summaryrefslogtreecommitdiff
path: root/Assets/Scripts/AbilitySystem/Conditions
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-18 00:48:13 +0800
committerchai <chaifix@163.com>2020-10-18 00:48:13 +0800
commitc83b9abffe8988f9322a027b7fefd68e7f3fa6ba (patch)
treed29bd71fd485e9e4d5aa1ae68a7af2501b641b9d /Assets/Scripts/AbilitySystem/Conditions
parentfd4f77ee3621bef2ce91ee6584ca9a2dc5064f96 (diff)
+dash 动作
Diffstat (limited to 'Assets/Scripts/AbilitySystem/Conditions')
-rw-r--r--Assets/Scripts/AbilitySystem/Conditions/ConditionCommandSeq.cs40
1 files changed, 37 insertions, 3 deletions
diff --git a/Assets/Scripts/AbilitySystem/Conditions/ConditionCommandSeq.cs b/Assets/Scripts/AbilitySystem/Conditions/ConditionCommandSeq.cs
index 8c955400..71a7dbf3 100644
--- a/Assets/Scripts/AbilitySystem/Conditions/ConditionCommandSeq.cs
+++ b/Assets/Scripts/AbilitySystem/Conditions/ConditionCommandSeq.cs
@@ -7,14 +7,48 @@ using UnityEngine;
/// </summary>
public class ConditionCommandSeq : ConditionBase
{
+ List<GamepadButton> m_CommandSeq = new List<GamepadButton>();
+ float m_DeltaTime = 0;
+ List<int> m_LastCmdID = new List<int>();
- public ConditionCommandSeq(List<GamepadButton> commandSeq, float maxDeltaTime)
- {
+ List<int> id = new List<int>();
+ public ConditionCommandSeq(List<GamepadButton> commandSeq, float maxDeltaTime)
+ {
+ m_CommandSeq.AddRange(commandSeq);
+ m_DeltaTime = maxDeltaTime;
}
public override bool Evaluate()
{
- throw new System.NotImplementedException();
+ List<Command> commandRecord = InputManager.Instance.CommandRecord;
+ if (commandRecord == null || commandRecord.Count < m_CommandSeq.Count)
+ return false;
+ id.Clear();
+ for (int i = 1; i < m_CommandSeq.Count; ++i)
+ {
+ GamepadButton button = m_CommandSeq[i];
+ GamepadButton preButton = m_CommandSeq[i-1];
+ int j = commandRecord.Count - m_CommandSeq.Count + i;
+ Command cmd = commandRecord[j];
+ Command preCmd = commandRecord[j-1];
+ if (preCmd.code != preButton || cmd.code != button)
+ return false;
+ if (cmd.time - preCmd.time > m_DeltaTime)
+ return false;
+ id.Add(preCmd.id);
+ if (j == commandRecord.Count - 1)
+ id.Add(cmd.id);
+ }
+
+ //for (int i = 0; i < id.Count; ++i)
+ //{
+ // if (m_LastCmdID.Contains(id[i]))
+ // return false;
+ //}
+ //m_LastCmdID.Clear();
+ //m_LastCmdID.AddRange(id);
+
+ return true;
}
}