MergeGameMaterialTipView.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.MiniGame;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class MergeGameMaterialTipView : BaseWindow
  10. {
  11. private UI_MergeGameRouteTips _ui;
  12. private int _res;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. _ui = null;
  19. }
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_MergeGameRouteTips.PACKAGE_NAME;
  26. _ui = UI_MergeGameRouteTips.Create();
  27. this.viewCom = _ui.target;
  28. isfullScreen = true;
  29. _ui.m_btnBack.onClick.Add(Hide);
  30. _ui.m_AFuList.itemRenderer = RenderAFuList;
  31. _ui.m_DouBaoList.itemRenderer = RenderDouBaoList;
  32. }
  33. protected override void OnShown()
  34. {
  35. base.OnShown();
  36. if (this.viewData != null && (this.viewData as object[]).Length != 2)
  37. {
  38. _res = (int)(this.viewData as object[])[0];
  39. }
  40. else
  41. {
  42. _res = 1;
  43. }
  44. _ui.m_AFuList.numItems = 10;
  45. _ui.m_DouBaoList.numItems = 10;
  46. }
  47. protected async override void OnHide()
  48. {
  49. bool result = await MiniGameProxy.ReqMergeGameNewStyle();
  50. base.OnHide();
  51. }
  52. private void RenderAFuList(int index, GObject obj)
  53. {
  54. UI_MergeGamematerialItem item = UI_MergeGamematerialItem.Proxy(obj);
  55. item.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgsByresTypeAndmaterialId(_res,index+11)[0].resName,"MergeGame");
  56. if( (index+1) % 5 == 0)
  57. {
  58. item.m_right.visible = false;
  59. }
  60. if(item.target.data == null)
  61. {
  62. item.target.onClick.Add(OnClickItem);
  63. }
  64. item.target.data = index + 1 + 10;
  65. int id = index + 1 + 10;
  66. if (MiniGameDateManager.Instance.NewItemIdDic.ContainsKey(id))
  67. {
  68. if (MiniGameDateManager.Instance.NewItemIdDic[id] == 1)
  69. {
  70. item.m_c1.selectedIndex = 1;
  71. }
  72. else
  73. {
  74. item.m_c1.selectedIndex = 0;
  75. }
  76. }
  77. else
  78. {
  79. item.m_c1.selectedIndex = 2;
  80. }
  81. UI_MergeGamematerialItem.ProxyEnd();
  82. }
  83. private void RenderDouBaoList(int index,GObject obj)
  84. {
  85. UI_MergeGamematerialItem item = UI_MergeGamematerialItem.Proxy(obj);
  86. item.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgsByresTypeAndmaterialId(_res, index+1)[0].resName, "MergeGame");
  87. if ((index + 1) % 5 == 0)
  88. {
  89. item.m_right.visible = false;
  90. }
  91. if (item.target.data == null)
  92. {
  93. item.target.onClick.Add(OnClickItem);
  94. }
  95. item.target.data = index + 1;
  96. int id = index + 1 + 10;
  97. if (MiniGameDateManager.Instance.NewItemIdDic.ContainsKey(id))
  98. {
  99. if (MiniGameDateManager.Instance.NewItemIdDic[id] == 1)
  100. {
  101. item.m_c1.selectedIndex = 1;
  102. }
  103. else
  104. {
  105. item.m_c1.selectedIndex = 0;
  106. }
  107. }
  108. else
  109. {
  110. item.m_c1.selectedIndex = 2;
  111. }
  112. UI_MergeGamematerialItem.ProxyEnd();
  113. }
  114. private void OnClickItem(EventContext context)
  115. {
  116. int index = (int)(context.sender as GObject).data;
  117. _ui.m_name.text = index.ToString();
  118. _ui.m_desc.text = index.ToString();
  119. }
  120. }
  121. }