MergeGameMaterialTipView.cs 4.3 KB

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