MergeGameMaterialTipView.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. _ui.m_ruleTips.onClick.Add(RuleController.ShowRuleView);
  33. _ui.m_ruleTips.data = 300036;
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. if (this.viewData != null && (this.viewData as object[]).Length != 2)
  39. {
  40. _res = (int)(this.viewData as object[])[0];
  41. }
  42. else
  43. {
  44. _res = 1;
  45. }
  46. _ui.m_AFuList.numItems = 10;
  47. _ui.m_DouBaoList.numItems = 10;
  48. }
  49. protected async override void OnHide()
  50. {
  51. bool result = await MiniGameProxy.ReqMergeGameNewStyle();
  52. base.OnHide();
  53. }
  54. private void RenderAFuList(int index, GObject obj)
  55. {
  56. UI_MergeGamematerialItem item = UI_MergeGamematerialItem.Proxy(obj);
  57. item.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res,index+11).resName,"MergeGame");
  58. if( (index+1) % 5 == 0)
  59. {
  60. item.m_right.visible = false;
  61. }
  62. if(item.target.data == null)
  63. {
  64. item.target.onClick.Add(OnClickItem);
  65. }
  66. item.target.data = index + 1 + 10;
  67. int id = index + 1 + 10;
  68. if (MiniGameDateManager.Instance.NewItemIdDic.ContainsKey(id))
  69. {
  70. if (MiniGameDateManager.Instance.NewItemIdDic[id] == 1)
  71. {
  72. item.m_c1.selectedIndex = 1;
  73. }
  74. else
  75. {
  76. item.m_c1.selectedIndex = 0;
  77. }
  78. }
  79. else
  80. {
  81. item.m_c1.selectedIndex = 2;
  82. }
  83. if (index % 5 == 0)
  84. {
  85. item.m_c1.selectedIndex = 0;
  86. }
  87. UI_MergeGamematerialItem.ProxyEnd();
  88. }
  89. private void RenderDouBaoList(int index,GObject obj)
  90. {
  91. UI_MergeGamematerialItem item = UI_MergeGamematerialItem.Proxy(obj);
  92. item.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, index+1).resName, "MergeGame");
  93. if ((index + 1) % 5 == 0)
  94. {
  95. item.m_right.visible = false;
  96. }
  97. if (item.target.data == null)
  98. {
  99. item.target.onClick.Add(OnClickItem);
  100. }
  101. item.target.data = index + 1;
  102. int id = index + 1;
  103. if (MiniGameDateManager.Instance.NewItemIdDic.ContainsKey(id))
  104. {
  105. if (MiniGameDateManager.Instance.NewItemIdDic[id] == 1)
  106. {
  107. item.m_c1.selectedIndex = 1;
  108. }
  109. else
  110. {
  111. item.m_c1.selectedIndex = 0;
  112. }
  113. }
  114. else
  115. {
  116. item.m_c1.selectedIndex = 2;
  117. }
  118. if (index % 5 == 0)
  119. {
  120. item.m_c1.selectedIndex = 0;
  121. }
  122. UI_MergeGamematerialItem.ProxyEnd();
  123. }
  124. private void OnClickItem(EventContext context)
  125. {
  126. int index = (int)(context.sender as GObject).data;
  127. MergeCfg mergeCfg = MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(MiniGameDateManager.Instance.MergeGameMatType, index);
  128. _ui.m_name.text = mergeCfg.name;
  129. _ui.m_desc.text = mergeCfg.desc;
  130. }
  131. }
  132. }