Пример #1
0
        public void Update(float deltaTime)
        {
            // Null check the current state of the FSM
            if (m_CurrentState == null)
            {
                return;
            }

            // Check the conditions for each transition of the current state
            foreach (Transition t in m_CurrentState.TransitionList)
            {
                // If the condition has evaluated to true
                // then transition to the next state
                if (t.Condition())
                {
                    m_CurrentState.Exit(owner);
                    m_CurrentState = t.NextState;
                    m_CurrentState.Enter(owner);
                    break;
                }
            }

            // Execute the current state
            m_CurrentState.Execute(owner, deltaTime);
        }