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/BattleDpsHandler.cs | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/BattleDpsHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/BattleDpsHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/BattleDpsHandler.cs b/Client/Assets/Scripts/XMainClient/UI/BattleDpsHandler.cs new file mode 100644 index 00000000..3d3c5d9c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/BattleDpsHandler.cs @@ -0,0 +1,88 @@ +using System; +using UILib; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class BattleDpsHandler : DlgHandlerBase + { + private IXUILabel m_uiInfo; + + private IXUISprite m_uiBg; + + private ulong m_Dps; + + private int m_Rank; + + private XCombatStatisticsDocument doc; + + private string m_strTemplate; + + protected override void Init() + { + base.Init(); + this.m_uiInfo = (base.PanelObject.GetComponent("XUILabel") as IXUILabel); + this.m_uiBg = (base.PanelObject.transform.Find("Bg").GetComponent("XUISprite") as IXUISprite); + this.doc = XDocuments.GetSpecificDocument(XCombatStatisticsDocument.uuID); + this.doc.DpsHandler = this; + this.m_Dps = 0UL; + this.m_Rank = 0; + this.m_strTemplate = XSingleton.singleton.ReplaceReturn(XStringDefineProxy.GetString("DPS_INFO")); + } + + public override void OnUnload() + { + base.OnUnload(); + this.doc.DpsHandler = null; + } + + protected override void OnShow() + { + base.OnShow(); + this._Refresh(); + this.RefreshData(); + } + + public override void OnUpdate() + { + base.OnUpdate(); + bool flag = !XSingleton.singleton.SyncMode; + if (flag) + { + this.RefreshData(); + } + } + + public override void RefreshData() + { + base.RefreshData(); + this.doc.ReqDps(); + } + + public void SetDps(double dps, double rank) + { + ulong num = (ulong)dps; + int num2 = (int)rank; + bool flag = num != this.m_Dps || num2 != this.m_Rank; + if (flag) + { + this.m_Dps = num; + this.m_Rank = num2; + this._Refresh(); + } + } + + public void SetInfo(string s) + { + this.m_uiInfo.SetText(s); + this.m_uiBg.UpdateAnchors(); + } + + private void _Refresh() + { + string text = string.Format(this.m_strTemplate, XSingleton.singleton.NumberFormat(this.m_Dps), this.m_Rank.ToString()); + this.m_uiInfo.SetText(text); + this.m_uiBg.UpdateAnchors(); + } + } +} -- cgit v1.1-26-g67d0