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 OnShown() { base.OnShown(); _ui.m_bg.url = ResPathUtil.GetBgImgPath("pxs_bj"); _ui.m_titleText.text = JudgingRoundOpenCfgArray.Instance.dataArray[MatchingCompetitionDataManager.Instance.MatchingCompetitionSeason - 1].Name; UpdateView(); UpdateHead(); } protected override void OnHide() { base.OnHide(); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.DOWNLOAD_FINISH, UpdateView); } private void UpdateView() { if(MatchingCompetitionDataManager.Instance._currentRankList.Count > 0) { MatchingPhotoWorksData otherInfo = MatchingCompetitionDataManager.Instance._currentRankList[0]; _ui.m_playerImage.texture = otherInfo.Ntexture; } else { _ui.m_playerImage.texture = null; } _currentIndex = 0; _ui.m_RankList.numItems = MatchingCompetitionDataManager.Instance._currentRankList.Count; } private void UpdateHead() { RoleInfoManager.Instance.UpdateHead(_ui.m_playerHead.m_head, RoleDataManager.headId, RoleDataManager.headBorderId); _ui.m_playerHead.m_nameText.text = RoleDataManager.roleName.ToString(); _ui.m_playerHead.m_countText.text = MatchingCompetitionDataManager.Instance.myWorks.Score.ToString(); MatchingCompetitionDataManager.Instance.SetNumToRank(MatchingCompetitionDataManager.Instance.myWorks.Rank,_ui.m_playerHead.m_RankIndex); } private void RenderRankList(int index, GObject obj) { UI_Component3 item = UI_Component3.Proxy(obj); MatchingPhotoWorksData otherdata = MatchingCompetitionDataManager.Instance._currentRankList[index]; JudgingRoundRoleInfo otherInfo = otherdata.JudgingInfo; otherInfo.Rank = index + 1; RoleInfoManager.Instance.UpdateHead(item.m_head, otherInfo.HeadItemId, otherInfo.HeadBorderItemId); item.m_nameText.text = otherInfo.RoleName.ToString(); item.m_countText.text = otherInfo.Score.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; MatchingPhotoWorksData otherInfo = MatchingCompetitionDataManager.Instance._currentRankList[index]; _ui.m_playerImage.texture = otherInfo.Ntexture; } private void OnClickBtnBack() { ViewManager.GoBackFrom(typeof(MatchingCompetitionRankView).FullName); } private async void OnClickBtnBefore() { bool result = await MatchingCompetitionSproxy.ReqBeforeWorks(); if(result) { ViewManager.Show(); } else { PromptController.Instance.ShowFloatTextPrompt("暂无往期数据!"); } } private void OnClickBtnLook() { List AllIdList = new List(); foreach (var info in MatchingCompetitionDataManager.Instance._currentRankList[_currentIndex].JudgingInfo.CollocationInfoList) { AllIdList.Add(MatchingCompetitionDataManager.Instance.GetIDByString(info.ItemId)); } MatchingCompetitionDataManager.Instance.DetailNtexture = MatchingCompetitionDataManager.Instance._currentRankList[_currentIndex].Ntexture; ViewManager.Show(AllIdList); } } }