using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 一个command序列,用来触发连击 /// public class ConditionCommandSeq : ConditionBase { List m_CommandSeq = new List(); float m_DeltaTime = 0; List m_LastCmdID = new List(); List id = new List(); public ConditionCommandSeq(List commandSeq, float maxDeltaTime) { m_CommandSeq.AddRange(commandSeq); m_DeltaTime = maxDeltaTime; } public override bool Evaluate() { List 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; } }