コード例 #1
0
        protected void InitializeState(BState <TEnum> state, TEnum[] allEnumValues)
        {
            foreach (TEnum e in allEnumValues)
            {
                if (state.Id.Equals(e))
                {
                    continue;
                }

                this.SetupActionForMethod(state.TransitionToNextStateIdKey(e));
            }

            this.SetupActionForMethod(state.EnterKey());
            this.SetupActionForMethod(state.TickKey());
            this.SetupActionForMethod(state.FixedTickKey());
            this.SetupActionForMethod(state.ExitKey());
        }
コード例 #2
0
        protected virtual void Update()
        {
            _remainingTimeInState -= Time.deltaTime;
            if (_remainingTimeInState <= 0)
            {
                if (_currentState == null)
                {
                    Debug.LogError("BasicFiniteStateMachine::Tick - current state null (did you forget to set the start state?)");
                }
                else
                {
                    if (_currentState.CanTransitionWithTime())
                    {
                        this.AdvanceCurrentState();
                    }
                }
            }

            this.CallActionForMethod(_currentState.TickKey());
        }