Example #1
0
        /// <summary>
        /// Use all LevelEnemy objects and create
        /// EnemyAirplane . Queue them in a list.
        /// </summary>
        public void QueueEnemies()
        {
            // Sort enemies by XAppear, so they appear correctly
            // in the queue.
            _data.Enemies.Sort((LevelEnemy x1, LevelEnemy x2) =>
                x1.XAppear < x2.XAppear ? -1 : 1);

            _enemies = new Queue<PoorSceneObject>();
            foreach (LevelEnemy le in _data.Enemies)
            {
                PoorSceneObject e = null;
                if (le.type == "Airplane")
                {
                    e = new EnemyAirplane(le.health, le.RequiredForVictory);
                    e.Position = new Vector2(le.XAppear, GameHelper.GroundLevel - 70 - le.Y);
                }
                else if (le.type == "AntiAir")
                {
                    e = new AntiAirVehicle(le.health, le.RequiredForVictory);
                    e.Position = new Vector2(le.XAppear, GameHelper.GroundLevel - 49);
                }
                else if (le.type == "Transport")
                {
                    e = new GroundTransport(le.health, le.RequiredForVictory);
                    e.Position = new Vector2(le.XAppear, GameHelper.GroundLevel - 39);
                }
                else if (le.type == "BossAntiAir")
                {
                    e = new BossAntiAir(le.health, le.RequiredForVictory);
                    e.Position = new Vector2(le.XAppear, GameHelper.GroundLevel - 170);
                }
                else if (le.type == "BurgerBoss")
                {
                    e = new GroundTransport(le.health, le.RequiredForVictory, true);
                    e.Position = new Vector2(le.XAppear, GameHelper.GroundLevel - 130);
                }

                if (e != null)
                    _enemies.Enqueue(e);
            }
        }
Example #2
0
        /// <summary>
        /// Allows the screen to handle user input. Unlike Update, this method
        /// is only called when the screen is active, and not when some other
        /// screen has taken the focus.
        /// </summary>
        public override void HandleInput(Input input)
        {
            base.HandleInput(input);

            player1.HandleInput(input);

            /*
             *  DEBUG INPUT
             */
            #region
            if (EngineManager.DebugKeysEnabled)
            {
                if (input.IsNewKeyPress(Keys.D1))
                {
                    SceneGraphManager.SetTimeOfDay24h = 0f;
                }
                if (input.IsNewKeyPress(Keys.D2))
                {
                    SceneGraphManager.SetTimeOfDay24h = 3f;
                }
                if (input.IsNewKeyPress(Keys.D3))
                {
                    SceneGraphManager.SetTimeOfDay24h = 6f;
                }
                if (input.IsNewKeyPress(Keys.D4))
                {
                    SceneGraphManager.SetTimeOfDay24h = 9f;
                }
                if (input.IsNewKeyPress(Keys.D5))
                {
                    SceneGraphManager.SetTimeOfDay24h = 12f;
                }
                if (input.IsNewKeyPress(Keys.D6))
                {
                    SceneGraphManager.SetTimeOfDay24h = 15f;
                }
                if (input.IsNewKeyPress(Keys.D7))
                {
                    SceneGraphManager.SetTimeOfDay24h = 18f;
                }
                if (input.IsNewKeyPress(Keys.D8
                    ))
                {
                    SceneGraphManager.SetTimeOfDay24h = 21f;
                }

                if (input.IsNewKeyPress(Keys.E))
                {
                    GroundTransport gcv = new GroundTransport(3000, false);
                    gcv.Position = new Vector2(
                            CameraManager.Camera.Pos.X +
                            GameHelper.ScreenWidth - 200f,
                            GameHelper.GroundLevel - 38);
                    gcv.LoadContent();

                    SceneGraphManager.AddObject(gcv);
                }

                if (input.IsNewKeyPress(Keys.R))
                {
                    AntiAirVehicle gbv = new AntiAirVehicle(3000, false);
                    gbv.Position = new Vector2(
                            CameraManager.Camera.Pos.X +
                            GameHelper.ScreenWidth - 200f,
                            GameHelper.GroundLevel - 47);

                    gbv.Velocity = new Vector2(0f, 0f);
                    gbv.LoadContent();

                    SceneGraphManager.AddObject(gbv);
                }

                if (input.IsNewKeyPress(Keys.B))
                {
                    BossAntiAir boss = new BossAntiAir(70000, false);
                    boss.Position = new Vector2(
                            CameraManager.Camera.Pos.X +
                            GameHelper.ScreenWidth - 200f,
                            GameHelper.GroundLevel - 170);

                    boss.Velocity = new Vector2(0f, 0f);
                    boss.LoadContent();

                    SceneGraphManager.AddObject(boss);
                }
                if (input.IsNewKeyPress(Keys.N))
                {
                    GroundTransport boss = new GroundTransport(40000, false, true);
                    boss.Position = new Vector2(
                            CameraManager.Camera.Pos.X +
                            GameHelper.ScreenWidth - 200f,
                            GameHelper.GroundLevel - 130);

                    boss.Velocity = new Vector2(4f, 0f);
                    boss.LoadContent();

                    SceneGraphManager.AddObject(boss);
                }

                if (input.IsNewKeyPress(Keys.W))
                {
                    AmmoBase ab = new AmmoBase();
                    ab.Position = new Vector2(
                            CameraManager.Camera.Pos.X +
                            GameHelper.ScreenWidth - 250f,
                            GameHelper.GroundLevel + 10);
                    ab.LoadContent();

                    SceneGraphManager.AddObject(ab);
                }

                if (input.IsNewKeyPress(Keys.P))
                {
                    LevelManager.CurrentLevel.Completed = true;
                }

                if (input.IsNewKeyPress(Keys.F5))
                {
                    SceneGraphManager.ToggleCollisionDetection();
                }

                if (input.IsNewKeyPress(Keys.PageUp))
                {
                    ScreenManager.lengthenJanitorCoffeeBreak();
                }

                if (input.IsNewKeyPress(Keys.PageDown))
                {
                    ScreenManager.shortenJanitorCoffeeBreak();
                }

                if (input.IsNewKeyPress(Keys.Add))
                {
                    SceneGraphManager.TImeOfDaySpeed += 0.00001f;
                }

                if (input.IsNewKeyPress(Keys.Subtract))
                {
                    SceneGraphManager.TImeOfDaySpeed -= 0.00001f;
                }
            }
            #endregion
            /*
             *  END DEBUG INPUT
             */

            if (input.IsNewKeyPress(Keys.Escape))
            {
                SoundFxManager.Pause();
                PauseMenuScreen pauseMenuScreen = new PauseMenuScreen(400, 300);
                pauseMenuScreen.ExitToMenuEvent += ExitGameEvent;
                pauseMenuScreen.RestartGameEvent += RestartGameEvent;
                ScreenManager.AddScreen(pauseMenuScreen);
            }
            if (input.IsNewKeyPress(Keys.V))
            {
                GameSettings.Default.ShowUI = !GameSettings.Default.ShowUI;
            }
        }