CardUpView.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using FairyGUI;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using cfg.GfgCfg;
  5. using UI.Card;
  6. using UI.CommonGame;
  7. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. public class CardUpView : BaseWindow
  11. {
  12. private UI_CardUpUI _ui;
  13. private Dictionary<int, int> _scores;
  14. private string _type;
  15. private int _lastNum;
  16. private int _curNum;
  17. private int _cardId;
  18. private string _fromUIType;
  19. private CardLvlCfg _cardLvCfg;
  20. private CardStarCfg _cardStarCfg;
  21. private int _mainScore = 0;
  22. private int _otherScore = 0;
  23. private int _itemCfgMainScore = 0;
  24. private EffectUI _effectUI1;
  25. private EffectUI _effectUI2;
  26. public override void Dispose()
  27. {
  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_CardUpUI.PACKAGE_NAME;
  39. _ui = UI_CardUpUI.Create();
  40. this.viewCom = _ui.target;
  41. this.viewCom.Center();
  42. this.modal = true;
  43. this.isfullScreen = true;
  44. //MakeFullScreen(_ui);
  45. _ui.target.onClick.Add(OnBackClick);
  46. _ui.m_listProperty.itemRenderer = RenderListPropertyItem;
  47. _ui.m_listLastProperty.itemRenderer = RenderListLastPropertyItem;
  48. _ui.m_listCardProperty.itemRenderer = RenderListCardPropertyItem;
  49. _ui.m_listLastCardProperty.itemRenderer = RenderListLastCardPropertyItem;
  50. }
  51. private void OnBackClick()
  52. {
  53. this.Hide();
  54. }
  55. protected override void OnShown()
  56. {
  57. base.OnShown();
  58. _scores = (Dictionary<int, int>)(viewData as object[])[0];
  59. _type = (string)(viewData as object[])[1];
  60. _lastNum = (int)(viewData as object[])[2];
  61. _curNum = (int)(viewData as object[])[3];
  62. _cardId = (int)(viewData as object[])[4];
  63. if ((viewData as object[]).Length > 5)
  64. _fromUIType = (string)(viewData as object[])[5];
  65. if (_type == "lv")
  66. {
  67. _ui.m_c1.selectedIndex = 0;
  68. _ui.m_txtLast.text = string.Format("{0}级", _lastNum);
  69. _ui.m_txtNow.text = string.Format("{0}级", _curNum);
  70. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_cardId);
  71. _cardLvCfg = CommonDataManager.Tables.TblCardLvlCfg.Get(itemCfg.Rarity, _lastNum);
  72. _cardStarCfg = null;
  73. _itemCfgMainScore = itemCfg.MainScore;
  74. _mainScore = 0;
  75. _otherScore = 0;
  76. for (int i = _lastNum; i < _curNum; i++)
  77. {
  78. CardLvlCfg cardLvCfg = CommonDataManager.Tables.TblCardLvlCfg.Get(itemCfg.Rarity, i);
  79. _mainScore += cardLvCfg.MainScore;
  80. _otherScore += cardLvCfg.OtherScore;
  81. }
  82. _ui.m_listProperty.numItems = _scores.Count;
  83. _ui.m_listLastProperty.numItems = _scores.Count;
  84. }
  85. else if (_type == "star")
  86. {
  87. _ui.m_c1.selectedIndex = 1;
  88. _ui.m_txtLast.text = string.Format("{0}星", _lastNum / 6);
  89. _ui.m_txtNow.text = string.Format("{0}星", _curNum / 6);
  90. _cardStarCfg = CommonDataManager.Tables.TblCardStarCfg.Get(_cardId, _lastNum);
  91. if (_cardStarCfg == null)
  92. ET.Log.Error("RenderListCardPropertyItemd _cardStarCfg 1 is null=" + _cardId + "==" + _lastNum);
  93. _cardLvCfg = null;
  94. _ui.m_listCardProperty.numItems = 1;
  95. _ui.m_listLastCardProperty.numItems = 1;
  96. }
  97. else
  98. {
  99. _ui.m_c1.selectedIndex = 2;
  100. _cardStarCfg = CommonDataManager.Tables.TblCardStarCfg.Get(_cardId, _lastNum);
  101. if (_cardStarCfg == null)
  102. ET.Log.Error("RenderListCardPropertyItemd _cardStarCfg 2 is null=" + _fromUIType + "==" + _cardId +
  103. "==" + _lastNum);
  104. _cardLvCfg = null;
  105. _ui.m_listCardProperty.numItems = 1;
  106. _ui.m_listLastCardProperty.numItems = 1;
  107. }
  108. Timers.inst.AddUpdate(CheckGuide);
  109. if (_type == "lv")
  110. EffectUIPool.CreateEffectUI(_ui.m_holderTitle, "ui_hd", "GXSJ_Text",
  111. onComplete: (effect) =>
  112. {
  113. if (effect != null)
  114. {
  115. _effectUI1 = effect;
  116. }
  117. });
  118. else
  119. EffectUIPool.CreateEffectUI(_ui.m_holderTitle, "ui_hd", "GXSX_Text",
  120. onComplete: (effect) =>
  121. {
  122. if (effect != null)
  123. {
  124. _effectUI1 = effect;
  125. }
  126. });
  127. EffectUIPool.CreateEffectUI(_ui.m_holderBgCom, "ui_hd", "TC_Quad_ALL",
  128. onComplete: (effect) =>
  129. {
  130. if (effect != null)
  131. {
  132. _effectUI2 = effect;
  133. }
  134. });
  135. }
  136. private void RenderListLastCardPropertyItem(int index, GObject obj)
  137. {
  138. UI_ListScoreItem2 listItem = UI_ListScoreItem2.Proxy(obj);
  139. int score = 0;
  140. int typeIndex = 1;
  141. listItem.m_ArrowsType.selectedIndex = 2;
  142. if (_cardStarCfg.Score1 > 0)
  143. {
  144. typeIndex = 1;
  145. score = _scores[typeIndex] - _cardStarCfg.Score1;
  146. }
  147. else if (_cardStarCfg.Score2 > 0)
  148. {
  149. typeIndex = 2;
  150. score = _scores[typeIndex] - _cardStarCfg.Score2;
  151. }
  152. else if (_cardStarCfg.Score3 > 0)
  153. {
  154. typeIndex = 3;
  155. score = _scores[typeIndex] - _cardStarCfg.Score3;
  156. }
  157. else if (_cardStarCfg.Score4 > 0)
  158. {
  159. typeIndex = 4;
  160. score = _scores[typeIndex] - _cardStarCfg.Score4;
  161. }
  162. listItem.m_txtProperty.text = score.ToString();
  163. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (typeIndex));
  164. UI_ListScoreItem2.ProxyEnd();
  165. }
  166. private void RenderListLastPropertyItem(int index, GObject obj)
  167. {
  168. UI_ListScoreItem2 listItem = UI_ListScoreItem2.Proxy(obj);
  169. int score = 0;
  170. listItem.m_ArrowsType.selectedIndex = 1;
  171. if ((index + 1) == _itemCfgMainScore)
  172. score = _scores[index + 1] - _mainScore;
  173. else
  174. score = _scores[index + 1] - _otherScore;
  175. listItem.m_txtProperty.text = score.ToString();
  176. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (index + 1));
  177. UI_ListScoreItem2.ProxyEnd();
  178. }
  179. private void RenderListPropertyItem(int index, GObject obj)
  180. {
  181. UI_ListScoreItem2 listItem = UI_ListScoreItem2.Proxy(obj);
  182. listItem.m_txtProperty.text = _scores[index + 1].ToString();
  183. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (index + 1));
  184. UI_ListScoreItem2.ProxyEnd();
  185. }
  186. private void RenderListCardPropertyItem(int index, GObject obj)
  187. {
  188. UI_ListScoreItem2 listItem = UI_ListScoreItem2.Proxy(obj);
  189. if (_cardStarCfg == null)
  190. ET.Log.Error("RenderListCardPropertyItemd _cardStarCfg is null");
  191. int typeIndex = 1;
  192. if (_cardStarCfg.Score1 > 0)
  193. typeIndex = 1;
  194. else if (_cardStarCfg.Score2 > 0)
  195. typeIndex = 2;
  196. else if (_cardStarCfg.Score3 > 0)
  197. typeIndex = 3;
  198. else if (_cardStarCfg.Score4 > 0)
  199. typeIndex = 4;
  200. _scores.TryGetValue(typeIndex, out var scoresValue);
  201. listItem.m_txtProperty.text = scoresValue.ToString();
  202. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + typeIndex);
  203. UI_ListScoreItem2.ProxyEnd();
  204. }
  205. protected override void OnHide()
  206. {
  207. base.OnHide();
  208. Timers.inst.Remove(CheckGuide);
  209. EffectUIPool.Recycle(_effectUI1);
  210. _effectUI1 = null;
  211. EffectUIPool.Recycle(_effectUI2);
  212. _effectUI2 = null;
  213. }
  214. private void CheckGuide(object param)
  215. {
  216. if (GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_LV) <= 0
  217. || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_STAR) <= 0)
  218. {
  219. UpdateToCheckGuide(null);
  220. }
  221. else
  222. {
  223. Timers.inst.Remove(CheckGuide);
  224. }
  225. }
  226. protected override void UpdateToCheckGuide(object param)
  227. {
  228. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  229. GuideController.TryGuide(null, ConstGuideId.UP_CARD_LV, 6, "升级成功啦", -1, true, 1500);
  230. GuideController.TryGuide(null, ConstGuideId.UP_CARD_STAR, 6, "升星成功啦", -1, true, 1500);
  231. }
  232. }
  233. }