Exemple #1
0
        public StateMachine()
        {
            TaxiBus.GetBus().Subscribe(GameEventType.GameStateEvent, this);
            TaxiBus.GetBus().Subscribe(GameEventType.InputEvent, this);

            ActiveState = MainMenu.GetInstance();
        }
Exemple #2
0
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            if (keyAction == "KEY_PRESS")
            {
                switch (keyValue)
                {
                case "KEY_UP":
                    if (activeMenuButton > 0)
                    {
                        menuButtons[activeMenuButton].SetColor(new Vec3F(1.0f, 1.0f, 1.0f));
                        activeMenuButton--;
                        menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f));
                    }
                    break;

                case "KEY_DOWN":
                    if (activeMenuButton < maxMenuButtons - 1)
                    {
                        menuButtons[activeMenuButton].SetColor(new Vec3F(1.0f, 1.0f, 1.0f));
                        activeMenuButton++;
                        menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f));
                    }
                    break;

                case "KEY_ENTER":
                    switch (activeMenuButton)
                    {
                    case 1:
                        TaxiBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent,
                                this,
                                "CHANGE_STATE",
                                "SELECT_LEVEL", ""));
                        break;

                    case 2:
                        TaxiBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.WindowEvent,
                                this,
                                "CLOSE_WINDOW", "", ""));
                        break;

                    default:
                        //GameRunning.NewInstance();
                        GameRunning.NewInstance();
                        TaxiBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent,
                                this,
                                "CHANGE_STATE",
                                "GAME_RUNNING", ""));
                        break;
                    }
                    break;
                }
            }
        }
Exemple #3
0
 private void GameOver()
 {
     GameRunning.NewInstance();
     TaxiBus.GetBus().RegisterEvent(
         GameEventFactory <object> .CreateGameEventForAllProcessors(
             GameEventType.GameStateEvent,
             this,
             "CHANGE_STATE",
             "MAIN_MENU", ""));
 }
Exemple #4
0
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            if (keyAction == "KEY_PRESS")
            {
                switch (keyValue)
                {
                case "KEY_UP":
                    if (activeMenuButton > 0)
                    {
                        menuButtons[activeMenuButton].SetColor(new Vec3F(1.0f, 1.0f, 1.0f));
                        activeMenuButton--;
                        menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f));
                    }
                    break;

                case "KEY_DOWN":
                    if (activeMenuButton < maxMenuButtons - 1)
                    {
                        menuButtons[activeMenuButton].SetColor(new Vec3F(1.0f, 1.0f, 1.0f));
                        activeMenuButton++;
                        menuButtons[activeMenuButton].SetColor(new Vec3F(0.0f, 1.0f, 0.0f));
                    }
                    break;

                case "KEY_ENTER":
                    switch (activeMenuButton)
                    {
                    case 2:
                        TaxiBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent,
                                this,
                                "CHANGE_STATE",
                                "MAIN_MENU", ""));
                        break;

                    default:
                        LevelParser.GetInstance().InitLevel(
                            maxMenuButtons - activeMenuButton - 2);
                        TaxiBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent,
                                this,
                                "CHANGE_STATE",
                                "GAME_RUNNING", ""));
                        break;
                    }
                    break;
                }
            }
        }
Exemple #5
0
        public void InitializeGameState()
        {
            // level class
            LevelParser.NewGame();
            level = LevelParser.GetInstance();

            // event bus
            eventBus = TaxiBus.GetBus();

            // game assets
            backGroundImage = new Entity(
                new StationaryShape(new Vec2F(0.0f, 0.0f), new Vec2F(1.0f, 1.0f)),
                new Image(Path.Combine("Assets", "Images", "SpaceBackground.png"))
                );
        }
Exemple #6
0
        public Player()
        {
            TaxiBus.GetBus().Subscribe(GameEventType.PlayerEvent, this);

            shape = new DynamicShape(new Vec2F(), new Vec2F(0.0625f, 0.045f));

            taxiBoosterOffImageLeft = new Image(
                Path.Combine("Assets", "Images", "Taxi_Thrust_None.png"));
            taxiBoosterOffImageRight = new Image(
                Path.Combine("Assets", "Images", "Taxi_Thrust_None_Right.png"));
            taxiBoosterOnImageLeft           = CreateStride("Taxi_Thrust_Back.png");
            taxiBoosterOnImageRight          = CreateStride("Taxi_Thrust_Back_Right.png");
            taxiBoosterOnImageBottomLeft     = CreateStride("Taxi_Thrust_Bottom.png");
            taxiBoosterOnImageBottomRight    = CreateStride("Taxi_Thrust_Bottom_Right.png");
            taxiBoosterOnImageBottomAndLeft  = CreateStride("Taxi_Thrust_Bottom_Back.png");
            taxiBoosterOnImageBottomAndRight = CreateStride("Taxi_Thrust_Bottom_Back_Right.png");

            Entity          = new Entity(shape, taxiBoosterOffImageLeft);
            taxiOrientation = Orientation.Right;

            InFlight = false;
        }