From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XSecurityMobInfo.cs | 138 +++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XSecurityMobInfo.cs (limited to 'Client/Assets/Scripts/XMainClient/XSecurityMobInfo.cs') diff --git a/Client/Assets/Scripts/XMainClient/XSecurityMobInfo.cs b/Client/Assets/Scripts/XMainClient/XSecurityMobInfo.cs new file mode 100644 index 00000000..d2e49c6d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XSecurityMobInfo.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; + +namespace XMainClient +{ + internal class XSecurityMobInfo + { + public List MobInfoList + { + get + { + return this._MobInfosList; + } + } + + private List _MobInfosList = new List(); + + private Dictionary _MobInfos = new Dictionary(); + + public class MobInfo : XDataBase + { + public uint _TemplateID; + + public int _CastCount; + + public float _AttackTotal; + + public void Reset() + { + this._TemplateID = 0u; + this._CastCount = 0; + this._AttackTotal = 0f; + } + + public void Merge(XSecurityMobInfo.MobInfo other) + { + bool flag = other == null; + if (!flag) + { + this._AttackTotal += other._AttackTotal; + this._CastCount += other._CastCount; + } + } + + public override void Init() + { + base.Init(); + this.Reset(); + } + + public override void Recycle() + { + base.Recycle(); + XDataPool.Recycle(this); + } + } + + private XSecurityMobInfo.MobInfo _TryGetMobInfo(uint templateID) + { + XSecurityMobInfo.MobInfo data; + bool flag = !this._MobInfos.TryGetValue(templateID, out data); + if (flag) + { + data = XDataPool.GetData(); + data._TemplateID = templateID; + this._MobInfosList.Add(data); + this._MobInfos.Add(templateID, data); + } + return data; + } + + public void Reset() + { + for (int i = 0; i < this._MobInfosList.Count; i++) + { + this._MobInfosList[i].Recycle(); + } + this._MobInfosList.Clear(); + this._MobInfos.Clear(); + } + + public void Merge(XSecurityMobInfo other) + { + for (int i = 0; i < other._MobInfosList.Count; i++) + { + XSecurityMobInfo.MobInfo mobInfo = this._TryGetMobInfo(other._MobInfosList[i]._TemplateID); + mobInfo.Merge(other._MobInfosList[i]); + } + } + + public void OnCast(uint templateID, int count) + { + XSecurityMobInfo.MobInfo mobInfo = this._TryGetMobInfo(templateID); + mobInfo._CastCount += count; + } + + public void OnCastDamage(uint templateID, double value) + { + XSecurityMobInfo.MobInfo mobInfo = this._TryGetMobInfo(templateID); + mobInfo._AttackTotal += (float)value; + } + + public void Append(XEntity entity) + { + XSecurityStatistics xsecurityStatistics = XSecurityStatistics.TryGetStatistics(entity); + bool flag = xsecurityStatistics == null || !xsecurityStatistics.bValid; + if (!flag) + { + XSecurityMobInfo.MobInfo mobInfo = this._TryGetMobInfo(entity.TypeID); + mobInfo._CastCount++; + mobInfo._AttackTotal += xsecurityStatistics.DamageStatistics._AttackTotal; + } + } + + public XSecurityMobInfo.MobInfo GetMobInfoByID(uint templateID) + { + XSecurityMobInfo.MobInfo result; + this._MobInfos.TryGetValue(templateID, out result); + return result; + } + + public static XSecurityMobInfo TryGetStatistics(XEntity entity) + { + XSecurityStatistics xsecurityStatistics = XSecurityStatistics.TryGetStatistics(entity); + bool flag = xsecurityStatistics == null; + XSecurityMobInfo result; + if (flag) + { + result = null; + } + else + { + result = xsecurityStatistics.MobStatistics; + } + return result; + } + } +} -- cgit v1.1-26-g67d0