예제 #1
0
        public gamePhase HandleInput(ButtonEvents bEvent, gamePhase same, Player player, GraphicsDevice gDev)
        {
            gamePhase result = same;

            if (bEvent.BackPress || bEvent.EscPress)
            {
                result = gamePhase.SPLASH;
            }

            if (bEvent.StartPress || bEvent.EnterPress)
            {
                result = gamePhase.PAUSE;
            }

            if ((bEvent.APress || bEvent.SpacePress) && player.bullets().Count < player.maxBullets)
            {
                player.Fire();
            }

            player.setPosition(player.X + (GamePad.GetState(PlayerIndex.One).ThumbSticks.Left.X *player.Speed), player.Y);
            //*****
            if (Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                player.setPosition((player.X - player.Speed), player.Y);
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                player.setPosition((player.X + player.Speed), player.Y);
            }
            //*****
            player.CheckBounds(0, gDev.Viewport.Width - 200);

            return(result);
        }
예제 #2
0
        public gamePhase HandleInput(ButtonEvents bEvent, gamePhase same, UFOManager ufo, Player player)
        {
            gamePhase result = same;

            if (bEvent.BackPress || bEvent.EscPress)
            {
                // Allows the game to exit
                result = gamePhase.QUIT;
            }
            else if (bEvent.DpadDownPress || bEvent.DownPress)
            {
                // Move difficulty selector down
                difficulty.option = (difficulty.option + 1) % 3;
            }
            else if (bEvent.DpadUpPress || bEvent.UpPress)
            {
                // Move difficulty selector up
                difficulty.option = (difficulty.option + 2) % 3;
            }
            else if (bEvent.StartPress || bEvent.EnterPress)
            {
                // Begin game
                switch (difficulty.option)
                {
                case 0:     //Easy
                    player.level       = 1;
                    player.score       = 0;
                    player.lives       = 10;
                    player.maxBullets  = 8;
                    player.bulletSpeed = 3;
                    player.setSpeedMultiplier(8);
                    break;

                case 1:     //Medium
                    player.level       = 1;
                    player.score       = 0;
                    player.lives       = 5;
                    player.maxBullets  = 2;
                    player.bulletSpeed = 1.5f;
                    player.setSpeedMultiplier(5);
                    break;

                case 2:     //Hard
                    player.level       = 1;
                    player.score       = 0;
                    player.lives       = 3;
                    player.maxBullets  = 1;
                    player.bulletSpeed = 1;
                    player.setSpeedMultiplier(3);
                    break;
                }
                ufo.Destroy();
                result     = gamePhase.LOADLEVEL;
                mFirstPass = true;         //reset splash screen initializer
            }

            return(result);
        }
예제 #3
0
        public gamePhase HandleInput(ButtonEvents bEvent, gamePhase same)
        {
            gamePhase result = same;

            if (bEvent.StartPress || bEvent.EnterPress)
            {
                result = gamePhase.SPLASH;
            }

            return(result);
        }
예제 #4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Initialize game window
            base.Initialize();

            // Everything else
            bEvents = new ButtonEvents(GamePad.GetState(PlayerIndex.One), Keyboard.GetState());
            phase   = gamePhase.DEVINTRO;

            Texture2D[] frames = new Texture2D[31] {
                Content.Load <Texture2D>("Intro/devint-01"),
                Content.Load <Texture2D>("Intro/devint-02"),
                Content.Load <Texture2D>("Intro/devint-03"),
                Content.Load <Texture2D>("Intro/devint-04a"),
                Content.Load <Texture2D>("Intro/devint-04b"),
                Content.Load <Texture2D>("Intro/devint-04a"),
                Content.Load <Texture2D>("Intro/devint-04a"),
                Content.Load <Texture2D>("Intro/devint-04a"),
                Content.Load <Texture2D>("Intro/devint-04b"),
                Content.Load <Texture2D>("Intro/devint-04a"),
                Content.Load <Texture2D>("Intro/devint-04b"),
                Content.Load <Texture2D>("Intro/devint-04a"),
                Content.Load <Texture2D>("Intro/devint-05"),
                Content.Load <Texture2D>("Intro/devint-06"),
                Content.Load <Texture2D>("Intro/devint-07"),
                Content.Load <Texture2D>("Intro/devint-08"),
                Content.Load <Texture2D>("Intro/devint-09"),
                Content.Load <Texture2D>("Intro/devint-10"),
                Content.Load <Texture2D>("Intro/devint-11"),
                Content.Load <Texture2D>("Intro/devint-12"),
                Content.Load <Texture2D>("Intro/devint-13"),
                Content.Load <Texture2D>("Intro/devint-14"),
                Content.Load <Texture2D>("Intro/devint-15"),
                Content.Load <Texture2D>("Intro/devint-16"),
                Content.Load <Texture2D>("Intro/devint-17"),
                Content.Load <Texture2D>("Intro/devint-18"),
                Content.Load <Texture2D>("Intro/devint-19"),
                Content.Load <Texture2D>("Intro/devint-19"),
                Content.Load <Texture2D>("Intro/devint-19"),
                Content.Load <Texture2D>("Intro/devint-19"),
                Content.Load <Texture2D>("Intro/devint-19")
            };

            scrIntro  = new DevIntro(frames, 31);
            scrSplash = new SplashScreen(Content.Load <SpriteFont>("Fonts/Fkey"),
                                         Content.Load <SpriteFont>("Fonts/Title"),
                                         Content.Load <SpriteFont>("Fonts/Instruction"));
            scrLoader = new LevelLoader(Content.Load <SpriteFont>("Fonts/Level"));
            scrPlay   = new PlayScreen(Content.Load <SpriteFont>("Fonts/PlayerHeader"),
                                       Content.Load <SpriteFont>("Fonts/PlayerData"),
                                       Content.Load <Texture2D>("Panel"));
            scrPause    = new PauseScreen(Content.Load <SpriteFont>("Fonts/Pause"));
            scrGameover = new GameOver(Content.Load <SpriteFont>("Fonts/GameOver"));

            stars = new Starfield(GraphicsDevice);

            player = new Player(Content.Load <Texture2D>("Ship"),
                                Content.Load <Texture2D>("Bullet"),
                                Content.Load <SoundEffect>("Sounds/ShipFiring"),
                                Content.Load <SoundEffect>("Sounds/ShipDeath"),
                                new Vector2((GraphicsDevice.Viewport.Width - 200) / 2 - 40, GraphicsDevice.Viewport.Height - 91),
                                new Vector2(0, 0),
                                4.0f);
            aliens = new AlienManager(Content.Load <Texture2D>("alien0"),
                                      Content.Load <Texture2D>("alien1"),
                                      Content.Load <Texture2D>("alien2"),
                                      Content.Load <Texture2D>("alien3"),
                                      Content.Load <Texture2D>("Bullet"),
                                      Content.Load <SoundEffect>("Sounds/AlienFiring"),
                                      Content.Load <SoundEffect>("Sounds/AlienDeath"));
            ufo = new UFOManager(Content.Load <Texture2D>("BigAlien"),
                                 Content.Load <Texture2D>("Present"),
                                 Content.Load <SoundEffect>("Sounds/UFOMoving"),
                                 Content.Load <SoundEffect>("Sounds/GiftboxDrop"),
                                 Content.Load <SoundEffect>("Sounds/GiftboxCollect"));
        }