Example #1
0
        public void Update()
        {
            if (CurrentState != null)
            {
                Transition triggeredTransition = null;
                foreach (Transition transition in CurrentState.GetTransitions())
                {
                    if (transition.IsTriggered())
                    {
                        triggeredTransition = transition;
                    }
                }


                if (triggeredTransition != null)
                {
                    State targetState = triggeredTransition.GetTargetState();
                    CurrentState.ExitAction();
                    targetState.EntryAction();
                    CurrentState = targetState;
                }
                else
                {
                    CurrentState.Action();
                }
            }
        }