LeagueSkillView.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using ET;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. using UI.League;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. //联盟技能
  9. public class LeagueSkillView : BaseWindow
  10. {
  11. private UI_LeagueSkillUI _ui;
  12. private ValueBarController _valueBarController;
  13. public override void Dispose()
  14. {
  15. if (_valueBarController != null)
  16. {
  17. _valueBarController.Dispose();
  18. _valueBarController = null;
  19. }
  20. if (_ui != null)
  21. {
  22. _ui.Dispose();
  23. _ui = null;
  24. }
  25. base.Dispose();
  26. }
  27. protected override void OnInit()
  28. {
  29. base.OnInit();
  30. packageName = UI_LeagueSkillUI.PACKAGE_NAME;
  31. _ui = UI_LeagueSkillUI.Create();
  32. this.viewCom = _ui.target;
  33. isfullScreen = true;
  34. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  35. _ui.m_listScore.itemRenderer = RenderListScoreItem;
  36. _ui.m_list.itemRenderer = RenderListItem;
  37. _valueBarController = new ValueBarController(_ui.m_comValue);
  38. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("lm_beijing");
  39. }
  40. protected override void AddEventListener()
  41. {
  42. base.AddEventListener();
  43. // EventAgent.AddEventListener(ConstMessage.ACTIVE_SKILL,)
  44. }
  45. protected override void OnShown()
  46. {
  47. base.OnShown();
  48. _valueBarController.OnShown();
  49. _valueBarController.Controller(11);
  50. _ui.m_listScore.numItems = 4;
  51. _ui.m_list.numItems = LeagueSkillCountCfgArray.Instance.dataArray.Length;
  52. if (LeagueDataManager.Instance.GetSkillProgressByType(_ui.m_list.numItems) < 100)
  53. {
  54. _ui.m_list.ScrollToView(LeagueDataManager.Instance.CurType - 1);
  55. }
  56. }
  57. protected override void OnHide()
  58. {
  59. base.OnHide();
  60. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  61. _valueBarController.OnHide();
  62. }
  63. protected override void RemoveEventListener()
  64. {
  65. base.RemoveEventListener();
  66. }
  67. private void OnBtnBackClick()
  68. {
  69. ViewManager.GoBackFrom(typeof(LeagueSkillView).FullName);
  70. }
  71. private void UpdateView()
  72. {
  73. }
  74. private void RenderListScoreItem(int index, GObject obj)
  75. {
  76. UI_ListScoreItem item = UI_ListScoreItem.Proxy(obj);
  77. item.m_loaIcon.url = ResPathUtil.GetScorePath(index + 1);
  78. item.m_txtProperty.text = LeagueDataManager.Instance.GetAllSkillScore(index + 1).ToString();
  79. UI_ListScoreItem.ProxyEnd();
  80. }
  81. private void RenderListItem(int index, GObject obj)
  82. {
  83. LeagueSkillCountCfg skillCountCfg = LeagueSkillCountCfgArray.Instance.dataArray[index];
  84. UI_ListSkillTypeItem item = UI_ListSkillTypeItem.Proxy(obj);
  85. if (skillCountCfg.type <= LeagueDataManager.Instance.CurType)
  86. {
  87. item.m_txtTitle.text = string.Format("茶艺-{0}", skillCountCfg.name);
  88. }
  89. else
  90. {
  91. LeagueSkillCountCfg lastSkillCountCfg = LeagueSkillCountCfgArray.Instance.dataArray[index - 1];
  92. item.m_txtTitle.text = string.Format("学习完茶艺-{0}后开启", lastSkillCountCfg.name);
  93. }
  94. double progress = LeagueDataManager.Instance.GetSkillProgressByType(skillCountCfg.type);
  95. item.m_txtProgress.text = string.Format("进度{0}%", progress);
  96. // item.m_txtProgress.text = LeagueDataManager.Instance.GetSkillProgressByType(skillCountCfg.type).ToString();
  97. if (item.target.data == null)
  98. {
  99. item.target.onClick.Add(OnUpSkillClick);
  100. }
  101. item.target.data = skillCountCfg.type;
  102. UI_ListSkillTypeItem.ProxyEnd();
  103. }
  104. private void OnUpSkillClick(EventContext context)
  105. {
  106. GObject obj = context.sender as GObject;
  107. int type = (int)obj.data;
  108. if (type > LeagueDataManager.Instance.CurType)
  109. {
  110. PromptController.Instance.ShowFloatTextPrompt("学完前一类所有技能开启");
  111. return;
  112. }
  113. ViewManager.Show<LeagueSkillUpView>(type, new object[] { typeof(LeagueSkillView).FullName });
  114. }
  115. }
  116. }