LeagueSkillView.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. isReturnView = true;
  35. _ui.m_btnBack.onClick.Add(OnBtnBackClick);
  36. _ui.m_listScore.itemRenderer = RenderListScoreItem;
  37. _ui.m_list.itemRenderer = RenderListItem;
  38. _valueBarController = new ValueBarController(_ui.m_comValue);
  39. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("lm_beijing2");
  40. }
  41. protected override void AddEventListener()
  42. {
  43. base.AddEventListener();
  44. // EventAgent.AddEventListener(ConstMessage.ACTIVE_SKILL,)
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. _valueBarController.OnShown();
  50. _valueBarController.Controller(11);
  51. _ui.m_listScore.numItems = 4;
  52. _ui.m_list.numItems = LeagueSkillCountCfgArray.Instance.dataArray.Length;
  53. if (LeagueDataManager.Instance.GetSkillProgressByType(_ui.m_list.numItems) < 100)
  54. {
  55. _ui.m_list.ScrollToView(LeagueDataManager.Instance.MaxFinishType);
  56. }
  57. }
  58. protected override void OnHide()
  59. {
  60. base.OnHide();
  61. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  62. _valueBarController.OnHide();
  63. }
  64. protected override void RemoveEventListener()
  65. {
  66. base.RemoveEventListener();
  67. }
  68. private void OnBtnBackClick()
  69. {
  70. ViewManager.GoBackFrom(typeof(LeagueSkillView).FullName);
  71. }
  72. private void UpdateView()
  73. {
  74. }
  75. private void RenderListScoreItem(int index, GObject obj)
  76. {
  77. UI_ListScoreItem item = UI_ListScoreItem.Proxy(obj);
  78. item.m_loaIcon.url = ResPathUtil.GetScorePath(index + 1);
  79. item.m_txtProperty.text = LeagueDataManager.Instance.GetAllSkillScore(index + 1).ToString();
  80. UI_ListScoreItem.ProxyEnd();
  81. }
  82. private void RenderListItem(int index, GObject obj)
  83. {
  84. LeagueSkillCountCfg skillCountCfg = LeagueSkillCountCfgArray.Instance.dataArray[index];
  85. UI_ListSkillTypeItem item = UI_ListSkillTypeItem.Proxy(obj);
  86. int maxFinishType = LeagueDataManager.Instance.MaxFinishType;
  87. item.m_txtTitle.text = string.Format("茶艺·{0}", skillCountCfg.name);
  88. item.m_loaBg.url = string.Format("ui://League/skill_{0}", index + 1);
  89. item.m_grpLock.visible = skillCountCfg.type > maxFinishType + 1;
  90. double progress = LeagueDataManager.Instance.GetSkillProgressByType(skillCountCfg.type);
  91. // item.m_txtProgress.text = string.Format("进度{0}%", progress);
  92. item.m_txtProgress.SetVar("value", progress.ToString()).FlushVars();
  93. // item.m_txtProgress.text = LeagueDataManager.Instance.GetSkillProgressByType(skillCountCfg.type).ToString();
  94. if (item.target.data == null)
  95. {
  96. item.target.onClick.Add(OnUpSkillClick);
  97. }
  98. item.target.data = skillCountCfg.type;
  99. UI_ListSkillTypeItem.ProxyEnd();
  100. }
  101. private void OnUpSkillClick(EventContext context)
  102. {
  103. GObject obj = context.sender as GObject;
  104. int type = (int)obj.data;
  105. if (type > LeagueDataManager.Instance.MaxFinishType + 1)
  106. {
  107. PromptController.Instance.ShowFloatTextPrompt("学完前一类所有技能开启");
  108. return;
  109. }
  110. ViewManager.Show<LeagueSkillUpView>(type, new object[] { typeof(LeagueSkillView).FullName });
  111. }
  112. }
  113. }