MatchingCompetitionRankView.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.MatchingCompetition;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. class MatchingCompetitionRankView : BaseWindow
  10. {
  11. private UI_MatchingCompetitionRankUI _ui;
  12. private int _currentIndex = 0;
  13. public override void Dispose()
  14. {
  15. if (_ui != null)
  16. {
  17. _ui.Dispose();
  18. }
  19. _ui = null;
  20. base.Dispose();
  21. }
  22. protected override void OnInit()
  23. {
  24. base.OnInit();
  25. packageName = UI_MatchingCompetitionRankUI.PACKAGE_NAME;
  26. _ui = UI_MatchingCompetitionRankUI.Create();
  27. this.viewCom = _ui.target;
  28. isReturnView = true;
  29. isfullScreen = true;
  30. _ui.m_RankList.itemRenderer = RenderRankList;
  31. _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
  32. _ui.m_btnBefore.onClick.Add(OnClickBtnBefore);
  33. _ui.m_btnLook.onClick.Add(OnClickBtnLook);
  34. _ui.m_ruleBtn.onClick.Add(MatchingCompetitionDataManager.Instance.OnClickBtnRule);
  35. }
  36. protected override void AddEventListener()
  37. {
  38. base.AddEventListener();
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. _ui.m_bg.url = ResPathUtil.GetBgImgPath("gzs_fb_bj");
  44. UpdateView();
  45. UpdateHead();
  46. }
  47. protected override void OnHide()
  48. {
  49. base.OnHide();
  50. }
  51. protected override void RemoveEventListener()
  52. {
  53. base.RemoveEventListener();
  54. }
  55. private void UpdateView()
  56. {
  57. MatchingPlayerData otherInfo = MatchingCompetitionDataManager.Instance._currentRankList[0];
  58. _ui.m_playerImage.texture = otherInfo.Ntexture;
  59. _currentIndex = 0;
  60. _ui.m_RankList.numItems = MatchingCompetitionDataManager.Instance._currentRankList.Count;
  61. }
  62. private void UpdateHead()
  63. {
  64. MatchingPlayerData otherInfo = new MatchingPlayerData();
  65. RoleInfoManager.Instance.UpdateHead(_ui.m_playerHead.m_head, otherInfo.HeadId, otherInfo.HeadBorderId);
  66. _ui.m_playerHead.m_nameText.text = otherInfo.OtherPlayerName.ToString();
  67. _ui.m_playerHead.m_countText.text = otherInfo.OtherPlayerPopularity.ToString();
  68. MatchingCompetitionDataManager.Instance.SetNumToRank(otherInfo.Rank,_ui.m_playerHead.m_RankIndex);
  69. }
  70. private void RenderRankList(int index, GObject obj)
  71. {
  72. UI_Component3 item = UI_Component3.Proxy(obj);
  73. MatchingPlayerData otherInfo = new MatchingPlayerData();
  74. otherInfo.Rank = index;
  75. RoleInfoManager.Instance.UpdateHead(item.m_head, otherInfo.HeadId, otherInfo.HeadBorderId);
  76. item.m_nameText.text = otherInfo.OtherPlayerName.ToString();
  77. item.m_countText.text = otherInfo.OtherPlayerPopularity.ToString();
  78. MatchingCompetitionDataManager.Instance.SetNumToRank(otherInfo.Rank, item.m_RankIndex);
  79. if(item.target.data == null)
  80. {
  81. item.target.onClick.Add(OnClickBtnItem);
  82. }
  83. item.target.data = index;
  84. UI_Component3.ProxyEnd();
  85. }
  86. private void OnClickBtnItem(EventContext context)
  87. {
  88. GObject item = context.sender as GObject;
  89. int index = (int)item.data;
  90. _currentIndex = index;
  91. MatchingPlayerData otherInfo = MatchingCompetitionDataManager.Instance._currentRankList[index];
  92. _ui.m_playerImage.texture = otherInfo.Ntexture;
  93. }
  94. private void OnClickBtnBack()
  95. {
  96. ViewManager.GoBackFrom(typeof(MatchingCompetitionRankView).FullName);
  97. }
  98. private void OnClickBtnBefore()
  99. {
  100. ViewManager.Show<MatchingCompetitionWorksView>();
  101. }
  102. private void OnClickBtnLook()
  103. {
  104. }
  105. }
  106. }