StoryCardChoose.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using FairyGUI;
  4. using UI.CommonGame;
  5. using UI.Main;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class StoryCardChoose : BaseWindow
  10. {
  11. private UI_StoryCardChooseUI _ui;
  12. private List<CardData> cardList = new List<CardData>();
  13. private static int _scoreType;
  14. private List<GameObject> _effects = new List<GameObject>();
  15. private List<GoWrapper> _wrappers = new List<GoWrapper>();
  16. public override void Dispose()
  17. {
  18. base.Dispose();
  19. for (int i = 0; i < _effects.Count; i++)
  20. {
  21. SceneController.DestroyObjectFromView(_effects[i], _wrappers[i]);
  22. }
  23. if (_ui != null)
  24. {
  25. _ui.Dispose();
  26. _ui = null;
  27. }
  28. }
  29. protected override void OnInit()
  30. {
  31. base.OnInit();
  32. packageName = UI_StoryCardChooseUI.PACKAGE_NAME;
  33. _ui = UI_StoryCardChooseUI.Create();
  34. this.viewCom = _ui.target;
  35. this.viewCom.Center();
  36. this.modal = true;
  37. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  38. _ui.m_listCard.SetVirtual();
  39. _ui.m_listCard.itemRenderer = RenderListCardItem;
  40. _ui.m_listCard.onClickItem.Add(OnListCardItemClick);
  41. _ui.m_btnCancel.onClick.Add(OnBtnCancelClick);
  42. _ui.m_btnConfirm.onClick.Add(OnBtnComfirmClick);
  43. }
  44. protected override void OnShown()
  45. {
  46. base.OnShown();
  47. _scoreType = (int)viewData;
  48. cardList = CardDataManager.GetCardListByRarity(0);
  49. cardList = FightDataManager.Instance.SortCardList(cardList, MyDressUpHelper.dressUpObj.itemList, _scoreType);
  50. _ui.m_listCard.numItems = cardList.Count;
  51. _ui.m_listCard.selectedIndex = 0;
  52. UpdateView(0);
  53. Timers.inst.AddUpdate(CheckGuide);
  54. }
  55. private void UpdateView(int index)
  56. {
  57. // CardData cardData = cardList[index];
  58. _ui.m_loaScore.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + _scoreType);
  59. int cardId = cardList[index].id;
  60. _ui.m_txtName.text = "";
  61. _ui.m_txtDiscribe.text = "";
  62. PassivitySkillCfg cfg = ScoreSystemData.Instance.GetShowSkillCfg(cardId);
  63. if (cfg == null) return;
  64. int skillId = ScoreSystemData.Instance.GetShowSkillCfg(cardId).skillId;
  65. int skillLv = SkillDataManager.Instance.GetSkillLv(cardId, skillId);
  66. PassivitySkillLvlCfg skillLvCfg = PassivitySkillLvlCfgArray.Instance.GetCfgByskilllvlAndskillId(skillLv, skillId);
  67. _ui.m_txtName.text = cfg.name;
  68. _ui.m_txtDiscribe.text = skillLvCfg.describe;
  69. }
  70. private void RenderListCardItem(int index, GObject obj)
  71. {
  72. CardData cardData = cardList[index];
  73. UI_ListCardItem item = UI_ListCardItem.Proxy(obj);// obj as GButton;
  74. item.m_txtName.text = cardData.itemCfg.name;
  75. item.m_comCardMask.m_loaCard.asLoader.url = ResPathUtil.GetCardSmallPath(cardData.resources[cardData.resIndex]);
  76. item.m_txtLv.text = string.Format("Lv.\n{0}", cardData.lv);
  77. // item.m_loaRarity.url = ResPathUtil.GetCommonGameResPath("kp_sxing_x_" + cardData.itemCfg.rarity);
  78. RarityIconController.UpdateRarityIcon(item.m_loaRarity, cardData.itemCfg.id, false);// ResPathUtil.GetCommonGameResPath("kp_sxing_x_" + data.itemCfg.rarity);
  79. item.m_loaMainScore.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (cardData.itemCfg.mainScore));
  80. // UI_ComStar comStar = UI_ComStar.Proxy(item.m_comStar);
  81. item.m_txtStarLv.text = cardData.star.ToString();
  82. // comStar.m_c1.selectedIndex = cardData.star;
  83. if (_effects.Count <= index)
  84. {
  85. string resPath = ResPathUtil.GetViewEffectPath("ui_xz", "ui_xz_zd_kq");
  86. GameObject gameObject0;
  87. GoWrapper wrapper0;
  88. SceneController.AddObjectToView(null, null, item.m_holder, resPath, out gameObject0, out wrapper0);
  89. _effects.Add(gameObject0);
  90. _wrappers.Add(wrapper0);
  91. }
  92. UI_ListCardItem.ProxyEnd();
  93. // UI_ComStar.ProxyEnd();
  94. }
  95. private void OnListCardItemClick(EventContext context)
  96. {
  97. UpdateView(_ui.m_listCard.selectedIndex);
  98. }
  99. private void OnBtnComfirmClick()
  100. {
  101. int cardId = cardList[_ui.m_listCard.selectedIndex].id;
  102. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Arena)
  103. {
  104. ArenaDataManager dataManager = ArenaDataManager.Instance;
  105. ArenaSproxy.ReqChangeArenaDressup(dataManager.SelectThemeIndex, cardId, MyDressUpHelper.dressUpObj.itemList).Coroutine();
  106. }
  107. else
  108. {
  109. List<PassivitySkillCfg> cfgs = PassivitySkillCfgArray.Instance.GetCfgsBycardId(cardId);
  110. InstanceZonesDataManager.currentCardId = cfgs.Count > 0 ? cardId : -1;
  111. EventAgent.DispatchEvent(ConstMessage.CARD_CHOOSE);
  112. }
  113. this.Hide();
  114. }
  115. private void OnBtnCancelClick()
  116. {
  117. this.Hide();
  118. }
  119. protected override void OnHide()
  120. {
  121. base.OnHide();
  122. _ui.m_listCard.ScrollToView(0);
  123. Timers.inst.Remove(CheckGuide);
  124. if (InstanceZonesDataManager.FightScene == ConstInstanceZonesType.Arena)
  125. {
  126. ViewManager.GoBackFrom(typeof(ArenaDressUpFightView).FullName);
  127. }
  128. }
  129. private void CheckGuide(object param)
  130. {
  131. if (GuideDataManager.IsGuideFinish(ConstGuideId.SKILL_CARD_FIGHT) <= 0)
  132. {
  133. UpdateToCheckGuide(null);
  134. }
  135. else
  136. {
  137. Timers.inst.Remove(CheckGuide);
  138. }
  139. }
  140. protected override void UpdateToCheckGuide(object param)
  141. {
  142. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  143. GuideController.TryGuide(null, ConstGuideId.SKILL_CARD_FIGHT, 1, "词牌可以辅助战斗,增加过关概率哦。", -1, true, _ui.m_btnCancel.y + _ui.m_btnCancel.height);
  144. GuideController.TryGuide(_ui.m_listCard, ConstGuideId.SKILL_CARD_FIGHT, 2, "选择一张合适的词牌,增加过关战斗力。", 0);
  145. GuideController.TryCompleteGuide(ConstGuideId.SKILL_CARD_FIGHT, 2);
  146. }
  147. }
  148. }