using UnityEngine; using System.Collections; using UnityEngine.Events; 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 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; } } }