//static UserInterface ui = new UserInterface();



        public static void Update()
        {
            //press esc to exit when boss is dead
            if (Keyboard.GetState().IsKeyDown(Keys.Escape) && GameBase.currentLevel == GameBase.level.end)
            {
                GameBase.setState(GameBase.gameStates.mainMenu);
            }

            //press D to move right
            if (Keyboard.GetState().IsKeyDown(Keys.D) && !(Keyboard.GetState().IsKeyDown(Keys.A)) && Player.Instance.PlayerX < GameBase.Viewport.Width - (64 / Player.scaleFactor))
            {
                Player.Instance.PlayerX   += movementSpeed;
                Player.Instance.SpriteXMod = 2;//change player's shown sprite to appropriate movement direction
            }
            //press A to move left
            else if (Keyboard.GetState().IsKeyDown(Keys.A) && !(Keyboard.GetState().IsKeyDown(Keys.D)) && Player.Instance.PlayerX > 0)
            {
                Player.Instance.PlayerX   -= movementSpeed;
                Player.Instance.SpriteXMod = 3; //change player's shown sprite to appropriate movement direction
            }
            else
            {
                Player.Instance.SpriteXMod = 1;//change player's shown sprite to appropriate movement direction
            }

            //press W to move up
            if (Keyboard.GetState().IsKeyDown(Keys.W) && !(Keyboard.GetState().IsKeyDown(Keys.S)) && Player.Instance.PlayerY > 0)
            {
                Player.Instance.PlayerY -= movementSpeed;
            }
            //press S to move down
            else if (Keyboard.GetState().IsKeyDown(Keys.S) && !(Keyboard.GetState().IsKeyDown(Keys.W)) && Player.Instance.PlayerY < GameBase.Viewport.Height - 164)
            {
                Player.Instance.PlayerY += movementSpeed;
            }
            //press space to fire (with cooldown)
            if (Keyboard.GetState().IsKeyDown(Keys.Space) && cooldownRemaining <= 0 && UserInterface.hasEnergy(4) == true)
            {
                cooldownRemaining = cooldownFrames;
                UserInterface.reduceEnergy(5);

                EntityManager.Add(new Bullet(Player.Instance.offsetPlayerPos, Player.Instance.vel, "defaultShot"));
                EntityManager.Add(new Bullet(Player.Instance.offsetPlayerPos2, Player.Instance.vel, "defaultShot"));
                GameBase.baseShotLaunch.Play(0.5f, -0.2f, 0);
            }
            //press 1 to fire eShot
            else if (Keyboard.GetState().IsKeyDown(Keys.D1) && cooldownRemaining <= 0 && UserInterface.hasEnergy(29) == true && UserInterface.hasEShot() > 0)
            {
                cooldownRemaining = cooldownFrames;
                UserInterface.reduceEnergy(30);
                UserInterface.updateEShot(1);
                EntityManager.Add(new Bullet(Player.Instance.offsetPlayerPosCentre, Player.Instance.vel, "eShot"));
                GameBase.eShotLaunch.Play(0.5f, -0.2f, 0);
            }

            if (cooldownRemaining > 0)
            {
                cooldownRemaining--;
            }
        }
Exemple #2
0
        public void Update()
        {
            mouseState = Mouse.GetState(); //mouse position
            mousePoint = new Vector2(mouseState.X, mouseState.Y);



            //does the player click play
            if (playButton.Contains(mousePoint) && (mouseState.LeftButton == ButtonState.Pressed) && state == menuState.mainMenu)
            {
                //begin playing
                UserInterface.setIntitialValues();
                GameBase.setState(GameBase.gameStates.Playing);
                EntityManager.Initialize();
                GameBase.setLevel(GameBase.level.one);
            }

            //does the player click help
            if (helpButton.Contains(mousePoint) && (mouseState.LeftButton == ButtonState.Pressed) && state == menuState.mainMenu)
            {
                state = menuState.help; //send to help screenn
            }

            //does the player click back
            if (backButton.Contains(mousePoint) && (mouseState.LeftButton == ButtonState.Pressed) && state == menuState.help)
            {
                state = menuState.mainMenu; //send  back to main menu
            }
        }
Exemple #3
0
 public void dead()
 {
     GameBase.setState(GameBase.gameStates.mainMenu);
 }