123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using UnityEngine;
- using System.Collections;
- using UnityEngine.Events;
- public abstract class Move
- {
- #region 变量
- protected virtual bool InDestination
- {
- get { return _InDestination; }
- set { _InDestination = value; }
- }
- protected 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;
- }
- }
- }
|