コード例 #1
0
        public bool ChangeState(string key)
        {
            StateMachineAction retval;

            if (_states.TryGetValue(key, out retval))
            {
                _currentState.OnExit();
                _currentState = retval;
                _currentState.OnEnter();
                return(true);
            }
            return(false);
        }
コード例 #2
0
        public bool Start(string key)
        {
            StateMachineAction retval;

            if (_states.TryGetValue(key, out retval))
            {
                _currentState = retval;
                isRunning     = true;
                return(true);
            }
            Debug.LogError("WARNING - " + key + " does not exsist! Cannot start the StateMachine!");
            return(false);
        }
コード例 #3
0
        public bool Add(StateMachineAction state, string key)
        {
            StateMachineAction retval;

            if (_states.TryGetValue(key, out retval))
            {
                return(false);
            }
            else
            {
                _states.Add(key, state);
                return(true);
            }
        }