CardUpView.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. using FairyGUI;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UI.Card;
  5. using UI.CommonGame;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class CardUpView : BaseWindow
  10. {
  11. private UI_CardUpUI _ui;
  12. private Dictionary<int, int> _scores;
  13. private string _type;
  14. private int _lastNum;
  15. private int _curNum;
  16. private int _cardId;
  17. private CardLvlCfg _cardLvCfg;
  18. private CardStarCfg _cardStarCfg;
  19. private int _mainScore = 0;
  20. private int _otherScore = 0;
  21. private int _itemCfgMainScore = 0;
  22. public override void Dispose()
  23. {
  24. if (_ui != null)
  25. {
  26. _ui.Dispose();
  27. _ui = null;
  28. }
  29. base.Dispose();
  30. }
  31. protected override void OnInit()
  32. {
  33. base.OnInit();
  34. _ui = UI_CardUpUI.Create();
  35. this.viewCom = _ui.target;
  36. this.viewCom.Center();
  37. this.modal = true;
  38. //MakeFullScreen(_ui);
  39. _ui.m_bgTouch.onClick.Add(OnBackClick);
  40. _ui.m_listProperty.itemRenderer = RenderListPropertyItem;
  41. _ui.m_listLastProperty.itemRenderer = RenderListLastPropertyItem;
  42. _ui.m_listCardProperty.itemRenderer = RenderListCardPropertyItem;
  43. _ui.m_listLastCardProperty.itemRenderer = RenderListLastCardPropertyItem;
  44. }
  45. private void OnBackClick()
  46. {
  47. this.Hide();
  48. }
  49. protected override void OnShown()
  50. {
  51. base.OnShown();
  52. _scores = (Dictionary<int, int>)(viewData as object[])[0];
  53. _type = (string)(viewData as object[])[1];
  54. _lastNum = (int)(viewData as object[])[2];
  55. _curNum = (int)(viewData as object[])[3];
  56. _cardId = (int)(viewData as object[])[4];
  57. if (_type == "lv")
  58. {
  59. _ui.m_c1.selectedIndex = 0;
  60. _ui.m_txtLast.text = string.Format("{0}级", _lastNum);
  61. _ui.m_txtNow.text = string.Format("{0}级", _curNum);
  62. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_cardId);
  63. _cardLvCfg = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(itemCfg.rarity, _lastNum);
  64. _cardStarCfg = null;
  65. _itemCfgMainScore = itemCfg.mainScore;
  66. _mainScore = 0;
  67. _otherScore = 0;
  68. for (int i = _lastNum; i < _curNum; i++)
  69. {
  70. CardLvlCfg cardLvCfg = CardLvlCfgArray.Instance.GetCfgByrarityAndcardLvl(itemCfg.rarity, i);
  71. _mainScore += cardLvCfg.mainScore;
  72. _otherScore += cardLvCfg.otherScore;
  73. }
  74. _ui.m_listProperty.numItems = _scores.Count;
  75. _ui.m_listLastProperty.numItems = _scores.Count;
  76. }
  77. else if (_type == "star")
  78. {
  79. _ui.m_c1.selectedIndex = 1;
  80. _ui.m_txtLast.text = string.Format("{0}星", _lastNum / 5);
  81. _ui.m_txtNow.text = string.Format("{0}星", _curNum / 5);
  82. _cardStarCfg = CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(_cardId, _lastNum);
  83. _cardLvCfg = null;
  84. _ui.m_listCardProperty.numItems = 1;
  85. _ui.m_listLastCardProperty.numItems = 1;
  86. }
  87. else {
  88. _ui.m_c1.selectedIndex = 2;
  89. _cardStarCfg = CardStarCfgArray.Instance.GetCfgBycardIdAndstarLvl(_cardId, _lastNum);
  90. _cardLvCfg = null;
  91. _ui.m_listCardProperty.numItems = 1;
  92. _ui.m_listLastCardProperty.numItems = 1;
  93. }
  94. Timers.inst.AddUpdate(CheckGuide);
  95. }
  96. private void RenderListLastCardPropertyItem(int index, GObject obj)
  97. {
  98. UI_ListScoreItem2 listItem = UI_ListScoreItem2.Proxy(obj);
  99. int score = 0;
  100. int typeIndex = 0;
  101. listItem.m_ArrowsType.selectedIndex = 2;
  102. if (_cardStarCfg.score1 > 0) {
  103. typeIndex = 1;
  104. score = _scores[typeIndex] - _cardStarCfg.score1;
  105. }
  106. else if (_cardStarCfg.score2 > 0)
  107. {
  108. typeIndex = 2;
  109. score = _scores[typeIndex] - _cardStarCfg.score2;
  110. }
  111. else if (_cardStarCfg.score3 > 0)
  112. {
  113. typeIndex = 3;
  114. score = _scores[typeIndex] - _cardStarCfg.score3;
  115. }
  116. else if (_cardStarCfg.score4 > 0)
  117. {
  118. typeIndex = 4;
  119. score = _scores[typeIndex] - _cardStarCfg.score4;
  120. }
  121. listItem.m_txtProperty.text = score.ToString();
  122. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (typeIndex));
  123. UI_ListScoreItem2.ProxyEnd();
  124. }
  125. private void RenderListLastPropertyItem(int index, GObject obj)
  126. {
  127. UI_ListScoreItem2 listItem = UI_ListScoreItem2.Proxy(obj);
  128. int score = 0;
  129. listItem.m_ArrowsType.selectedIndex = 1;
  130. if ((index + 1) == _itemCfgMainScore)
  131. score = _scores[index + 1] - _mainScore;
  132. else
  133. score = _scores[index + 1] - _otherScore;
  134. listItem.m_txtProperty.text = score.ToString();
  135. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (index + 1));
  136. UI_ListScoreItem2.ProxyEnd();
  137. }
  138. private void RenderListPropertyItem(int index, GObject obj)
  139. {
  140. UI_ListScoreItem2 listItem = UI_ListScoreItem2.Proxy(obj);
  141. listItem.m_txtProperty.text = _scores[index + 1].ToString();
  142. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (index + 1));
  143. UI_ListScoreItem2.ProxyEnd();
  144. }
  145. private void RenderListCardPropertyItem(int index, GObject obj)
  146. {
  147. UI_ListScoreItem2 listItem = UI_ListScoreItem2.Proxy(obj);
  148. int typeIndex = 0;
  149. if (_cardStarCfg.score1 > 0)
  150. typeIndex = 1;
  151. else if (_cardStarCfg.score2 > 0)
  152. typeIndex = 2;
  153. else if (_cardStarCfg.score3 > 0)
  154. typeIndex = 3;
  155. else if (_cardStarCfg.score4 > 0)
  156. typeIndex = 4;
  157. listItem.m_txtProperty.text = _scores[typeIndex].ToString();
  158. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + typeIndex);
  159. UI_ListScoreItem2.ProxyEnd();
  160. }
  161. protected override void OnHide()
  162. {
  163. base.OnHide();
  164. Timers.inst.Remove(CheckGuide);
  165. }
  166. private void CheckGuide(object param)
  167. {
  168. if (GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_LV) <= 0
  169. || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_STAR) <= 0)
  170. {
  171. UpdateToCheckGuide(null);
  172. }
  173. else
  174. {
  175. Timers.inst.Remove(CheckGuide);
  176. }
  177. }
  178. protected override void UpdateToCheckGuide(object param)
  179. {
  180. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  181. GuideController.TryGuide(null, ConstGuideId.UP_CARD_LV, 6, "升级成功啦", -1, true, 1500);
  182. GuideController.TryGuide(null, ConstGuideId.UP_CARD_STAR, 6, "升星成功啦", -1, true, 1500);
  183. }
  184. }
  185. }