IEnumerator StartState() { Debug.Log("Start state."); yield return(m_FramerateWait); m_CurrentRoutine = RunningState; }
public State(String tID, StateRoutine tRoutine, StateErrorHandler tErrorHandler, AutoResetEvent tEvent, State tParent) { m_Event = tEvent; m_Parent = tParent; m_ID = tID; m_ErrorHandler = tErrorHandler; if (null == m_Event) { m_Event = new AutoResetEvent(false); } if (null == m_Parent) { return; } if (null == tID) { return; } else if ("" == tID.Trim()) { return; } else if (null == tRoutine) { return; } m_Routine = tRoutine; m_Status = Status.FSM_IDLE; m_Available = true; }
IEnumerator StartState () { Debug.Log ("Start state."); yield return m_FramerateWait; m_CurrentRoutine = RunningState; }
IEnumerator Start() { m_CurrentRoutine = StartState; while (enabled && Application.isPlaying && m_CurrentRoutine != null) { yield return(StartCoroutine(m_CurrentRoutine())); } }
IEnumerator DefaultTransition (StateRoutine from, StateRoutine to) { Debug.Log (string.Format ("Transitioning from {0} to {1}", from.Method.Name, to == null ? "null" : to.Method.Name)); if (from == RunningState) { m_RunCount = 0; } yield return m_FramerateWait; }
IEnumerator Start () { m_CurrentRoutine = StartState; while (enabled && Application.isPlaying && m_CurrentRoutine != null) { yield return StartCoroutine (m_CurrentRoutine ()); } }
IEnumerator DefaultTransition(StateRoutine from, StateRoutine to) { Debug.Log(string.Format("Transitioning from {0} to {1}", from.Method.Name, to == null ? "null" : to.Method.Name)); if (from == RunningState) { m_RunCount = 0; } yield return(m_FramerateWait); }
IEnumerator RunningState() { while (++m_RunCount <= 3) { Debug.Log("Running state."); yield return(m_FramerateWait); } m_RunCount = 0; m_CurrentRoutine = EndState; }
IEnumerator RunningState () { while (++m_RunCount <= 3) { Debug.Log ("Running state."); yield return m_FramerateWait; } m_RunCount = 0; m_CurrentRoutine = EndState; }
IEnumerator Start () { m_CurrentState = InitialState; if (m_CurrentState == null) { throw new ArgumentException ("Initial state is null"); } while (m_CurrentState != null) { yield return StartCoroutine (Wrap (m_CurrentState ())); } }
IEnumerator Start() { m_CurrentState = InitialState; if (m_CurrentState == null) { throw new ArgumentException("Initial state is null"); } while (m_CurrentState != null) { yield return(StartCoroutine(Wrap(m_CurrentState()))); } }
IEnumerator Wrap (IEnumerator coroutine) { while (true) { if (!coroutine.MoveNext ()) { Debug.LogError ("Broke out of the current state. Will resume."); yield break; } TransitionTo transitionTo = coroutine.Current as TransitionTo; if (transitionTo != null) { yield return StartCoroutine (transitionTo.Transition (m_CurrentState, transitionTo.Target)); m_CurrentState = transitionTo.Target; yield break; } yield return coroutine.Current; } }
IEnumerator Wrap(IEnumerator coroutine) { while (true) { if (!coroutine.MoveNext()) { Debug.LogError("Broke out of the current state. Will resume."); yield break; } TransitionTo transitionTo = coroutine.Current as TransitionTo; if (transitionTo != null) { yield return(StartCoroutine(transitionTo.Transition(m_CurrentState, transitionTo.Target))); m_CurrentState = transitionTo.Target; yield break; } yield return(coroutine.Current); } }
public TransitionTo (StateRoutine newState, TransitionRoutine transition) { Target = newState; Transition = transition; }
public TransitionTo(StateRoutine newState, TransitionRoutine transition) { Target = newState; Transition = transition; }