123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using UnityEngine;
- using UnityEngine.Events;
- using System.Collections;
- public abstract class MoveRoot
- {
- #region 变量
- 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;
- ManaAnim.MoveForList.Remove(this);
- }
- }
- public virtual void Resume()
- {
- if (InPause)
- {
- InPause = false;
- ManaAnim.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;
- }
- }
- }
|