From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/LevelRewardTerritoryHandler.cs | 196 +++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/LevelRewardTerritoryHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/LevelRewardTerritoryHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/LevelRewardTerritoryHandler.cs b/Client/Assets/Scripts/XMainClient/LevelRewardTerritoryHandler.cs new file mode 100644 index 00000000..339e0651 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/LevelRewardTerritoryHandler.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class LevelRewardTerritoryHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "Battle/LevelReward/GuildTerritoryResult"; + } + } + + private XGuildTerritoryDocument _doc = null; + + private IXUIButton m_btn_close; + + private IXUISprite mSprGuild; + + private IXUILabel m_lblGuildName; + + private IXUILabel m_lblTown; + + private IXUIWrapContent mGuildWrap; + + private IXUIWrapContent mRankWrap; + + public IXUILabel m_lblMyRank; + + private XUIPool mRwdPool; + + private GameObject mRwdTpl; + + private Vector3 tplPos; + + protected override void Init() + { + base.Init(); + this._doc = XDocuments.GetSpecificDocument(XGuildTerritoryDocument.uuID); + this.InitUI(); + } + + public void InitUI() + { + this.m_btn_close = (base.PanelObject.transform.Find("Bg/Close").GetComponent("XUIButton") as IXUIButton); + this.mSprGuild = (base.transform.Find("Bg/Town").GetComponent("XUISprite") as IXUISprite); + this.m_lblGuildName = (base.transform.Find("Bg/Town/GuildName").GetComponent("XUILabel") as IXUILabel); + this.m_lblTown = (base.transform.Find("Bg/Town/TownName").GetComponent("XUILabel") as IXUILabel); + this.mRankWrap = (base.transform.Find("Bg/RankPanel/wrap").GetComponent("XUIWrapContent") as IXUIWrapContent); + this.mGuildWrap = (base.transform.Find("Bg/guilds/wrap").GetComponent("XUIWrapContent") as IXUIWrapContent); + this.m_lblMyRank = (base.transform.Find("Bg/Reward/Rank").GetComponent("XUILabel") as IXUILabel); + this.mRwdTpl = base.transform.Find("Bg/Reward/ItemTpl").gameObject; + this.tplPos = this.mRwdTpl.transform.localPosition; + this.mRankWrap.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.WrapRankItemUpdate)); + this.mGuildWrap.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.WrapGuildItemUpdate)); + this.mRwdPool = new XUIPool(XSingleton.singleton.m_uiTool); + this.mRwdPool.SetupPool(this.mRwdTpl.transform.parent.gameObject, this.mRwdTpl, 2u, true); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_btn_close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClick)); + } + + private bool OnCloseClick(IXUIButton button) + { + PtcC2G_LeaveSceneReq proto = new PtcC2G_LeaveSceneReq(); + XSingleton.singleton.Send(proto); + return true; + } + + protected override void OnShow() + { + base.OnShow(); + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(XSingleton.singleton.SceneID); + bool flag = XSingleton.singleton.SceneType == SceneType.SCENE_CASTLE_FIGHT || XSingleton.singleton.SceneType == SceneType.SCENE_CASTLE_WAIT; + if (flag) + { + this._doc.SendGCFCommonReq(GCFReqType.GCF_FIGHT_RESULT); + } + } + + public void RefreshAll() + { + this.RefreshTitleInfo(); + this.RefreshGuildsInfo(); + this.RefreshMembersInfo(); + this.RefreshMyselfInfo(); + this.RefreshRwds(); + } + + private void RefreshTitleInfo() + { + XGuildTerritoryDocument specificDocument = XDocuments.GetSpecificDocument(XGuildTerritoryDocument.uuID); + TerritoryBattle.RowData byID = XGuildTerritoryDocument.mGuildTerritoryList.GetByID(specificDocument.territoryid); + bool flag = byID == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("territory is nil, id: " + specificDocument.territoryid, null, null, null, null, null); + } + else + { + this.mSprGuild.SetSprite(byID.territoryIcon); + this.m_lblGuildName.SetText(specificDocument.winguild.guildname); + this.m_lblTown.SetText(byID.territoryname); + } + } + + public void RefreshGuildsInfo() + { + XGuildTerritoryDocument specificDocument = XDocuments.GetSpecificDocument(XGuildTerritoryDocument.uuID); + specificDocument.guilds.Sort(new Comparison(this.SortGuild)); + this.mGuildWrap.SetContentCount(specificDocument.guilds.Count, false); + } + + private int SortGuild(GCFGuild x, GCFGuild y) + { + return (int)(y.brief.point - x.brief.point); + } + + public void RefreshMembersInfo() + { + XGuildTerritoryDocument specificDocument = XDocuments.GetSpecificDocument(XGuildTerritoryDocument.uuID); + this.mRankWrap.SetContentCount(specificDocument.roles.Count, false); + } + + private void RefreshMyselfInfo() + { + XGuildTerritoryDocument specificDocument = XDocuments.GetSpecificDocument(XGuildTerritoryDocument.uuID); + this.m_lblMyRank.SetText(specificDocument.mmyinfo.rank.ToString()); + } + + private void WrapGuildItemUpdate(Transform t, int index) + { + XGuildTerritoryDocument specificDocument = XDocuments.GetSpecificDocument(XGuildTerritoryDocument.uuID); + List guilds = specificDocument.guilds; + bool flag = guilds.Count > index; + if (flag) + { + IXUILabel ixuilabel = t.Find("Name").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel2 = t.Find("Score").GetComponent("XUILabel") as IXUILabel; + IXUISprite ixuisprite = t.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuilabel.SetText(specificDocument.guilds[index].brief.guildname); + ixuilabel2.SetText(specificDocument.guilds[index].brief.point.ToString()); + ixuisprite.SetSprite(XGuildDocument.GetPortraitName((int)specificDocument.guilds[index].brief.guildicon)); + } + } + + private void WrapRankItemUpdate(Transform t, int index) + { + XGuildTerritoryDocument specificDocument = XDocuments.GetSpecificDocument(XGuildTerritoryDocument.uuID); + List roles = specificDocument.roles; + bool flag = roles.Count > index; + if (flag) + { + IXUILabel ixuilabel = t.Find("Rank").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel2 = t.Find("Name").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel3 = t.Find("Kill").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel4 = t.Find("Times").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel5 = t.Find("feats").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(roles[index].rank.ToString()); + ixuilabel2.SetText(roles[index].rolename); + ixuilabel3.SetText(roles[index].killcount.ToString()); + ixuilabel4.SetText(roles[index].occupycount.ToString()); + ixuilabel5.SetText(roles[index].feats.ToString()); + } + } + + private void RefreshRwds() + { + this.mRwdPool.ReturnAll(false); + XGuildTerritoryDocument specificDocument = XDocuments.GetSpecificDocument(XGuildTerritoryDocument.uuID); + List rwds = specificDocument.rwds; + for (int i = 0; i < rwds.Count; i++) + { + GameObject gameObject = this.mRwdPool.FetchGameObject(false); + gameObject.transform.localPosition = new Vector3(this.tplPos.x + (float)(this.mRwdPool.TplWidth * i), this.tplPos.y, this.tplPos.z); + XItem xitem = XBagDocument.MakeXItem((int)rwds[i].itemID, rwds[i].isbind); + xitem.itemCount = (int)rwds[i].itemCount; + XItemDrawerMgr.Param.bBinding = rwds[i].isbind; + XSingleton.singleton.DrawItem(gameObject, xitem); + IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)rwds[i].itemID; + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton.singleton.OnItemClick)); + } + } + } +} -- cgit v1.1-26-g67d0