Ejemplo n.º 1
0
        public StateMachine(Character character, uint numAnimations)
        {
            Character = character;
            Character.BehaviourChanged += HandleBehaviourChange;

            States = new State[numAnimations];
            GlobalStates = new List<State>();
            ShouldLoad = true;
        }
Ejemplo n.º 2
0
 public bool DeathTransition(State sourceState, State destinationState)
 {
     return Health <= 0;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds a state to this state machine.  This function takes care of global states and ID checks.
        /// Should not really be used - instead use Character function 'CreateState' - it is much nicer and tidier.
        /// </summary>
        /// <param name="state"></param>
        public void CreateState(uint id, Animation animation)
        {
            // This is a check to make sure that we are adding the states in the order they are declared in the enum.
            // If this doesn't occur, the states will be mixed up and all hell will break loose.
            Debug.Assert(id == currentAddedStates);

            State state = new State(id, animation);

            States[currentAddedStates] = state;
            currentAddedStates++;

            // If our state is global, add it to our list
            if (state.IsGlobal)
            {
                GlobalStates.Add(state);
            }
        }