using UnityEngine; using UnityEngine.Events; using System.Collections; public abstract class MoveRoot { #region 变量 public bool IsPlaying { get { return AnimManager.MoveForList.Contains(this) || AnimManager.MoveBacList.Contains(this); } } public virtual bool InDestination { get { return InDestination_; } set { InDestination_ = value; } } public bool InDestination_; public bool InPause; public UnityAction OnForwardStart; public UnityAction OnForwardFinish; #endregion public abstract bool DoForward(); public abstract bool DoBackward(); public virtual void Pause() { if (!InPause) { InPause = true; AnimManager.MoveForList.Remove(this); } } public virtual void Resume() { if (InPause) { InPause = false; AnimManager.MoveForList.Add(this); } } public virtual void PushEvent(EventType type, UnityAction action) { if (type == EventType.ForwardStart) { OnForwardStart = action + OnForwardStart; } else if (type == EventType.ForwardFinish) { OnForwardFinish = action + OnForwardFinish; } } public virtual 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 virtual 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; } } }