コード例 #1
0
        public void Update()
        {
            State    maybeNewState;
            AnyState maybeAnyState = null;

            for (int i = 0; i < anyStates.Count; ++i)
            {
                StateOutput output = anyStates[i];
                if (output.toState != currentState && output.condition())
                {
                    maybeAnyState = output.toState as AnyState;
                    maybeAnyState.SetPreviousState(currentState);
                }
            }

            maybeNewState = currentState.Update(maybeAnyState);

            if (maybeNewState != null)
            {
                currentState = maybeNewState;
            }
        }
コード例 #2
0
        public AnyState AnyState(string name, Condition switchCondition,
                                 EnterState enter             = null, UpdateState update = null,
                                 FixedUpdateState fixedUpdate = null, ExitState exit     = null
                                 )
        {
            AnyState stateToAdd = GetState(name) as AnyState;

            if (stateToAdd == null)
            {
                stateToAdd = new AnyState(this, name, enter, update, fixedUpdate, exit);
            }

            StateOutput output = new StateOutput();

            output.condition = switchCondition;
            output.toState   = stateToAdd;

            anyStates.Add(output);
            states.Add(name, stateToAdd);

            return(stateToAdd);
        }