Exemplo n.º 1
0
        private void KeyPress(string key)
        {
            switch (key)
            {
            case "KEY_ESCAPE":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", ""));
                break;

            case "KEY_A":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                        GameEventType.PlayerEvent, this, player, "move left", "", ""));
                break;

            case "KEY_D":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                        GameEventType.PlayerEvent, this, player, "move right", "", ""));
                break;

            case "KEY_SPACE":
                player.CreateShot();
                break;
            }
        }
Exemplo n.º 2
0
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            switch (keyValue)
            {
            // create a playerEvent of the with keyValue = messege and KeyAction = Parameter1
            // in case of the to cases belove.


            case "KEY_UP":
            case "KEY_LEFT":
            case "KEY_RIGHT":
                SpaceTaxiBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, keyValue, keyAction, ""));
                break;



            case "KEY_ESCAPE":
                if (keyAction == "KEY_RELEASE")
                {
                    SpaceTaxiBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_PAUSED", ""));
                }

                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the key events. For key up, key down and enter.
        /// </summary>
        /// <param name="keyValue">The given key pressed</param>
        /// <param name="keyAction">Registers if a certain button is pressed or released</param>
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            if (keyAction == "KEY_PRESS")
            {
            }

            switch (keyValue)
            {
            case "KEY_UP":
                SpaceBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_UPWARDS", "", ""));
                break;

            case "KEY_LEFT":
                SpaceBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_TO_LEFT", "", ""));
                break;

            case "KEY_RIGHT":
                SpaceBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_TO_RIGHT", "", ""));
                break;

            case "KEY_ESCAPE":
                SpaceBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent, this, "GAME_PAUSED", "", ""));
                break;
            }

            if (keyAction == "KEY_RELEASE")
            {
                switch (keyValue)
                {
                case "KEY_LEFT":
                    SpaceBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.PlayerEvent, this, "STOP_ACCELERATE_LEFT", "", ""));
                    break;

                case "KEY_RIGHT":
                    SpaceBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.PlayerEvent, this, "STOP_ACCELERATE_RIGHT", "", ""));
                    break;

                case "KEY_UP":
                    SpaceBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.PlayerEvent, this, "STOP_ACCELERATE_UP", "", ""));
                    break;

                default:
                    break;
                }
            }
        }
        public void TestCreationOfEventSpecificProcessorsToTest()
        {
            var res = GameEventFactory <object> .CreateGameEventForSpecificProcessor(GameEventType.ControlEvent, this, this, "test data",
                                                                                     "param1", "param2");

            Assert.That(res.To == this);
        }
Exemplo n.º 5
0
        public void KeyPress(string key)
        {
            switch (key)
            {
            case "KEY_RIGHT":
                GalagaBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "MOVE_RIGHT", "", ""));
                break;

            case "KEY_LEFT":
                GalagaBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "MOVE_LEFT", "", ""));
                break;

            case "KEY_SPACE":
                GalagaBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "SHOOT", "", ""));
                break;

            case "KEY_ESCAPE":
                GalagaBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent, this, "CHANGE_STATE", "GAME_PAUSED", ""));
                break;
            }
        }
        public void TestCreationOfEventForAllProcessorsInstanceTest()
        {
            var res = GameEventFactory <object> .CreateGameEventForAllProcessors(GameEventType.ControlEvent, this, "test data",
                                                                                 "param1", "param2");

            Assert.IsInstanceOf(typeof(GameEvent <object>), res);
        }
        public void TestCreationOfEventForAllProcessorsFromTest()
        {
            var res = GameEventFactory <object> .CreateGameEventForAllProcessors(GameEventType.ControlEvent, this, "test data",
                                                                                 "param1", "param2");

            Assert.That(res.From == this);
        }
Exemplo n.º 8
0
        public void KeyRelease(string key)
        {
            switch (key)
            {
            case "KEY_UP":
                _eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "STOP_ACCELERATE_UP", "", ""));
                break;

            case "KEY_LEFT":
                _eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "STOP_ACCELERATE_LEFT", "", ""));
                break;

            case "KEY_RIGHT":
                _eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "STOP_ACCELERATE_RIGHT", "", ""));
                break;

            case "KEY_P":
                _eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent, this, "GAME_PAUSED", "", ""));
                break;
            }
        }
Exemplo n.º 9
0
        public void KeyPress(string key)
        {
            switch (key)
            {
            case "KEY_ESCAPE":
                win.CloseWindow();
                break;

            case "KEY_F12":
                Console.WriteLine("Saving screenshot");
                win.SaveScreenShot();
                break;

            case "KEY_UP":
                SpaceBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_UPWARDS", "", ""));
                break;

            case "KEY_LEFT":
                SpaceBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_TO_LEFT", "", ""));
                break;

            case "KEY_RIGHT":
                SpaceBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "BOOSTER_TO_RIGHT", "", ""));
                break;
            }
        }
Exemplo n.º 10
0
    private void KeyPress(string key)
    {
        switch (key)
        {
        case "KEY_ESCAPE":
            eventBus.RegisterEvent(
                GameEventFactory <object> .CreateGameEventForAllProcessors(
                    GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", ""));

            break;

        case "KEY_LEFT":
            eventBus.RegisterEvent(
                GameEventFactory <object> .CreateGameEventForAllProcessors(
                    GameEventType.PlayerEvent, this.player, "MOVE_LEFT", "", ""));
            break;

        case "KEY_RIGHT":
            eventBus.RegisterEvent(
                GameEventFactory <object> .CreateGameEventForAllProcessors(
                    GameEventType.PlayerEvent, this.player, "MOVE_RIGHT", "", ""));
            break;

        case "KEY_SPACE":
            eventBus.RegisterEvent(
                GameEventFactory <object> .CreateGameEventForAllProcessors(
                    GameEventType.PlayerEvent, this.player, "SHOOT", "", ""));
            break;

        default:
            break;
        }
    }
Exemplo n.º 11
0
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            switch (keyAction)
            {
            case "KEY_PRESS":
                switch (keyValue)
                {
                case "KEY_ESCAPE":
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(GameEventType.WindowEvent, this,
                                                                                   "CLOSE_WINDOW", "", ""));
                    break;

                case "KEY_H":
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(GameEventType.MovementEvent, this,
                                                                                   "MOVE_RIGHT", "", ""));
                    break;

                case "KEY_L":
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(GameEventType.MovementEvent, this,
                                                                                   "MOVE_LEFT", "", ""));
                    break;

                case "KEY_SPACE":
                    playerShots.Add(new PlayerShot(
                                        new DynamicShape(
                                            new Vec2F(player.Entity.Shape.Position.X + 0.05f, player.Entity.Shape.Position.Y + 0.1f),
                                            new Vec2F(0.008f, 0.027f),
                                            new Vec2F(0.0f, 0.01f)
                                            ),
                                        bullet));
                    break;

                case "KEY_P":
                    GalagaBus.GetBus().RegisterEvent(GameEventFactory <object> .CreateGameEventForAllProcessors(GameEventType.GameStateEvent,
                                                                                                                this, "CHANGE_STATE", "GAME_PAUSED", ""));
                    break;
                }
                break;

            case "KEY_RELEASE":
                switch (keyValue)
                {
                case "KEY_H":
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(GameEventType.MovementEvent, this,
                                                                                   "MOVE_STOP", "", ""));
                    break;

                case "KEY_L":
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(GameEventType.MovementEvent, this,
                                                                                   "MOVE_STOP", "", ""));
                    break;
                }
                break;
            }
        }
Exemplo n.º 12
0
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            switch (keyValue)
            {
            case "KEY_Q":
                SpaceTaxiBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", ""));
                break;

            case "KEY_P":
                if (keyAction == "KEY_RELEASE")
                {
                    SpaceTaxiBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.GameStateEvent, this, "GAME_RUNNING", "", ""));
                }

                break;

            case "KEY_N":
                SpaceTaxiBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent, this, "NEW_GAME", "CHANGE_STATE", ""));
                break;
            }
        }
Exemplo n.º 13
0
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            switch (keyAction)
            {
            case "KEY_PRESS":
                switch (keyValue)
                {
                case "KEY_ESCAPE":
                    eventBus.RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", ""));
                    break;

                case "KEY_P":
                    eventBus.RegisterEvent(GameEventFactory <object> .CreateGameEventForAllProcessors(
                                               GameEventType.GameStateEvent,
                                               this,
                                               "CHANGE_STATE",
                                               "GAME_RUNNING", ""));
                    break;
                }
                break;

            case "KEY_RELEASE":
                break;
            }
        }
Exemplo n.º 14
0
    public void KeyPress(string key)
    {
        switch (key)
        {
        case "KEY_ESCAPE":
            eventBus.RegisterEvent(
                GameEventFactory <object> .CreateGameEventForAllProcessors(
                    GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", ""));
            break;

        case "KEY_A":
            KEY_A = true;
            player.direction(new Vec2F(-0.01f, 0.0f));
            break;

        case "KEY_D":
            KEY_D = true;
            player.direction(new Vec2F(0.01f, 0.0f));
            break;

        case "KEY_SPACE":
            player.shot();
            break;
        }
    }
Exemplo n.º 15
0
    public void KeyRelease(string key)
    {
        switch (key)
        {
        case "KEY_ESCAPE":
            eventBus.RegisterEvent(
                GameEventFactory <object> .CreateGameEventForAllProcessors(
                    GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", ""));
            break;

        case "KEY_A":
            if (KEY_D)
            {
                KeyPress("KEY_D");
                KEY_A = false;
                break;
            }
            player.direction(new Vec2F(0.0f, 0.0f));
            KEY_A = false;
            break;

        case "KEY_D":
            if (KEY_A)
            {
                KeyPress("KEY_A");
                KEY_D = false;
                break;
            }
            player.direction(new Vec2F(0.0f, 0.0f));
            KEY_D = false;
            break;
        }
    }
Exemplo n.º 16
0
        private void Collision()
        {
            foreach (Entity entity in paintBoard.Images)
            {
                switch (CollisionDetection.Aabb(
                            (DynamicShape)player.Entity.Shape, entity.Shape).Collision)
                {
                case true:
                    AddExplosion(player.Entity.Shape.Position,
                                 player.Entity.Shape.Extent);
                    player.Entity.DeleteEntity();
                    break;
                }

                var newPlayerList = new List <Player>();
                foreach (var player in playerList)
                {
                    if (!player.Entity.IsDeleted())
                    {
                        newPlayerList.Add(player);
                    }
                    if (player.Entity.IsDeleted())
                    {
                        SpaceBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors
                                (GameEventType.GameStateEvent, this,
                                "CHANGE_STATE", "GAME_OVER", ""));
                    }
                }

                playerList = newPlayerList;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Method that updates all logic features, which could be gravity.
        /// </summary>
        public void UpdateGameLogic()
        {
            if (player.GetsShape().Position.Y >= 0.98f && GameRunning.levelCounter == levelInfo.Count - 1)
            {
                AddCash();
                SpaceBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent, this, "GAME_VICTORY", "", ""));
            }

            CheckGameOver(GameRunning.levelCounter);
            RenderState();
            player.Physics();
            AddCash();

            foreach (Passenger passenger in levelPassengers[GameRunning.levelCounter])
            {
                passenger.PassengerMove();
            }

            levelCollisionCheckers[GameRunning.levelCounter].CheckCollsion();
            timerHandlers[GameRunning.levelCounter].SpawnPassengerTimer();
            timerHandlers[GameRunning.levelCounter].SetPickUpTimer();
            CheckGameOver(GameRunning.levelCounter);

            if (player.GetsShape().Position.Y >= 1.0f)
            {
                GameRunning.levelCounter++;
                player.SetPosition(playerXcoordinates[GameRunning.levelCounter], playerYcoordinates[GameRunning.levelCounter]);
            }
        }
Exemplo n.º 18
0
 public void HandleKeyEvent(string keyValue, string keyAction)
 {
     if (keyAction == "KEY_RELEASE")
     {
         if (keyValue == "KEY_ENTER")
         {
             if (activeMenuButton == 0)
             {
                 GameEventFactory <object> .CreateGameEventForAllProcessors(
                     GameEventType.GameStateEvent,
                     this,
                     "CHANGE_STATE",
                     "GAME_RUNNING", "");
             }
             else
             {
                 GameEventFactory <object> .CreateGameEventForAllProcessors(
                     GameEventType.GameStateEvent,
                     this,
                     "CHANGE_STATE",
                     "GAME_PAUSED", "");
             }
         }
     }
 }
Exemplo n.º 19
0
        public void KeyPress(string key)
        {
            switch (key)
            {
            case "KEY_SPACE":
                playerShots.AddDynamicEntity(
                    new DynamicShape(player.Entity.Shape.Position + new Vec2F(0.046f, 0.09f),
                                     new Vec2F(0.008f, 0.027f), new Vec2F(0.0f, 0.01f)),
                    shotStride);
                break;

            case "KEY_RIGHT":
                player.MoveRight();
                break;

            case "KEY_LEFT":
                player.MoveLeft();
                break;

            case "KEY_ESCAPE":
                GalagaBus.GetBus().RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.GameStateEvent,
                        this,
                        "CHANGE_STATE",
                        "GAME_PAUSED", ""));
                break;
            }
        }
Exemplo n.º 20
0
        public void KeyPress(string key)
        {
            switch (key)
            {
            case "KEY_ESCAPE":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.WindowEvent, this, "CLOSE_WINDOW", "", ""));
                break;

            case "KEY_SPACE":
                playerShots.AddDynamicEntity(
                    new DynamicShape(player.Entity.Shape.Position + new Vec2F(0.046f, 0.09f),
                                     new Vec2F(0.008f, 0.027f), new Vec2F(0.0f, 0.01f)),
                    shotStride);
                break;

            case "KEY_RIGHT":
                player.MoveRight();
                break;

            case "KEY_LEFT":
                player.MoveLeft();
                break;
            }
        }
Exemplo n.º 21
0
        public void KeyRelease(string key)
        {
            switch (key)
            {
            case "KEY_LEFT":
                if (key.Equals("KEY_LEFT") || key.Equals("KEY_RIGHT"))
                {
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.PlayerEvent, this, "NO_MOVE", "", ""));
                }

                break;

            case "KEY_RIGHT":
                if (key.Equals("KEY_RIGHT") || key.Equals("KEY_LEFT"))
                {
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.PlayerEvent, this, "NO_MOVE", "", ""));
                }

                break;
            }
        }
Exemplo n.º 22
0
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            switch (keyAction)
            {
            case "KEY_PRESS":
                switch (keyValue)
                {
                case "KEY_ESCAPE":
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.GameStateEvent,
                            this,
                            "CHANGE_STATE",
                            "GAME_PAUSED", ""));
                    break;

                case "KEY_A":
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                            GameEventType.PlayerEvent, this, player, "move left", "", ""));

                    break;

                case "KEY_D":
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                            GameEventType.PlayerEvent, this, player, "move right", "", ""));

                    break;
                }
                break;
            }
        }
Exemplo n.º 23
0
        private void EnemyCollision(EntityContainer <Enemy> squadron)
        {
            squadron.Iterate(delegate(Enemy enemy) {
                if (CollisionDetection.Aabb(player.Shape.AsDynamicShape(), enemy.Shape).Collision)
                {
                    enemy.DeleteEntity();
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.PlayerEvent,
                            this,
                            "LOSE_LIFE",
                            "", ""));
                }

                if (enemy.Shape.Position.Y + enemy.Shape.Extent.Y <= 0.0f)
                {
                    enemy.DeleteEntity();
                    GalagaBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.PlayerEvent,
                            this,
                            "LOSE_LIFE",
                            "", ""));
                }
            });
        }
Exemplo n.º 24
0
        public void KeyRelease(string key)
        {
            switch (key)
            {
            case "KEY_UP":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "KEY_UP", "KEY_RELEASE", ""));
                break;

            case "KEY_DOWN":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "KEY_DOWN", "KEY_RELEASE", ""));
                break;

            case "KEY_LEFT":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "KEY_LEFT", "KEY_RELEASE", ""));
                break;

            case "KEY_RIGHT":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForAllProcessors(
                        GameEventType.PlayerEvent, this, "KEY_RIGHT", "KEY_RELEASE", ""));
                break;

            default:
                break;
            }
        }
Exemplo n.º 25
0
    public void FillPool(IEventPool <GameEvent> pool, int amountOfEvents, string type)
    {
        //get discrete function for how to pick game events
        double[] eventProbability = Utils.DistributionFunction(GAME_DIFFICULTY_COUNT);

        int[] numberOfEvenetsFromEachLevel = new int[GAME_DIFFICULTY_COUNT];

        for (int i = 0; i < GAME_DIFFICULTY_COUNT; i++)
        {
            numberOfEvenetsFromEachLevel[i] = (int)Math.Floor(eventProbability[i] * amountOfEvents);
        }

        for (int i = 0; i < eventProbability.Length; i++)
        {
            //factory give me from this pool of options an amount of events according to it's
            //specified distrub
            int amount = numberOfEvenetsFromEachLevel[i];

            List <GameEvent> generatedEvents = GameEventFactory.GetIntance().GenerateMany(type, amount, i);

            EventPoolHolder <GameEvent> .AddToPool(pool, generatedEvents);
        }


        //choose from each type x the f(x) amount
        //for every object clone and send to pool

        //call it self in {level} time
    }
Exemplo n.º 26
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;
                }
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Handles the key events. For key up, key down and enter.
        /// </summary>
        /// <param name="keyValue">The given key pressed</param>
        /// <param name="keyAction">Registers if a certain button is pressed or released</param>
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            if (keyAction == "KEY_PRESS")
            {
                switch (keyValue)
                {
                case "KEY_UP":
                    if (activeMenuButton == 0)
                    {
                        activeMenuButton = maxMenuButtons - 1;
                    }
                    else
                    {
                        activeMenuButton -= 1;
                    }

                    break;

                case "KEY_DOWN":
                    if (activeMenuButton == maxMenuButtons - 1)
                    {
                        activeMenuButton = 0;
                    }
                    else
                    {
                        activeMenuButton += 1;
                    }

                    break;

                case "KEY_ENTER":
                    switch (activeMenuButton)
                    {
                    case 0:
                        GameRunning.ResetGameRunning();
                        GameLevels.Levelcount = 0;
                        SpaceBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent, this, "GAME_RUNNING", "", ""));
                        break;

                    case 1:
                        SpaceBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent, this, "MAIN_MENU", "", ""));

                        break;

                    default:
                        break;
                    }

                    break;

                default:
                    break;
                }
            }
        }
Exemplo n.º 28
0
 public static GameEventFactory GetIntance()
 {
     if (mInstance == null)
     {
         mInstance = new GameEventFactory();
     }
     return(mInstance);
 }
Exemplo n.º 29
0
        private void RegisterEvent(object sender, KeyboardKeyEventArgs e)
        {
            var keyAction = (e.Keyboard.IsKeyDown(e.Key)) ? "KEY_PRESS" : "KEY_RELEASE";
            var newEvent  = GameEventFactory <object> .CreateGameEventForAllProcessors(
                GameEventType.InputEvent, this, Input.KeyTransformer.GetKeyString(e.Key), keyAction, "");

            eventBus.RegisterEvent(newEvent);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Handles the key events. Such as the key enter, sets the player back to main menu.
        /// </summary>
        /// <param name="keyValue">The given key pressed</param>
        /// <param name="keyAction">Registers if a certain button is pressed or released</param>
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            if (keyAction == "KEY_PRESS")
            {
                switch (keyValue)
                {
                case "KEY_UP":
                    if (activeMenuButton == 0)
                    {
                        activeMenuButton = maxMenuButtons - 1;
                    }
                    else
                    {
                        activeMenuButton -= 1;
                    }

                    break;

                case "KEY_DOWN":
                    if (activeMenuButton == maxMenuButtons - 1)
                    {
                        activeMenuButton = 0;
                    }
                    else
                    {
                        activeMenuButton += 1;
                    }

                    break;

                case "KEY_ENTER":
                    switch (activeMenuButton)
                    {
                    case 0:
                        GameRunning.ResetGameRunning();
                        SpaceBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent, this, "GAME_LEVELS", "", ""));
                        break;

                    case 1:
                        GameRunning.ResetGameRunning();
                        SpaceBus.GetBus().RegisterEvent(
                            GameEventFactory <object> .CreateGameEventForAllProcessors(
                                GameEventType.GameStateEvent, this, "GAME_CONTROLS", "", ""));
                        break;

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

                    break;
                }
            }
        }