using UnityEngine; using UnityEngine.Events; using System.Collections; public abstract class Move { #region 变量 public virtual bool InDestination { get { return InDestination_; } set { InDestination_ = value; } } public bool InDestination_; public UnityAction OnForwardStart; public UnityAction OnForwardFinish; #endregion public abstract bool Do(); public void Pause() { ManaAnim.MoveList.Remove(this); } public void Resume() { ManaAnim.MoveList.Add(this); } public void PushEvent(EventType type, UnityAction action) { if (type == EventType.ForwardStart) { OnForwardStart = action + OnForwardStart; } else if (type == EventType.ForwardFinish) { OnForwardFinish = action + OnForwardFinish; } } public void AddEventOnetime(EventType type, UnityAction action) { if (type == EventType.ForwardStart) { action += () => { OnForwardStart -= action; }; OnForwardStart += action; } else if (type == EventType.ForwardFinish) { action += () => { OnForwardFinish -= action; }; OnForwardFinish += action; } } public void PushEventOnetime(EventType type, UnityAction action) { if (type == EventType.ForwardStart) { action += () => { OnForwardStart -= action; }; OnForwardStart = action + OnForwardStart; } else if (type == EventType.ForwardFinish) { action += () => { OnForwardFinish -= action; }; OnForwardFinish = action + OnForwardFinish; } } }