LuckyBoxNewDressView.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System.Collections;
  2. using UnityEngine;
  3. using UI.LuckyBox;
  4. using System.Collections.Generic;
  5. using FairyGUI;
  6. using System.Linq;
  7. namespace GFGGame
  8. {
  9. public class LuckyBoxNewDressView : BaseWindow
  10. {
  11. private UI_LuckyBoxNewDressUI _ui;
  12. private List<ItemData> _rewardList = new List<ItemData>();
  13. // private List<ItemData> _newRewardList = new List<ItemData>();
  14. // private List<ItemData> _oldRewardList = new List<ItemData>();
  15. // private List<ItemData> _showRewardList = new List<ItemData>();
  16. // private int _type = 0;//弹窗类型:0可跳过,1:首次获得物品不可跳过,2首次获得物品不可跳过,不弹获得套装界面
  17. private GameObject gameObject;
  18. private GoWrapper wrapper;
  19. private GameObject gameObject1;
  20. private GoWrapper wrapper1;
  21. private GameObject gameObject2;
  22. private GoWrapper wrapper2;
  23. public override void Dispose()
  24. {
  25. base.Dispose();
  26. SceneController.DestroyObjectFromView(gameObject, wrapper);
  27. SceneController.DestroyObjectFromView(gameObject1, wrapper1);
  28. SceneController.DestroyObjectFromView(gameObject2, wrapper2);
  29. if (_ui != null)
  30. {
  31. _ui.Dispose();
  32. _ui = null;
  33. }
  34. }
  35. protected override void OnInit()
  36. {
  37. base.OnInit();
  38. packageName = UI_LuckyBoxNewDressUI.PACKAGE_NAME;
  39. _ui = UI_LuckyBoxNewDressUI.Create();
  40. this.viewCom = _ui.target;
  41. isfullScreen = true;
  42. this.modal = true;
  43. _ui.m_loaBg.onTouchBegin.Add(OnClickBg);
  44. _ui.m_btnPass.onClick.Add(OnClickBtnPass);
  45. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
  46. string resPath = ResPathUtil.GetViewEffectPath("ui_ck", "ui_ck_zs");
  47. SceneController.AddObjectToView(gameObject, null, _ui.m_comCard.m_holder, resPath, out gameObject, out wrapper);
  48. }
  49. protected override void OnShown()
  50. {
  51. base.OnShown();
  52. _rewardList = this.viewData as List<ItemData>;
  53. _ui.m_btnPass.visible = false;
  54. // _newRewardList.Clear();
  55. // _oldRewardList.Clear();
  56. // for (int i = 0; i < _rewardList.Count; i++)
  57. // {
  58. // if (GetThisCount(_rewardList[i].id, _rewardList) == ItemDataManager.GetItemNum(_rewardList[i].id) && !IsAddToNewRewardList(_rewardList[i].id))
  59. // {
  60. // _newRewardList.Add(_rewardList[i]);
  61. // }
  62. // else
  63. // {
  64. // _oldRewardList.Add(_rewardList[i]);
  65. // }
  66. // }
  67. // if (LuckyBoxDataManager.Instance.luckyBoxId > 0)//必展示必掉奖励
  68. // {
  69. // int[][] bonus = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.luckyBoxId).bonusArr;
  70. // List<ItemData> itemDatas = ItemUtil.CreateItemDataList(bonus, LuckyBoxDataManager.Instance.times);
  71. // _newRewardList.AddRange(itemDatas);
  72. // LuckyBoxDataManager.Instance.luckyBoxId = 0;
  73. // }
  74. LuckyBoxDataManager.Instance.luckyBoxId = 0;
  75. UpdateView();
  76. }
  77. private void UpdateView()
  78. {
  79. // _ui.m_btnPass.visible = _newRewardList.Count <= 1;
  80. // _newRewardList.Count > 0 ? _newRewardList : _oldRewardList;
  81. if (_rewardList.Count - 1 < 0) return;
  82. ItemData itemdata = _rewardList[_rewardList.Count - 1];
  83. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdata.id);
  84. string resPath = "";
  85. string resPath1 = "";
  86. switch (itemCfg.rarity)
  87. {
  88. case ConstDressRarity.Rarity_TIANYI:
  89. resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Yellow_01");
  90. SceneController.AddObjectToView(gameObject1, wrapper1, _ui.m_comCard.m_holder, resPath, out gameObject1, out wrapper1);
  91. _ui.m_comCard.m_holder.visible = true;
  92. resPath1 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Yellow_01_top");
  93. SceneController.AddObjectToView(gameObject2, wrapper2, _ui.m_comCard.m_holder1, resPath1, out gameObject2, out wrapper2);
  94. _ui.m_comCard.m_holder1.visible = true;
  95. break;
  96. case ConstDressRarity.Rarity_DIANCANG:
  97. resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Purple_02");
  98. SceneController.AddObjectToView(gameObject1, wrapper1, _ui.m_comCard.m_holder, resPath, out gameObject1, out wrapper1);
  99. _ui.m_comCard.m_holder.visible = true;
  100. resPath1 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Purple_02_top");
  101. SceneController.AddObjectToView(gameObject2, wrapper2, _ui.m_comCard.m_holder1, resPath1, out gameObject2, out wrapper2);
  102. _ui.m_comCard.m_holder1.visible = true;
  103. break;
  104. case ConstDressRarity.Rarity_ZHENXI:
  105. resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_Bule_03");
  106. SceneController.AddObjectToView(gameObject1, wrapper1, _ui.m_comCard.m_holder, resPath, out gameObject1, out wrapper1);
  107. _ui.m_comCard.m_holder.visible = true;
  108. break;
  109. case ConstDressRarity.Rarity_FANPIN:
  110. resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_grey_04");
  111. SceneController.AddObjectToView(gameObject1, wrapper1, _ui.m_comCard.m_holder, resPath, out gameObject1, out wrapper1);
  112. _ui.m_comCard.m_holder.visible = true;
  113. break;
  114. }
  115. _ui.m_comCard.m_loaType.url = ResPathUtil.GetCommonGameResPath("hd_sxicon_" + itemCfg.rarity);
  116. _ui.m_comCard.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  117. _ui.m_comCard.m_loaProperty.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + itemCfg.mainScore);
  118. _ui.m_comCard.m_txtName.text = itemCfg.name;
  119. _ui.m_comCard.m_txtDiscribe.text = itemCfg.desc;
  120. if (LuckyBoxDataManager.Instance.FirstRewardList.ContainsKey(_rewardList.Count - 1) == true)
  121. {
  122. LuckyBoxDataManager.Instance.FirstRewardList.Remove(_rewardList.Count - 1);
  123. }
  124. _rewardList.RemoveAt(_rewardList.Count - 1);
  125. }
  126. private void OnClickBg()
  127. {
  128. if (_rewardList.Count == 0)
  129. {
  130. // // if (_type == (int)FirstGetCardViewType.JUMP)
  131. // // {
  132. // ViewManager.Show(ViewName.LUCKY_BOX_BONUS_VIEW, new object[] { (this.viewData as object[])[0] as List<ItemData>, _rewardList });
  133. // // }
  134. // // else if (_type == (int)FirstGetCardViewType.CANNOT_JUMP)
  135. // // {
  136. // // GetSuitItemController.TryShow(0);
  137. // // }
  138. this.Hide();
  139. return;
  140. }
  141. _ui.m_t_close.Play(() =>
  142. {
  143. _ui.m_comCard.m_holder.visible = false;
  144. _ui.m_comCard.m_holder1.visible = false;
  145. _ui.m_t_open.Play();
  146. UpdateView();
  147. });
  148. }
  149. private int GetThisCount(int itemId, List<ItemData> rewards)
  150. {
  151. int count = 0;
  152. for (int i = 0; i < rewards.Count; i++)
  153. {
  154. if (rewards[i].id == itemId)
  155. {
  156. count++;
  157. }
  158. }
  159. return count;
  160. }
  161. private bool IsAddToNewRewardList(int itemId)
  162. {
  163. for (int i = 0; i < _rewardList.Count; i++)
  164. {
  165. if (itemId == _rewardList[i].id)
  166. {
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. private void OnClickBtnPass()
  173. {
  174. ViewManager.Show(ViewName.LUCKY_BOX_BONUS_VIEW, new object[] { (this.viewData as object[])[0], _rewardList });
  175. this.Hide();
  176. }
  177. protected override void OnHide()
  178. {
  179. _ui.m_t_close.Stop(true, false);
  180. _ui.m_t_open.Stop(true, false);
  181. _rewardList.Clear();
  182. base.OnHide();
  183. }
  184. }
  185. }