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/XTriggerCondition.cs | |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XTriggerCondition.cs')
| -rw-r--r-- | Client/Assets/Scripts/XMainClient/XTriggerCondition.cs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XTriggerCondition.cs b/Client/Assets/Scripts/XMainClient/XTriggerCondition.cs new file mode 100644 index 00000000..bdbb6d91 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XTriggerCondition.cs @@ -0,0 +1,64 @@ +using System;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XTriggerCondition
+ {
+ private float m_LastTriggerTime;
+
+ private float m_TriggerCD;
+
+ private uint m_TriggerCount;
+
+ private bool m_bCDWhenRandFail;
+
+ public XTriggerCondition(BuffTable.RowData info)
+ {
+ this.m_LastTriggerTime = 0f;
+ this.m_TriggerCD = Math.Abs(info.BuffTriggerCD);
+ this.m_TriggerCount = (uint)info.BuffTriggerCount;
+ this.m_bCDWhenRandFail = (info.BuffTriggerCD < 0f);
+ bool flag = this.m_TriggerCount == 0u;
+ if (flag)
+ {
+ this.m_TriggerCount = uint.MaxValue;
+ }
+ }
+
+ public bool CanTrigger()
+ {
+ return this._IsTriggerBuffCD() && this._HasTriggerCount();
+ }
+
+ public void OnTrigger()
+ {
+ this.m_LastTriggerTime = Time.time;
+ bool flag = this.m_TriggerCount != uint.MaxValue && this.m_TriggerCount > 0u;
+ if (flag)
+ {
+ this.m_TriggerCount -= 1u;
+ }
+ }
+
+ public void OnRandFail()
+ {
+ bool bCDWhenRandFail = this.m_bCDWhenRandFail;
+ if (bCDWhenRandFail)
+ {
+ this.m_LastTriggerTime = Time.time;
+ }
+ }
+
+ private bool _IsTriggerBuffCD()
+ {
+ return Time.time - this.m_LastTriggerTime > this.m_TriggerCD;
+ }
+
+ private bool _HasTriggerCount()
+ {
+ return this.m_TriggerCount == uint.MaxValue || this.m_TriggerCount > 0u;
+ }
+ }
+}
|
