MergeGameMaterialTipView.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.GetCfgByresTypeAndmaterialld(_res,index+11).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. if (index % 5 == 0)
  82. {
  83. item.m_c1.selectedIndex = 0;
  84. }
  85. UI_MergeGamematerialItem.ProxyEnd();
  86. }
  87. private void RenderDouBaoList(int index,GObject obj)
  88. {
  89. UI_MergeGamematerialItem item = UI_MergeGamematerialItem.Proxy(obj);
  90. item.m_icon.url = ResPathUtil.GetMiniGamePicPath(MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(_res, index+1).resName, "MergeGame");
  91. if ((index + 1) % 5 == 0)
  92. {
  93. item.m_right.visible = false;
  94. }
  95. if (item.target.data == null)
  96. {
  97. item.target.onClick.Add(OnClickItem);
  98. }
  99. item.target.data = index + 1;
  100. int id = index + 1;
  101. if (MiniGameDateManager.Instance.NewItemIdDic.ContainsKey(id))
  102. {
  103. if (MiniGameDateManager.Instance.NewItemIdDic[id] == 1)
  104. {
  105. item.m_c1.selectedIndex = 1;
  106. }
  107. else
  108. {
  109. item.m_c1.selectedIndex = 0;
  110. }
  111. }
  112. else
  113. {
  114. item.m_c1.selectedIndex = 2;
  115. }
  116. if (index % 5 == 0)
  117. {
  118. item.m_c1.selectedIndex = 0;
  119. }
  120. UI_MergeGamematerialItem.ProxyEnd();
  121. }
  122. private void OnClickItem(EventContext context)
  123. {
  124. int index = (int)(context.sender as GObject).data;
  125. MergeCfg mergeCfg = MergeCfgArray.Instance.GetCfgByresTypeAndmaterialld(MiniGameDateManager.Instance.MergeGameMatType, index);
  126. _ui.m_name.text = mergeCfg.name;
  127. _ui.m_desc.text = mergeCfg.desc;
  128. }
  129. }
  130. }