| StateMachine manager, designed with simplicity in mind (as simple as a state machine can be anyway). To use it, you need an enum. For example : public enum CharacterConditions { Normal, ControlledMovement, Frozen, Paused, Dead } Declare it like so : public StateMachine<CharacterConditions> ConditionStateMachine; Initialize it like that : ConditionStateMachine = new StateMachine<CharacterConditions>(); Then from anywhere, all you need to do is update its state when needed, like that for example : ConditionStateMachine.ChangeState(CharacterConditions.Dead); The state machine will store for you its current and previous state, accessible at all times, and will also optionnally trigger events on enter/exit of these states. More...
|