예제 #1
0
        public void AddTransition(IState from, IState to, Func <bool> condition)
        {
            if (_stateTransitions.ContainsKey(from) == false)
            {
                _stateTransitions[from] = new List <StateTransition>();
            }

            StateTransition stateTransition = new StateTransition(from, to, condition);

            _stateTransitions[from].Add(stateTransition);
        }
예제 #2
0
        public void Tick()
        {
            StateTransition transition = CheckForTransition();

            if (transition != null)
            {
                SetState(transition.To);
            }

            CurrentState.Tick();
        }
예제 #3
0
        public void AddAnyTransition(IState to, Func <bool> condition)
        {
            StateTransition stateTransition = new StateTransition(null, to, condition);

            _anyStateTransitions.Add(stateTransition);
        }