TurnTableRewardTIpsView.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. EffectUIPool.CreateEffectUI(_ui.m_bgEffect, "ui_league", "TEA",
  48. onComplete: (effect) =>
  49. {
  50. if (effect != null)
  51. {
  52. _effectUI3 = effect;
  53. }
  54. });
  55. EffectUIPool.CreateEffectUI(_ui.m_bgEffect1, "ui_LuckyBox", "CK_Yellow_01",
  56. onComplete: (effect) =>
  57. {
  58. if (effect != null)
  59. {
  60. _effectUI4 = effect;
  61. }
  62. });
  63. }
  64. protected override void OnShown()
  65. {
  66. base.OnShown();
  67. _ui.m_mask.touchable = false;
  68. if ((this.viewData as object[]).Length > 0)
  69. {
  70. _listItemDatas = (this.viewData as object[])[0] as List<ItemData>;
  71. onSuccess = (this.viewData as object[])[1] as Action;
  72. }
  73. else
  74. {
  75. _listItemDatas = this.viewData as List<ItemData>;
  76. }
  77. List<ItemData> suitPart = new List<ItemData>();
  78. ;
  79. for (int i = _listItemDatas.Count - 1; i >= 0; i--)
  80. {
  81. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_listItemDatas[i].id);
  82. if (suitCfg != null)
  83. {
  84. for (int j = 0; j < suitCfg.Parts.Count; j++)
  85. {
  86. suitPart.Add(ItemUtil.createItemData(suitCfg.Parts[j], _listItemDatas[i].num));
  87. }
  88. _listItemDatas.RemoveAt(i);
  89. }
  90. }
  91. _listItemDatas.AddRange(suitPart);
  92. //_ui.m_listReward.SetVirtual(); //有虚拟列表的时候,没有办法居中显示列表
  93. _ui.m_downTipsText.visible = false;
  94. _ui.m_comList.m_listReward.numItems = 0;
  95. counTime = 0;
  96. _ui.m_bgEffect.visible = true;
  97. _ui.m_bgEffect1.visible = true;
  98. Timers.inst.Add(0.1f, 3, OnTimerUpdate, 1);
  99. Timers.inst.Add(0.5f, 1, OnTimerClick);
  100. }
  101. private void OnTimerClick(object param)
  102. {
  103. _ui.m_mask.touchable = true;
  104. }
  105. private void OnTimerUpdate(object param)
  106. {
  107. counTime += 1;
  108. if (counTime == 1)
  109. {
  110. EffectUIPool.CreateEffectUI(_ui.m_holderTitle, "ui_hd", "GXHD_Text",
  111. onComplete: (effect) =>
  112. {
  113. if (effect != null)
  114. {
  115. _effectUI1 = effect;
  116. }
  117. });
  118. EffectUIPool.CreateEffectUI(_ui.m_holderBgCom, "ui_hd", "TC_Quad_ALL",
  119. onComplete: (effect) =>
  120. {
  121. if (effect != null)
  122. {
  123. _effectUI2 = effect;
  124. }
  125. });
  126. }
  127. else if (counTime == 2)
  128. {
  129. _ui.m_comList.m_listReward.numItems = _listItemDatas.Count;
  130. _ui.m_comList.m_listReward.ResizeToFit();
  131. if (_ui.m_comList.m_listReward.height > maxHeight)
  132. {
  133. _ui.m_comList.m_listReward.height = maxHeight;
  134. }
  135. }
  136. else if (counTime == 3)
  137. {
  138. _ui.m_downTipsText.visible = true;
  139. Timers.inst.Remove(OnTimerUpdate);
  140. }
  141. }
  142. protected override void OnHide()
  143. {
  144. EffectUIPool.Recycle(_effectUI1);
  145. _effectUI1 = null;
  146. EffectUIPool.Recycle(_effectUI2);
  147. _effectUI2 = null;
  148. Timers.inst.Remove(OnTimerUpdate);
  149. Timers.inst.Remove(OnTimerClick);
  150. _ui.m_mask.touchable = true;
  151. for (int i = 0; i < _effects.Count; i++)
  152. {
  153. if (_effects[i] != null)
  154. {
  155. EffectUIPool.Recycle(_effects[i]);
  156. _effects[i] = null;
  157. }
  158. }
  159. _effects.Clear();
  160. if (onSuccess != null)
  161. {
  162. onSuccess();
  163. }
  164. base.OnHide();
  165. //_effects.Clear();
  166. //EventAgent.DispatchEvent(ConstMessage.REWARDVIEW_CLOTHER);
  167. GetSuitItemController.TryShow(0);
  168. if (ActivityDataManager.Instance.StartDropId != ActivityDataManager.Instance.TipsDropId)
  169. {
  170. PromptController.Instance.ShowFloatTextPrompt("特殊奖励已改变!");
  171. ActivityDataManager.Instance.StartDropId = ActivityDataManager.Instance.TipsDropId;
  172. }
  173. }
  174. private void RenderListRewardItem(int index, GObject obj)
  175. {
  176. // obj.data = _listItemDatas[index];
  177. UI.CommonGame.UI_ComItem item = UI.CommonGame.UI_ComItem.Proxy(obj);
  178. string name = "";
  179. string iconRes = "";
  180. string ext = "png";
  181. int rarity = 0;
  182. int id = 0;
  183. bool isSuit = false;
  184. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(_listItemDatas[index].id);
  185. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_listItemDatas[index].id);
  186. if (suitCfg != null)
  187. {
  188. name = suitCfg.Name;
  189. iconRes = suitCfg.Res;
  190. rarity = suitCfg.Rarity;
  191. id = suitCfg.Id;
  192. isSuit = true;
  193. }
  194. else
  195. {
  196. name = itemCfg.Name;
  197. ext = ItemUtil.GetItemResExt(itemCfg.ItemType, itemCfg.SubType, true);
  198. iconRes = itemCfg.Res;
  199. id = itemCfg.Id;
  200. isSuit = false;
  201. //if (itemCfg.itemType == ConstItemType.DRESS_UP)
  202. rarity = itemCfg.Rarity;
  203. }
  204. item.m_txtName.text = name;
  205. // item.m_txtCount.text = _listItemDatas[index].num==1?"": string.Format("{0}", _listItemDatas[index].num);
  206. item.m_txtCount.text = string.Format("{0}", _listItemDatas[index].num);
  207. item.m_loaIcon.url = ResPathUtil.GetIconPath(iconRes, ext);
  208. if (rarity > 0)
  209. {
  210. item.m_QualityType.selectedIndex = rarity - 1;
  211. }
  212. else
  213. {
  214. item.m_QualityType.selectedIndex = 0;
  215. }
  216. RarityIconController.UpdateRarityIcon(item.m_loaRarity, id, false, isSuit);
  217. item.m_imgOnceBonus.visible = _listItemDatas[index].isOnceBonus;
  218. //特效("ui_ck", "ui_ck_zl");
  219. int childIndex = _ui.m_comList.m_listReward.ItemIndexToChildIndex(index);
  220. if (_effects.Count <= childIndex)
  221. {
  222. EffectUIPool.CreateEffectUI(item.m_holderReware, "ui_hd", "GXHD_WuPin", 120,
  223. onComplete: (effect) =>
  224. {
  225. if (effect != null)
  226. {
  227. _effects.Add(effect);
  228. }
  229. });
  230. }
  231. if (item.target.data == null)
  232. {
  233. item.target.onClick.Add(OnClickListReward);
  234. }
  235. item.target.data = _listItemDatas[index];
  236. UI.CommonGame.UI_ComItem.ProxyEnd();
  237. }
  238. private void OnClickListReward(EventContext context)
  239. {
  240. if (this.ShowTips)
  241. {
  242. ItemData data = (context.sender as GObject).data as ItemData;
  243. GoodsItemTipsController.ShowItemTips(data.id);
  244. }
  245. }
  246. private bool _showTips = true;
  247. /// <summary>
  248. /// 是否展示物品详情,默认展示
  249. /// </summary>
  250. private bool ShowTips
  251. {
  252. get { return _showTips; }
  253. set { _showTips = value; }
  254. }
  255. }
  256. }