Beispiel #1
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;
            }
        }
        public void TestCreationOfEventSpecificProcessorsToTest()
        {
            var res = GameEventFactory <object> .CreateGameEventForSpecificProcessor(GameEventType.ControlEvent, this, this, "test data",
                                                                                     "param1", "param2");

            Assert.That(res.To == this);
        }
Beispiel #3
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;
            }
        }
Beispiel #4
0
        public 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> .CreateGameEventForSpecificProcessor(
                        GameEventType.PlayerEvent, this, player, "MOVE_LEFT", "", ""));
                break;

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

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

            default:
                break;
            }
        }
Beispiel #5
0
 private void KeyRelease(string key)
 {
     if (key.Equals("KEY_A") || key.Equals("KEY_D"))
     {
         GalagaBus.GetBus().RegisterEvent(
             GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                 GameEventType.PlayerEvent, this, GameRunning.GetInstance(this).player, "stop move", "", ""));
     }
 }
Beispiel #6
0
 private void KeyRelease(string key)
 {
     if (key.Equals("KEY_A") || key.Equals("KEY_D"))
     {
         eventBus.RegisterEvent(
             GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                 GameEventType.PlayerEvent, this, player, "stop move", "", ""));
     }
 }
Beispiel #7
0
        public void KeyRelease(string key)
        {
            switch (key)
            {
            case "KEY_LEFT":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                        GameEventType.PlayerEvent, this, player, "MOVE_STOP", "", ""));
                break;

            case "KEY_RIGHT":
                eventBus.RegisterEvent(
                    GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                        GameEventType.PlayerEvent, this, player, "MOVE_STOP", "", ""));
                break;
            }
        }
Beispiel #8
0
        public void HandleKeyEvent(string keyValue, string keyAction)
        {
            switch (keyAction)
            {
            case "KEY_PRESS":
                switch (keyValue)
                {
                case "KEY_ESCAPE":
                    SpaceTaxiBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForAllProcessors(
                            GameEventType.GameStateEvent,
                            this,
                            "CHANGE_STATE",
                            "GAME_PAUSED", ""));
                    break;

                case "KEY_UP":
                    startup      = true;
                    isOnPlatform = false;
                    SpaceTaxiBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                            GameEventType.PlayerEvent, this, player, "BOOSTER_UPWARDS", "", ""));
                    break;

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

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

                default:
                    break;
                }

                break;

            case "KEY_RELEASE":
                switch (keyValue)
                {
                case "KEY_LEFT":
                    SpaceTaxiBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                            GameEventType.PlayerEvent, this, player, "STOP_ACCELERATE_LEFT", "", ""));
                    break;

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

                case "KEY_UP":
                    SpaceTaxiBus.GetBus().RegisterEvent(
                        GameEventFactory <object> .CreateGameEventForSpecificProcessor(
                            GameEventType.PlayerEvent, this, player, "STOP_ACCELERATE_UP", "", ""));
                    break;
                }
                break;
            }
        }