diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/PercentWatcher.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/PercentWatcher.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/PercentWatcher.cs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/PercentWatcher.cs b/Client/Assets/Scripts/XMainClient/PercentWatcher.cs new file mode 100644 index 00000000..1655d6f6 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/PercentWatcher.cs @@ -0,0 +1,97 @@ +using System;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal struct PercentWatcher
+ {
+ public double TargetDeltaValue
+ {
+ get
+ {
+ return this.m_TargetDeltaBasic;
+ }
+ }
+
+ public XAttributeDefine BasicAttr
+ {
+ get
+ {
+ return this.m_BasicAttr;
+ }
+ }
+
+ private bool m_bValid;
+
+ private double m_TargetDeltaPercent;
+
+ private double m_TargetDeltaBasic;
+
+ private XAttributeDefine m_BasicAttr;
+
+ private XAttributes m_Atributes;
+
+ public static bool IsValidAttr(XAttributeDefine attr)
+ {
+ return attr == XAttributeDefine.XAttr_MaxMP_Percent || attr == XAttributeDefine.XAttr_MaxHP_Percent || attr == XAttributeDefine.XAttr_MaxSuperArmor_Percent;
+ }
+
+ public PercentWatcher(XAttributes attributes, XAttributeDefine attr, double targetDeltaPercent)
+ {
+ this.m_bValid = false;
+ this.m_TargetDeltaPercent = 0.0;
+ this.m_TargetDeltaBasic = 0.0;
+ this.m_BasicAttr = XAttributeDefine.XAttr_Invalid;
+ this.m_Atributes = null;
+ bool flag = !PercentWatcher.IsValidAttr(attr);
+ if (!flag)
+ {
+ this.m_BasicAttr = XAttributeCommon.GetAttrCurAttr(attr);
+ bool flag2 = this.m_BasicAttr == XAttributeDefine.XAttr_Invalid;
+ if (!flag2)
+ {
+ this.m_bValid = true;
+ this.m_Atributes = attributes;
+ double attr2 = this.m_Atributes.GetAttr(attr);
+ bool flag3 = attr2 + targetDeltaPercent <= -1.0;
+ if (flag3)
+ {
+ targetDeltaPercent = -1.0 - attr2 + 0.001;
+ }
+ this.m_TargetDeltaPercent = targetDeltaPercent;
+ double num = Math.Max(0.001, 1.0 + attr2);
+ double attr3 = this.m_Atributes.GetAttr(this.m_BasicAttr);
+ this.m_TargetDeltaBasic = attr3 / num * this.m_TargetDeltaPercent;
+ this.m_TargetDeltaBasic = XCombat.CheckChangeHPLimit(this.m_BasicAttr, this.m_TargetDeltaBasic, attributes.Entity, true, true);
+ bool flag4 = this.m_TargetDeltaPercent < 0.0;
+ if (flag4)
+ {
+ this._ChangeBasic();
+ }
+ }
+ }
+ }
+
+ private void _ChangeBasic()
+ {
+ XAttrChangeEventArgs @event = XEventPool<XAttrChangeEventArgs>.GetEvent();
+ @event.AttrKey = this.m_BasicAttr;
+ @event.DeltaValue = this.m_TargetDeltaBasic;
+ @event.Firer = this.m_Atributes.Entity;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ }
+
+ public void Check()
+ {
+ bool flag = !this.m_bValid;
+ if (!flag)
+ {
+ bool flag2 = this.m_TargetDeltaPercent > 0.0;
+ if (flag2)
+ {
+ this._ChangeBasic();
+ }
+ }
+ }
+ }
+}
|