LeagueSkillView.cs 4.4 KB

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