Ejemplo n.º 1
0
        private void InitializeStates()
        {
            _fsm.AddState <LoaderState>();
            _fsm.AddState <GameState>();
            _fsm.AddState <MainMenuState>();

            _fsm.SetInitialState("Loader");
        }
Ejemplo n.º 2
0
 private void SetupMainMenu(IStateMachine menu)
 {
     menu.AddState(new MenuItem("New Game"));
     menu.AddState(new MenuItem("Load Game"));
     menu.AddState(new MenuItem("Options"));
     menu.AddState(new MenuItem("Quit"));
     menu.GetState((int)MainMenuOptions.NewGame).Activate();
 }
        public static BehaviouralState AddWithBehaviours <TState, TTrigger>(this IStateMachine <TState, TTrigger> fsm, TState stateId, params IStateBehaviour[] behaviours)
        {
            var state = new BehaviouralState(behaviours);

            fsm.AddState(stateId, state);
            return(state);
        }
Ejemplo n.º 4
0
        public PlayerMind(IEntity ent)
        {
            IdleState = "Idle_Right";
            body      = ent;
            input.AddKeyListener(OnNewKeyInput);
            //Add states to player for things liek climbing in order to counter the limitations of gravity
            StateMachine = new StateMachine <IEntity>(body);

            SpriteSheet = new SpriteSheetAnimation(body.Texture);
            Animations  = new AnimationMachine <IEntity>(body);

            StateMachine.AddState(new EmptyState <IEntity>(), "BaseState");
            StateMachine.AddState(new DamagedPlayerState <IEntity>(((Player)body), StateMachine, Animations), "Damaged");

            Animations.AddState(new AnimationState(body, SpriteSheet, 0, 0, 0, 1), "Idle_Left");
            Animations.AddState(new AnimationState(body, SpriteSheet, 0, 1, 0, 1), "Idle_Right");
            Animations.AddState(new AnimationState(body, SpriteSheet, 12, 0), "Walking_Left");
            Animations.AddState(new AnimationState(body, SpriteSheet, 12, 1), "Walking_Right");
            Animations.AddState(new AnimationState(body, SpriteSheet, 12, 2), "Climbing");
        }
Ejemplo n.º 5
0
 public void PopulateStateLineage(IStateMachine <StateIds, StateEvents> stateMachine, Action <StateIds> addFn = null, Action <StateIds, StateIds> enterFn = null, Action <StateIds, StateIds> exitFn = null)
 {
     // State1 -----+-----State2 ----+----State3
     //             |                |
     //             |                +----State4 --+-- State5 ----- State6
     //             |                |             |
     //             |                |             +-- State7
     //             |                |
     //             |                +----State8
     //             |
     //             +----State9
     //
     stateMachine.AddState(new SampleState(StateIds.State1, addFn, enterFn, exitFn));
     stateMachine.AddState(new SampleState(StateIds.State2, addFn, enterFn, exitFn), StateIds.State1);
     stateMachine.AddState(new SampleState(StateIds.State3, addFn, enterFn, exitFn), StateIds.State2);
     stateMachine.AddState(new SampleState(StateIds.State4, addFn, enterFn, exitFn), StateIds.State2);
     stateMachine.AddState(new SampleState(StateIds.State5, addFn, enterFn, exitFn), StateIds.State4);
     stateMachine.AddState(new SampleState(StateIds.State6, addFn, enterFn, exitFn), StateIds.State5);
     stateMachine.AddState(new SampleState(StateIds.State7, addFn, enterFn, exitFn), StateIds.State4);
     stateMachine.AddState(new SampleState(StateIds.State8, addFn, enterFn, exitFn), StateIds.State2);
     stateMachine.AddState(new SampleState(StateIds.State9, addFn, enterFn, exitFn), StateIds.State1);
 }
Ejemplo n.º 6
0
        public EnemyMind(IEntity Ent)
        {
            body = Ent;

            //Initialise the spriteSheet animation
            SpriteSheet = new SpriteSheetAnimation(body.Texture);

            //Create a new instance of State Machine
            StateMachine     = new StateMachine <IEntity>(body);
            AnimationMachine = new AnimationMachine <IEntity>(body);


            //Add Animation States
            AnimationMachine.AddState(new AnimationState(body, SpriteSheet, 12, 1), "left");
            AnimationMachine.AddState(new AnimationState(body, SpriteSheet, 12, 0), "right");

            //Add the states to the State Machine
            StateMachine.AddState(new Patrol <IEntity>(100, body.Position, AnimationMachine), "Patrol");
        }
Ejemplo n.º 7
0
 public void AddState(IState state)
 {
     _stateMachine.AddState(state);
 }
Ejemplo n.º 8
0
 public void AddState(IState state)
 {
     _stateMachine.AddState(state);
     state?.SetStateMachine(this);
 }
Ejemplo n.º 9
0
 public bool AddState(BaseState state)
 {
     return(mImpl.AddState(this, state));
 }
Ejemplo n.º 10
0
 public void AddState(IState state)
 {
     _mainMenuStateMachine.AddState(state);
 }
 public static void AddWithEvents <TState, TTrigger>(this IStateMachine <TState, TTrigger> fsm, TState stateId,
                                                     Action onEnter, Action onExit)
 {
     fsm.AddState(stateId, States.WithEvents(onEnter, null, onExit));
 }
 public static void AddEmpty <TState, TTrigger>(this IStateMachine <TState, TTrigger> fsm, TState stateId)
 {
     fsm.AddState(stateId, States.Empty());
 }
 public static void AddTimerState <TState, TTrigger>(this IStateMachine <TState, TTrigger> fsm, TState stateId,
                                                     TimeSpan time, Action onTimerElapsed)
 {
     fsm.AddState(stateId, States.Timer(time, onTimerElapsed));
 }