TurnTableRewardTIpsView.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System.Collections;
  2. using UnityEngine;
  3. using UI.TurnTable;
  4. using FairyGUI;
  5. using System.Collections.Generic;
  6. using System;
  7. using cfg.GfgCfg;
  8. namespace GFGGame
  9. {
  10. public class TurnTableTipsRewardView : BaseWindow
  11. {
  12. private UI_TurnTableRewardUI _ui;
  13. private List<ItemData> _listItemDatas;
  14. private Action onSuccess = null;
  15. private List<EffectUI> _effects = new List<EffectUI>();
  16. private const int maxHeight = 1030;
  17. private EffectUI _effectUI1;
  18. private EffectUI _effectUI2;
  19. private EffectUI _effectUI3;
  20. private EffectUI _effectUI4;
  21. private int counTime = 0; //定时器计数
  22. public override void Dispose()
  23. {
  24. EffectUIPool.Recycle(_effectUI3);
  25. _effectUI3 = null;
  26. EffectUIPool.Recycle(_effectUI4);
  27. _effectUI4 = null;
  28. if (_ui != null)
  29. {
  30. _ui.Dispose();
  31. _ui = null;
  32. }
  33. base.Dispose();
  34. }
  35. protected override void OnInit()
  36. {
  37. base.OnInit();
  38. packageName = UI_TurnTableRewardUI.PACKAGE_NAME;
  39. _ui = UI_TurnTableRewardUI.Create();
  40. this.viewCom = _ui.target;
  41. //this.viewCom.Center();
  42. //this.modal = true;
  43. //viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  44. isfullScreen = true;
  45. _ui.m_comList.m_listReward.itemRenderer = RenderListRewardItem;
  46. _ui.m_mask.onClick.Add(this.Hide);
  47. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_bgEffect, "ui_league", "TEA");
  48. _effectUI4 = EffectUIPool.CreateEffectUI(_ui.m_bgEffect1, "ui_LuckyBox", "CK_Yellow_01");
  49. }
  50. protected override void OnShown()
  51. {
  52. base.OnShown();
  53. _ui.m_mask.touchable = false;
  54. if ((this.viewData as object[]).Length > 0)
  55. {
  56. _listItemDatas = (this.viewData as object[])[0] as List<ItemData>;
  57. onSuccess = (this.viewData as object[])[1] as Action;
  58. }
  59. else
  60. {
  61. _listItemDatas = this.viewData as List<ItemData>;
  62. }
  63. List<ItemData> suitPart = new List<ItemData>(); ;
  64. for (int i = _listItemDatas.Count - 1; i >= 0; i--)
  65. {
  66. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_listItemDatas[i].id);
  67. if (suitCfg != null)
  68. {
  69. for (int j = 0; j < suitCfg.Parts.Count; j++)
  70. {
  71. suitPart.Add(ItemUtil.createItemData(suitCfg.Parts[j], _listItemDatas[i].num));
  72. }
  73. _listItemDatas.RemoveAt(i);
  74. }
  75. }
  76. _listItemDatas.AddRange(suitPart);
  77. //_ui.m_listReward.SetVirtual(); //有虚拟列表的时候,没有办法居中显示列表
  78. _ui.m_downTipsText.visible = false;
  79. _ui.m_comList.m_listReward.numItems = 0;
  80. counTime = 0;
  81. _ui.m_bgEffect.visible = true;
  82. _ui.m_bgEffect1.visible = true;
  83. Timers.inst.Add(0.1f, 3, OnTimerUpdate, 1);
  84. Timers.inst.Add(0.5f, 1, OnTimerClick);
  85. }
  86. private void OnTimerClick(object param)
  87. {
  88. _ui.m_mask.touchable = true;
  89. }
  90. private void OnTimerUpdate(object param)
  91. {
  92. counTime += 1;
  93. if (counTime == 1)
  94. {
  95. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderTitle, "ui_hd", "GXHD_Text");
  96. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderBgCom, "ui_hd", "TC_Quad_ALL");
  97. }
  98. else if (counTime == 2)
  99. {
  100. _ui.m_comList.m_listReward.numItems = _listItemDatas.Count;
  101. _ui.m_comList.m_listReward.ResizeToFit();
  102. if (_ui.m_comList.m_listReward.height > maxHeight)
  103. {
  104. _ui.m_comList.m_listReward.height = maxHeight;
  105. }
  106. }
  107. else if (counTime == 3)
  108. {
  109. _ui.m_downTipsText.visible = true;
  110. Timers.inst.Remove(OnTimerUpdate);
  111. }
  112. }
  113. protected override void OnHide()
  114. {
  115. EffectUIPool.Recycle(_effectUI1);
  116. _effectUI1 = null;
  117. EffectUIPool.Recycle(_effectUI2);
  118. _effectUI2 = null;
  119. Timers.inst.Remove(OnTimerUpdate);
  120. Timers.inst.Remove(OnTimerClick);
  121. _ui.m_mask.touchable = true;
  122. for (int i = 0; i < _effects.Count; i++)
  123. {
  124. if (_effects[i] != null)
  125. {
  126. EffectUIPool.Recycle(_effects[i]);
  127. _effects[i] = null;
  128. }
  129. }
  130. _effects.Clear();
  131. if (onSuccess != null)
  132. {
  133. onSuccess();
  134. }
  135. base.OnHide();
  136. //_effects.Clear();
  137. //EventAgent.DispatchEvent(ConstMessage.REWARDVIEW_CLOTHER);
  138. GetSuitItemController.TryShow(0);
  139. if (ActivityDataManager.Instance.StartDropId != ActivityDataManager.Instance.TipsDropId)
  140. {
  141. PromptController.Instance.ShowFloatTextPrompt("特殊奖励已改变!");
  142. ActivityDataManager.Instance.StartDropId = ActivityDataManager.Instance.TipsDropId;
  143. }
  144. }
  145. private void RenderListRewardItem(int index, GObject obj)
  146. {
  147. // obj.data = _listItemDatas[index];
  148. UI.CommonGame.UI_ComItem item = UI.CommonGame.UI_ComItem.Proxy(obj);
  149. string name = "";
  150. string iconRes = "";
  151. string ext = "png";
  152. int rarity = 0;
  153. int id = 0;
  154. bool isSuit = false;
  155. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_listItemDatas[index].id);
  156. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_listItemDatas[index].id);
  157. if (suitCfg != null)
  158. {
  159. name = suitCfg.Name;
  160. iconRes = suitCfg.Res;
  161. rarity = suitCfg.Rarity;
  162. id = suitCfg.Id;
  163. isSuit = true;
  164. }
  165. else
  166. {
  167. name = itemCfg.Name;
  168. ext = ItemUtil.GetItemResExt(itemCfg.ItemType, itemCfg.SubType, true);
  169. iconRes = itemCfg.Res;
  170. id = itemCfg.Id;
  171. isSuit = false;
  172. //if (itemCfg.itemType == ConstItemType.DRESS_UP)
  173. rarity = itemCfg.Rarity;
  174. }
  175. item.m_txtName.text = name;
  176. // item.m_txtCount.text = _listItemDatas[index].num==1?"": string.Format("{0}", _listItemDatas[index].num);
  177. item.m_txtCount.text = string.Format("{0}", _listItemDatas[index].num);
  178. item.m_loaIcon.url = ResPathUtil.GetIconPath(iconRes, ext);
  179. if (rarity > 0)
  180. {
  181. item.m_QualityType.selectedIndex = rarity - 1;
  182. }
  183. else
  184. {
  185. item.m_QualityType.selectedIndex = 0;
  186. }
  187. RarityIconController.UpdateRarityIcon(item.m_loaRarity, id, false, isSuit);
  188. item.m_imgOnceBonus.visible = _listItemDatas[index].isOnceBonus;
  189. //特效("ui_ck", "ui_ck_zl");
  190. int childIndex = _ui.m_comList.m_listReward.ItemIndexToChildIndex(index);
  191. if (_effects.Count <= childIndex)
  192. {
  193. EffectUI _effectUI = EffectUIPool.CreateEffectUI(item.m_holderReware, "ui_hd", "GXHD_WuPin", 120);
  194. _effects.Add(_effectUI);
  195. }
  196. if (item.target.data == null)
  197. {
  198. item.target.onClick.Add(OnClickListReward);
  199. }
  200. item.target.data = _listItemDatas[index];
  201. UI.CommonGame.UI_ComItem.ProxyEnd();
  202. }
  203. private void OnClickListReward(EventContext context)
  204. {
  205. if (this.ShowTips)
  206. {
  207. ItemData data = (context.sender as GObject).data as ItemData;
  208. GoodsItemTipsController.ShowItemTips(data.id);
  209. }
  210. }
  211. private bool _showTips = true;
  212. /// <summary>
  213. /// 是否展示物品详情,默认展示
  214. /// </summary>
  215. private bool ShowTips
  216. {
  217. get { return _showTips; }
  218. set { _showTips = value; }
  219. }
  220. }
  221. }