示例#1
0
        public State To(string name, Condition switchCondition,
                        EnterState enter             = null, UpdateState update = null,
                        FixedUpdateState fixedUpdate = null, ExitState exit     = null
                        )
        {
            State stateToAdd = stateMachine.GetState(name);

            if (stateToAdd == null)
            {
                stateToAdd = stateMachine.AddState(name, enter, update, fixedUpdate, exit);
            }

            StateOutput output = new StateOutput();

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

            outputStates.Add(output);

            return(output.toState);
        }
示例#2
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;
            }
        }
示例#3
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);
        }