123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System;
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.MatchingCompetition;
- using UnityEngine;
- namespace GFGGame
- {
- class MatchingCompetitionRankView : BaseWindow
- {
- private UI_MatchingCompetitionRankUI _ui;
- private int _currentIndex = 0;
- public override void Dispose()
- {
- if (_ui != null)
- {
- _ui.Dispose();
- }
- _ui = null;
- base.Dispose();
- }
- protected override void OnInit()
- {
- base.OnInit();
- packageName = UI_MatchingCompetitionRankUI.PACKAGE_NAME;
- _ui = UI_MatchingCompetitionRankUI.Create();
- this.viewCom = _ui.target;
- isReturnView = true;
- isfullScreen = true;
- _ui.m_RankList.itemRenderer = RenderRankList;
- _ui.m_BtnBack.onClick.Add(OnClickBtnBack);
- _ui.m_btnBefore.onClick.Add(OnClickBtnBefore);
- _ui.m_btnLook.onClick.Add(OnClickBtnLook);
- _ui.m_ruleBtn.onClick.Add(MatchingCompetitionDataManager.Instance.OnClickBtnRule);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- _ui.m_bg.url = ResPathUtil.GetBgImgPath("gzs_fb_bj");
- UpdateView();
- UpdateHead();
- }
- protected override void OnHide()
- {
- base.OnHide();
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void UpdateView()
- {
- MatchingPlayerData otherInfo = MatchingCompetitionDataManager.Instance._currentRankList[0];
- _ui.m_playerImage.texture = otherInfo.Ntexture;
- _currentIndex = 0;
- _ui.m_RankList.numItems = MatchingCompetitionDataManager.Instance._currentRankList.Count;
- }
- private void UpdateHead()
- {
- MatchingPlayerData otherInfo = new MatchingPlayerData();
- RoleInfoManager.Instance.UpdateHead(_ui.m_playerHead.m_head, otherInfo.HeadId, otherInfo.HeadBorderId);
- _ui.m_playerHead.m_nameText.text = otherInfo.OtherPlayerName.ToString();
- _ui.m_playerHead.m_countText.text = otherInfo.OtherPlayerPopularity.ToString();
- MatchingCompetitionDataManager.Instance.SetNumToRank(otherInfo.Rank,_ui.m_playerHead.m_RankIndex);
- }
- private void RenderRankList(int index, GObject obj)
- {
- UI_Component3 item = UI_Component3.Proxy(obj);
- MatchingPlayerData otherInfo = new MatchingPlayerData();
- otherInfo.Rank = index;
- RoleInfoManager.Instance.UpdateHead(item.m_head, otherInfo.HeadId, otherInfo.HeadBorderId);
- item.m_nameText.text = otherInfo.OtherPlayerName.ToString();
- item.m_countText.text = otherInfo.OtherPlayerPopularity.ToString();
- MatchingCompetitionDataManager.Instance.SetNumToRank(otherInfo.Rank, item.m_RankIndex);
- if(item.target.data == null)
- {
- item.target.onClick.Add(OnClickBtnItem);
- }
- item.target.data = index;
- UI_Component3.ProxyEnd();
- }
- private void OnClickBtnItem(EventContext context)
- {
- GObject item = context.sender as GObject;
- int index = (int)item.data;
- _currentIndex = index;
- MatchingPlayerData otherInfo = MatchingCompetitionDataManager.Instance._currentRankList[index];
- _ui.m_playerImage.texture = otherInfo.Ntexture;
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(MatchingCompetitionRankView).FullName);
- }
- private void OnClickBtnBefore()
- {
- ViewManager.Show<MatchingCompetitionWorksView>();
- }
- private void OnClickBtnLook()
- {
- }
- }
- }
|