From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/HeroBattleHandler.cs | 655 +++++++++++++++++++++ 1 file changed, 655 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/HeroBattleHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/HeroBattleHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/HeroBattleHandler.cs b/Client/Assets/Scripts/XMainClient/UI/HeroBattleHandler.cs new file mode 100644 index 00000000..8c394044 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/HeroBattleHandler.cs @@ -0,0 +1,655 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class HeroBattleHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "Battle/HeroBattleHandler"; + } + } + + private XHeroBattleDocument _doc = null; + + private XHeroBattleSkillDocument _skillDoc = null; + + private List m_Team = new List(); + + private GameObject m_Death; + + private IXUILabel m_ReviveLeftTime; + + private Transform m_ProgressTs; + + private IXUILabel m_ProgressTips; + + private Transform m_ProgressTipsTs; + + private IXUIProgress m_Progress; + + private Transform m_AddTimeTs; + + private IXUIProgress m_AddTimeProgress; + + private IXUIButton m_ChangeHeroBtn; + + private IXUILabel m_KillText; + + private IXUILabel m_DeadText; + + private IXUILabel m_AssitText; + + private Transform m_AncientParent; + + private IXUILabel m_AncientPercent; + + private IXUIProgress m_AncientSlider; + + private IXUISprite[] m_AncientSkill = new IXUISprite[3]; + + private bool _isAncientFull; + + private IXUISprite m_AttrShowBtn; + + private IXUISprite m_AncientTipsBtn; + + private IXUISprite m_AncientTipsCloseBtn; + + private IXUILabel m_AncientTips; + + private uint m_AncientTipsCloseToken; + + private Color blueColor; + + private Color redColor; + + private XFx _Fx; + + private XFx _OccupantFx; + + private XFx _EndFx; + + private uint _MiniMapFxToken; + + private uint _CurrentOccupant; + + private bool _InCircleMyself; + + private bool _IsInFight; + + private uint _ProgressTeam; + + private bool _InAddTime; + + private float _AddTimePerTurn; + + private float _SignTime; + + private bool _OnDeath; + + private float _ReviveTime; + + private float _ReviveSignTime; + + private float _LootProgress; + + private bool _HaveEnd; + + private XFx[] _skillFx = new XFx[3]; + + private XFx _barFx; + + public MapSignalHandler m_MapSignalHandler; + + protected override void Init() + { + base.Init(); + this._doc = XDocuments.GetSpecificDocument(XHeroBattleDocument.uuID); + this._skillDoc = XDocuments.GetSpecificDocument(XHeroBattleSkillDocument.uuID); + this._doc._HeroBattleHandler = this; + this.m_Death = base.transform.Find("Death").gameObject; + this.m_Death.transform.localPosition = XGameUI.Far_Far_Away; + this.m_ReviveLeftTime = (this.m_Death.transform.Find("LeftTime").GetComponent("XUILabel") as IXUILabel); + this.m_ChangeHeroBtn = (this.m_Death.gameObject.transform.Find("ChangeHeroBtn").GetComponent("XUIButton") as IXUIButton); + this.m_ProgressTs = base.transform.Find("Progress"); + this.m_ProgressTipsTs = base.transform.Find("TextTs"); + this.m_ProgressTs.localPosition = XGameUI.Far_Far_Away; + this.m_ProgressTipsTs.localPosition = XGameUI.Far_Far_Away; + this.m_Progress = (this.m_ProgressTs.Find("ProgressBar").GetComponent("XUIProgress") as IXUIProgress); + this.m_AddTimeTs = base.transform.Find("AddTime"); + this.m_AddTimeTs.localPosition = XGameUI.Far_Far_Away; + this.m_AddTimeProgress = (this.m_AddTimeTs.Find("AddtimeBar").GetComponent("XUIProgress") as IXUIProgress); + this.m_ProgressTips = (base.transform.Find("TextTs/Text").GetComponent("XUILabel") as IXUILabel); + this.m_ProgressTips.SetText(XStringDefineProxy.GetString("HeroBattleLoot")); + GameObject gameObject = base.transform.Find("Score").gameObject; + gameObject.SetActive(!XSingleton.singleton.bSpectator); + this.m_KillText = (base.transform.Find("Score/kill").GetComponent("XUILabel") as IXUILabel); + this.m_DeadText = (base.transform.Find("Score/dead").GetComponent("XUILabel") as IXUILabel); + this.m_AssitText = (base.transform.Find("Score/help").GetComponent("XUILabel") as IXUILabel); + this.m_AttrShowBtn = (base.transform.Find("AttrShowBtn").GetComponent("XUISprite") as IXUISprite); + this.m_AncientParent = base.transform.Find("AncientBarParent"); + this.m_AncientPercent = (base.transform.Find("AncientBarParent/AncientSkillBar/Num").GetComponent("XUILabel") as IXUILabel); + this.m_AncientSlider = (base.transform.Find("AncientBarParent/AncientSkillBar").GetComponent("XUIProgress") as IXUIProgress); + for (int i = 0; i < 3; i++) + { + this.m_AncientSkill[i] = (base.transform.Find(string.Format("AncientSkill/Skill{0}", i)).GetComponent("XUISprite") as IXUISprite); + this.m_AncientSkill[i].ID = (ulong)((long)i + 1L); + this.m_AncientSkill[i].RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAncientSkillClick)); + this.m_AncientSkill[i].SetVisible(false); + } + this._isAncientFull = false; + this.SetAncientPercent(0f); + this.m_AncientTipsBtn = (base.transform.Find("AncientBarParent/AncientSkillBar/Foreground").GetComponent("XUISprite") as IXUISprite); + this.m_AncientTips = (base.transform.Find("AncientTips/Desc").GetComponent("XUILabel") as IXUILabel); + this.m_AncientTipsCloseBtn = (base.transform.Find("AncientTips/Close").GetComponent("XUISprite") as IXUISprite); + this.m_AncientTips.gameObject.transform.parent.gameObject.SetActive(false); + this.m_Team.Clear(); + HeroBattleTeam item = new HeroBattleTeam(base.transform.Find("Scoreboard/BlueTeam")); + HeroBattleTeam item2 = new HeroBattleTeam(base.transform.Find("Scoreboard/RedTeam")); + this.m_Team.Add(item); + this.m_Team.Add(item2); + List intList = XSingleton.singleton.GetIntList("HeroBattleBlueColor"); + this.blueColor = new Color((float)intList[0] / 255f, (float)intList[1] / 255f, (float)intList[2] / 255f); + intList = XSingleton.singleton.GetIntList("HeroBattleRedColor"); + this.redColor = new Color((float)intList[0] / 255f, (float)intList[1] / 255f, (float)intList[2] / 255f); + this._AddTimePerTurn = float.Parse(XSingleton.singleton.GetValue("HeroBattleOverTime")); + this._ReviveTime = float.Parse(XSingleton.singleton.GetValue("HeroBattleReviveTime")); + this._CurrentOccupant = 0u; + this._InCircleMyself = false; + this._IsInFight = false; + this._ProgressTeam = 0u; + this._LootProgress = 0f; + this._MiniMapFxToken = 0u; + this._InAddTime = false; + this._OnDeath = false; + this._HaveEnd = false; + this.SetFx(0u); + bool bSpectator = XSingleton.singleton.bSpectator; + if (bSpectator) + { + this.m_AncientSlider.SetVisible(false); + base.transform.Find("MapSignalHandler").gameObject.SetActive(false); + this.m_AttrShowBtn.SetVisible(false); + } + else + { + DlgHandlerBase.EnsureCreate(ref this.m_MapSignalHandler, base.transform.Find("MapSignalHandler").gameObject, this, true); + } + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_ChangeHeroBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnChangeHeroBtnClick)); + this.m_AttrShowBtn.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAttrShowBtnClick)); + this.m_AncientTipsBtn.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAncientTipsBtnClick)); + this.m_AncientTipsCloseBtn.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAncientCloseBtnClick)); + } + + public void OnAttrShowBtnClick(IXUISprite isp) + { + bool flag = XSingleton.singleton.XPlayerData == null; + if (!flag) + { + uint num = 0u; + this._doc.heroIDIndex.TryGetValue(XSingleton.singleton.XPlayerData.RoleID, out num); + bool flag2 = num > 0u; + if (flag2) + { + DlgBase.singleton.ShowByType(SceneType.SCENE_HEROBATTLE, num); + } + } + } + + public override void OnUnload() + { + this._doc._HeroBattleHandler = null; + XSingleton.singleton.KillTimer(this.m_AncientTipsCloseToken); + bool flag = this._Fx != null; + if (flag) + { + XSingleton.singleton.DestroyFx(this._Fx, true); + this._Fx = null; + } + bool flag2 = this._OccupantFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._OccupantFx, true); + this._OccupantFx = null; + } + bool flag3 = this._EndFx != null; + if (flag3) + { + XSingleton.singleton.DestroyFx(this._EndFx, true); + this._EndFx = null; + } + bool flag4 = this._barFx != null; + if (flag4) + { + XSingleton.singleton.DestroyFx(this._barFx, true); + this._barFx = null; + } + for (int i = 0; i < this._skillFx.Length; i++) + { + bool flag5 = this._skillFx[i] != null; + if (flag5) + { + XSingleton.singleton.DestroyFx(this._skillFx[i], true); + this._skillFx[i] = null; + } + } + bool bSpectator = XSingleton.singleton.bSpectator; + if (bSpectator) + { + XSpectateSceneDocument.DelMiniMapFx(this._MiniMapFxToken); + } + else + { + XBattleDocument.DelMiniMapFx(this._MiniMapFxToken); + } + bool flag6 = this.m_MapSignalHandler != null; + if (flag6) + { + DlgHandlerBase.EnsureUnload(ref this.m_MapSignalHandler); + } + base.OnUnload(); + } + + protected override void OnShow() + { + base.OnShow(); + } + + public void SetTeamData(HeroBattleTeamMsg data) + { + int num = (this._doc.MyTeam == data.teamdata[0].teamid) ? 0 : 1; + this.m_Team[0].Score = data.teamdata[num].point; + this.m_Team[1].Score = data.teamdata[1 - num].point; + bool flag = !this._HaveEnd; + if (flag) + { + bool flag2 = data.teamdata[0].point == 100u || data.teamdata[1].point == 100u; + if (flag2) + { + this._HaveEnd = true; + bool flag3 = data.teamdata[0].point == 100u; + if (flag3) + { + this.SetResultFx(data.teamdata[0].teamid == this._doc.MyTeam); + } + else + { + this.SetResultFx(data.teamdata[1].teamid == this._doc.MyTeam); + } + } + } + } + + public void SetResultFx(bool isWinMySelf) + { + HeroBattleMapCenter.RowData bySceneID = this._doc.HeroBattleMapReader.GetBySceneID(XSingleton.singleton.SceneID); + bool flag = bySceneID == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("Can't find hero battle map data by sceneID = ", XSingleton.singleton.SceneID.ToString(), null, null, null, null); + } + else + { + Vector3 position; + position= new Vector3(bySceneID.Center[0], bySceneID.Center[1], bySceneID.Center[2]); + bool flag2 = this._EndFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._EndFx, true); + } + if (isWinMySelf) + { + this._EndFx = XSingleton.singleton.CreateFx(bySceneID.OccWinFx[0], null, true); + } + else + { + this._EndFx = XSingleton.singleton.CreateFx(bySceneID.OccWinFx[1], null, true); + } + this._EndFx.Play(position, Quaternion.identity, Vector3.one, 1f); + } + } + + public void SetProgressData(HeroBattleSyncData data) + { + bool flag = this._IsInFight != data.isInFight; + if (flag) + { + this.m_ProgressTips.SetText(XStringDefineProxy.GetString(data.isInFight ? "HeroBattleInFight" : "HeroBattleLoot")); + this._IsInFight = data.isInFight; + } + bool flag2 = this._CurrentOccupant != data.occupant; + int num; + if (flag2) + { + num = ((this._doc.MyTeam == data.occupant) ? 0 : 1); + this.m_Team[num].SetOccupantState(true); + this.m_Team[1 - num].SetOccupantState(false); + this._CurrentOccupant = data.occupant; + this.SetFx(this._CurrentOccupant); + } + num = ((this._doc.MyTeam == data.lootTeam) ? 0 : 1); + bool flag3 = this._ProgressTeam != data.lootTeam; + if (flag3) + { + bool flag4 = data.lootTeam > 0u; + if (flag4) + { + this.m_Progress.SetForegroundColor((num == 0) ? this.blueColor : this.redColor); + this.m_Team[(this._ProgressTeam == this._doc.MyTeam) ? 0 : 1].SetOccupyValue(0f); + } + else + { + this.m_Team[(this._ProgressTeam == this._doc.MyTeam) ? 0 : 1].SetOccupyValue(0f); + this.m_ProgressTs.localPosition = XGameUI.Far_Far_Away; + this.m_ProgressTipsTs.localPosition = XGameUI.Far_Far_Away; + } + this._ProgressTeam = data.lootTeam; + } + bool flag5 = this._ProgressTeam > 0u; + if (flag5) + { + this.m_Team[num].SetOccupyValue(data.lootProgress / 100f); + this.m_Progress.value = data.lootProgress / 100f; + this._LootProgress = data.lootProgress; + } + this.m_ProgressTs.localPosition = ((this._InCircleMyself && this._ProgressTeam != 0u && this._LootProgress > 0.5f) ? Vector3.zero : XGameUI.Far_Far_Away); + this.m_ProgressTipsTs.localPosition = ((this._IsInFight || (this._InCircleMyself && this._ProgressTeam != 0u)) ? Vector3.zero : XGameUI.Far_Far_Away); + } + + public void SetInCircleData(HeroBattleInCircle data) + { + bool flag = false; + bool bSpectator = XSingleton.singleton.bSpectator; + if (bSpectator) + { + flag = true; + } + else + { + for (int i = 0; i < data.roleInCircle.Count; i++) + { + bool flag2 = data.roleInCircle[i] == XSingleton.singleton.XPlayerData.RoleID; + if (flag2) + { + flag = true; + } + } + } + bool flag3 = this._InCircleMyself != flag; + if (flag3) + { + this._InCircleMyself = flag; + this.m_ProgressTs.localPosition = ((this._InCircleMyself && this._ProgressTeam != 0u && this._LootProgress > 0.5f) ? Vector3.zero : XGameUI.Far_Far_Away); + } + this.m_ProgressTipsTs.localPosition = ((this._IsInFight || (this._InCircleMyself && this._ProgressTeam != 0u)) ? Vector3.zero : XGameUI.Far_Far_Away); + } + + public void StartAddTime(int time) + { + this._InAddTime = (time != 0); + this._AddTimePerTurn = (float)time / 1000f; + this.m_AddTimeTs.localPosition = (this._InAddTime ? Vector3.zero : XGameUI.Far_Far_Away); + this._SignTime = Time.realtimeSinceStartup; + } + + public void RefreshScoreBoard(uint kill, uint dead, uint assit) + { + this.m_KillText.SetText(kill.ToString()); + this.m_DeadText.SetText(dead.ToString()); + this.m_AssitText.SetText(assit.ToString()); + } + + public void SetFx(uint occupant) + { + HeroBattleMapCenter.RowData bySceneID = this._doc.HeroBattleMapReader.GetBySceneID(XSingleton.singleton.SceneID); + bool flag = bySceneID == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("Can't find hero battle map data by sceneID = ", XSingleton.singleton.SceneID.ToString(), null, null, null, null); + } + else + { + Vector3 vector; + vector= new Vector3(bySceneID.Center[0], bySceneID.Center[1], bySceneID.Center[2]); + float num = bySceneID.Param[0] * bySceneID.ClientFxScalse; + float num2 = ((bySceneID.CenterType == 1u) ? bySceneID.Param[0] : bySceneID.Param[1]) * bySceneID.ClientFxScalse; + Vector3 scale; + scale= new Vector3(num, 1f, num2); + bool flag2 = this._Fx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._Fx, true); + this._Fx = null; + } + bool bSpectator = XSingleton.singleton.bSpectator; + if (bSpectator) + { + XSpectateSceneDocument.DelMiniMapFx(this._MiniMapFxToken); + } + else + { + XBattleDocument.DelMiniMapFx(this._MiniMapFxToken); + } + bool flag3 = occupant == 0u; + if (flag3) + { + this._Fx = XSingleton.singleton.CreateFx(bySceneID.OccupantFx[0], null, true); + bool bSpectator2 = XSingleton.singleton.bSpectator; + if (bSpectator2) + { + this._MiniMapFxToken = XSpectateSceneDocument.AddMiniMapFx(vector, bySceneID.MiniMapFx[0]); + } + else + { + this._MiniMapFxToken = XBattleDocument.AddMiniMapFx(vector, bySceneID.MiniMapFx[0]); + } + } + else + { + bool flag4 = occupant == this._doc.MyTeam; + if (flag4) + { + this._Fx = XSingleton.singleton.CreateFx(bySceneID.OccupantFx[1], null, true); + bool bSpectator3 = XSingleton.singleton.bSpectator; + if (bSpectator3) + { + this._MiniMapFxToken = XSpectateSceneDocument.AddMiniMapFx(vector, bySceneID.MiniMapFx[1]); + } + else + { + this._MiniMapFxToken = XBattleDocument.AddMiniMapFx(vector, bySceneID.MiniMapFx[1]); + } + } + else + { + this._Fx = XSingleton.singleton.CreateFx(bySceneID.OccupantFx[2], null, true); + bool bSpectator4 = XSingleton.singleton.bSpectator; + if (bSpectator4) + { + this._MiniMapFxToken = XSpectateSceneDocument.AddMiniMapFx(vector, bySceneID.MiniMapFx[2]); + } + else + { + this._MiniMapFxToken = XBattleDocument.AddMiniMapFx(vector, bySceneID.MiniMapFx[2]); + } + } + } + this._Fx.Play(vector, Quaternion.identity, scale, 1f); + bool flag5 = occupant > 0u; + if (flag5) + { + bool flag6 = this._OccupantFx != null; + if (flag6) + { + XSingleton.singleton.DestroyFx(this._OccupantFx, true); + } + bool flag7 = occupant == this._doc.MyTeam; + if (flag7) + { + this._OccupantFx = XSingleton.singleton.CreateFx(bySceneID.OccSuccessFx[0], null, true); + } + else + { + this._OccupantFx = XSingleton.singleton.CreateFx(bySceneID.OccSuccessFx[1], null, true); + } + this._OccupantFx.Play(vector, Quaternion.identity, scale, 1f); + } + } + } + + private bool OnChangeHeroBtnClick(IXUIButton btn) + { + bool flag = this._skillDoc.m_HeroBattleSkillHandler != null; + if (flag) + { + this._skillDoc.m_HeroBattleSkillHandler.SetVisible(true); + this._skillDoc.m_HeroBattleSkillHandler.RefreshTab(); + } + return true; + } + + public void SetDeathGoState(bool state) + { + this.m_Death.gameObject.transform.localPosition = (state ? Vector3.zero : XGameUI.Far_Far_Away); + } + + public void SetReviveLeftTime() + { + this._OnDeath = true; + this._ReviveSignTime = Time.realtimeSinceStartup; + } + + public override void OnUpdate() + { + bool inAddTime = this._InAddTime; + if (inAddTime) + { + float num = Time.realtimeSinceStartup - this._SignTime; + this.m_AddTimeProgress.value = 1f - num / this._AddTimePerTurn; + bool flag = num > this._AddTimePerTurn; + if (flag) + { + this._InAddTime = false; + this.m_AddTimeTs.localPosition = XGameUI.Far_Far_Away; + } + } + bool onDeath = this._OnDeath; + if (onDeath) + { + float num = Time.realtimeSinceStartup - this._ReviveSignTime; + int num2 = (int)(this._ReviveTime - num); + this.m_ReviveLeftTime.SetText(num2.ToString()); + bool flag2 = this._ReviveTime - num < 0f; + if (flag2) + { + this._OnDeath = false; + } + } + } + + private void PlayShowSkillFx() + { + bool flag = this._barFx != null; + if (flag) + { + XSingleton.singleton.DestroyFx(this._barFx, true); + } + this._barFx = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_jindutiao", this.m_AncientParent, false); + for (int i = 0; i < 3; i++) + { + bool flag2 = this._skillFx[i] != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._skillFx[i], true); + } + switch (i) + { + case 0: + this._skillFx[i] = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_tubiao_hong", this.m_AncientSkill[i].transform, false); + break; + case 1: + this._skillFx[i] = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_tubiao_lan", this.m_AncientSkill[i].transform, false); + break; + case 2: + this._skillFx[i] = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_tubiao_lu", this.m_AncientSkill[i].transform, false); + break; + } + } + } + + protected void DestroyShowSkillFx(object o) + { + GameObject o2 = o as GameObject; + XSingleton.singleton.UnSafeDestroy(o2, true, false); + } + + private void OnAncientSkillClick(IXUISprite iSp) + { + this._doc.QueryUseAncientSkill((int)iSp.ID); + } + + public void SetAncientPercent(float percent) + { + bool flag = percent > 99.99f; + if (flag) + { + percent = 100f; + } + bool flag2 = percent == 100f; + bool flag3 = flag2 != this._isAncientFull; + if (flag3) + { + for (int i = 0; i < 3; i++) + { + this.m_AncientSkill[i].SetVisible(flag2); + } + this.m_AncientSlider.SetVisible(!flag2); + bool flag4 = flag2; + if (flag4) + { + this.PlayShowSkillFx(); + } + this._isAncientFull = flag2; + bool flag5 = flag2; + if (flag5) + { + this.OnAncientCloseBtnClick(null); + } + } + this.m_AncientSlider.value = percent / 100f; + this.m_AncientPercent.SetText(string.Format("{0}%", (int)(percent + 0.49f))); + } + + public void OnAncientTipsBtnClick(IXUISprite iSp) + { + this.m_AncientTips.gameObject.transform.parent.gameObject.SetActive(true); + this.m_AncientTips.SetText(XSingleton.singleton.ReplaceReturn(XStringDefineProxy.GetString("HeroBattleAncientTips"))); + this.m_AncientTipsCloseToken = XSingleton.singleton.SetTimer(5f, new XTimerMgr.ElapsedEventHandler(this.AutoClose), null); + } + + public void AutoClose(object o = null) + { + this.OnAncientCloseBtnClick(null); + } + + public void OnAncientCloseBtnClick(IXUISprite iSp) + { + this.m_AncientTips.gameObject.transform.parent.gameObject.SetActive(false); + XSingleton.singleton.KillTimer(this.m_AncientTipsCloseToken); + } + } +} -- cgit v1.1-26-g67d0