LuckyBoxBonusView.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.LuckyBox;
  4. using UI.CommonGame;
  5. using System.Collections.Generic;
  6. namespace GFGGame
  7. {
  8. public class LuckyBoxBonusView : BaseWindow
  9. {
  10. private UI_LuckBoxBonusUI _ui;
  11. private List<ItemData> itemList;
  12. private List<GameObject> _effects = new List<GameObject>();
  13. private List<GoWrapper> _wrappers = new List<GoWrapper>();
  14. private GameObject _effect;
  15. private GoWrapper _wrapper;
  16. public override void Dispose()
  17. {
  18. base.Dispose();
  19. for (int i = 0; i < _effects.Count; i++)
  20. {
  21. SceneController.DestroyObjectFromView(_effects[i]);
  22. }
  23. SceneController.DestroyObjectFromView(_effect);
  24. }
  25. protected override void OnInit()
  26. {
  27. base.OnInit();
  28. packageName = UI_LuckBoxBonusUI.PACKAGE_NAME;
  29. _ui = UI_LuckBoxBonusUI.Create();
  30. this.viewCom = _ui.target;
  31. isfullScreen = true;
  32. InitAllItem();
  33. _ui.m_loaBg.touchable = false;
  34. _ui.m_loaBg.onClick.Add(OnClickBg);
  35. string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_zl");
  36. for (int i = 0; i < 10; i++)
  37. {
  38. GameObject gameObject0;
  39. GoWrapper wrapper0;
  40. GGraph holder = _ui.target.GetChild("item" + i).asCom.GetChild("holder").asGraph;
  41. SceneController.AddObjectToView(null, null, holder, resPath, out gameObject0, out wrapper0);
  42. _effects.Add(gameObject0);
  43. }
  44. GGraph holder1 = _ui.target.GetChild("itemOne").asCom.GetChild("holder").asGraph;
  45. SceneController.AddObjectToView(null, null, holder1, resPath, out _effect, out _wrapper);
  46. }
  47. protected override void OnShown()
  48. {
  49. base.OnShown();
  50. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gxhd_bjbj");
  51. itemList = (viewData as object[])[0] as List<ItemData>;
  52. if (itemList != null)
  53. {
  54. _ui.m_loaBg.touchable = false;
  55. int count = itemList.Count;
  56. if (count == 10)
  57. {
  58. ShowBonusList(itemList);
  59. }
  60. else if (count > 0)
  61. {
  62. ShowBonus(itemList[0]);
  63. }
  64. else
  65. {
  66. _ui.m_loaBg.touchable = true;
  67. }
  68. }
  69. else
  70. {
  71. _ui.m_loaBg.touchable = true;
  72. }
  73. }
  74. protected override void OnHide()
  75. {
  76. base.OnHide();
  77. }
  78. private void OnClickBg()
  79. {
  80. this.Hide();
  81. ViewManager.Show(ViewName.LUCKY_BOX_VIEW, ViewManager.GetGoBackDatas(ViewName.LUCKY_BOX_STAR_VIEW));
  82. GetSuitItemController.TryShow(0);
  83. }
  84. private void ShowBonusList(List<ItemData> itemList)
  85. {
  86. HideAllItem();
  87. for (int i = 0; i < 10; i++)
  88. {
  89. ItemData itemData = itemList[i];
  90. GObject itemObject = _ui.target.GetChild("item" + i);
  91. if (itemObject != null)
  92. {
  93. UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(itemObject);
  94. UpdateItem(itemUI, itemData, i);
  95. UI_LuckyBoxBonusItem.ProxyEnd();
  96. Timers.inst.Add(0.3f * i, 1, (object param) =>
  97. {
  98. itemObject.visible = true;
  99. if ((int)param == 9)
  100. {
  101. Timers.inst.Add(0.1f, 1, (object param) =>
  102. {
  103. _ui.m_loaBg.touchable = true;
  104. // List<ItemData> list = LuckyBoxDataManager.Instance.GetFirstClothingList();
  105. // if (list.Count > 0)
  106. // {
  107. // ViewManager.Show(ViewName.LUCKY_BOX_CARD_VIEW, new object[] { list, FirstGetCardViewType.CANNOT_JUMP_CANNOT_SUIT });
  108. // }
  109. // else
  110. // {
  111. // GetSuitItemController.TryShow(0);
  112. // }
  113. });
  114. }
  115. }, i);
  116. }
  117. }
  118. }
  119. private void ShowBonus(ItemData itemData)
  120. {
  121. HideAllItem();
  122. _ui.m_itemOne.visible = true;
  123. UI_LuckyBoxBonusItem itemUI = UI_LuckyBoxBonusItem.Proxy(_ui.m_itemOne);
  124. UpdateItem(itemUI, itemData, 0);
  125. UI_LuckyBoxBonusItem.ProxyEnd();
  126. _ui.m_loaBg.touchable = true;
  127. }
  128. private void HideAllItem()
  129. {
  130. _ui.m_itemOne.visible = false;
  131. for (int i = 0; i < 10; i++)
  132. {
  133. GObject itemObject = _ui.target.GetChild("item" + i);
  134. if (itemObject != null)
  135. {
  136. itemObject.visible = false;
  137. }
  138. }
  139. }
  140. private void UpdateItem(UI_LuckyBoxBonusItem itemUI, ItemData itemData, int index)
  141. {
  142. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  143. itemUI.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  144. bool isFirst = true;
  145. int count = 0;
  146. for (int i = 0; i < itemList.Count; i++)
  147. {
  148. if (i < index && itemList[i].id == itemData.id)
  149. {
  150. isFirst = false;
  151. }
  152. if (itemList[i].id == itemData.id)
  153. {
  154. count++;
  155. }
  156. }
  157. itemUI.m_comIcon.m_imgNew.visible = ItemDataManager.GetItemNum(itemData.id) == count && isFirst ? true : false;
  158. string itemName = itemCfg.name;
  159. if (itemData.num > 1)
  160. {
  161. itemName += "x" + itemData.num;
  162. }
  163. itemUI.m_comIcon.m_txtName.text = itemName;
  164. RarityIconController.UpdateRarityIcon(itemUI.m_comIcon.m_rarity, itemData.id, false);
  165. itemUI.target.data = itemData.id;
  166. itemUI.m_comIcon.target.SetScale(0, 0);
  167. itemUI.m_t0.Play();
  168. // GTween.To(0, 1, 0.2f).SetTarget(itemUI).OnUpdate((GTweener t) => { itemUI.target.SetScale(t.value.x, t.value.x); });
  169. }
  170. private void InitAllItem()
  171. {
  172. _ui.m_itemOne.onClick.Add(OnClickItemUI);
  173. for (int i = 0; i < 10; i++)
  174. {
  175. GObject itemObject = _ui.target.GetChild("item" + i);
  176. if (itemObject != null)
  177. {
  178. itemObject.onClick.Add(OnClickItemUI);
  179. }
  180. }
  181. }
  182. private void OnClickItemUI(EventContext context)
  183. {
  184. GComponent item = context.sender as GComponent;
  185. int itemID = (int)item.data;
  186. GoodsItemTipsController.ShowItemTips(itemID);
  187. }
  188. }
  189. }