// handle key presses
        public override void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.Up))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }
            if (input.IsNewKeyPress(Keys.Down))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }
            if (input.IsNewKeyPress(Keys.Enter))
            {
                switch (selectedEntry)
                {
                    case (int)MainMenuEntry.NewGame:
                        screenManager.AddScreen(new NameInputScreen(this));
                        break;
                    case (int)MainMenuEntry.ContinueGame:
                        break;
                    case (int)MainMenuEntry.Exit:
                        screenManager.AddScreen(new EndGameScreen());
                        break;
                }
            }
        }
        public override void HandleInput(InputState input)
        {
            if (input.IsNewKeyPress(Keys.Left))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }
            if (input.IsNewKeyPress(Keys.Right))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }
            if (input.IsNewKeyPress(Keys.Enter) || input.IsNewKeyPress(Keys.Space))
            {
                switch (selectedEntry)
                {
                    case (int)EndGameEntry.Yes:
                        screenManager.Game.Exit();
                        break;
                    case (int)EndGameEntry.No:
                        screenManager.RemoveScreen(this);
                        break;
                }
            }
            if (input.IsNewKeyPress(Keys.Escape))
            {
                screenManager.RemoveScreen(this);
            }
        }
 public override void HandleInput(InputState input)
 {
     if (input.IsNewKeyPress(Keys.Enter) || input.IsNewKeyPress(Keys.Space))
     {
         // move on to gameplay
         screenManager.AddScreen(new MainGameScreen());
         screenManager.RemoveScreen(this);
     }
 }
 public override void HandleInput(InputState input)
 {
     if (input.IsNewKeyPress(Keys.Enter) && keyboardInput.Length > 0)
     {
         // accept name and move on to intro screen
         screenManager.AddScreen(new IntroductionScreen());
         screenManager.RemoveScreen(this);
         screenManager.RemoveScreen(ParentScreen);
     }
     if (input.IsNewKeyPress(Keys.Escape))
     {
         screenManager.RemoveScreen(this);
     }
 }
Exemplo n.º 5
0
 public virtual void HandleInput(InputState input)
 {
 }
        public override void HandleInput(InputState input)
        {
            int x = (int)((Position)PlayerManager.Player.GetComponent("Position")).X;
            int y = (int)((Position)PlayerManager.Player.GetComponent("Position")).Y;

            if (input.IsNewKeyPress(Keys.NumPad1) && (tower.getCurrentFloor())[x - 1][y + 1] == (int)EnvTiles.Floor)
            {
                PlayerManager.Player.DoAction("ChangeDeltaPosition", new ChangePositionArgs(new Vector2(-1, 1)));
                PlayerManager.Player.DoAction("ChangeDirectionOfAnimation", new ChangeDirectionOfAnimationArgs("left"));
            }
            else if (input.IsNewKeyPress(Keys.NumPad4) && (tower.getCurrentFloor())[x - 1][y] == (int)EnvTiles.Floor)
            {
                PlayerManager.Player.DoAction("ChangeDeltaPosition", new ChangePositionArgs(new Vector2(-1, 0)));
                PlayerManager.Player.DoAction("ChangeDirectionOfAnimation", new ChangeDirectionOfAnimationArgs("left"));
            }
            else if (input.IsNewKeyPress(Keys.NumPad7) && (tower.getCurrentFloor())[x - 1][y - 1] == (int)EnvTiles.Floor)
            {
                PlayerManager.Player.DoAction("ChangeDeltaPosition", new ChangePositionArgs(new Vector2(-1, -1)));
                PlayerManager.Player.DoAction("ChangeDirectionOfAnimation", new ChangeDirectionOfAnimationArgs("left"));
            }
            else if (input.IsNewKeyPress(Keys.NumPad8) && (tower.getCurrentFloor())[x][y - 1] == (int)EnvTiles.Floor)
            {
                PlayerManager.Player.DoAction("ChangeDeltaPosition", new ChangePositionArgs(new Vector2(0, -1)));
            }
            else if (input.IsNewKeyPress(Keys.NumPad9) && (tower.getCurrentFloor())[x + 1][y - 1] == (int)EnvTiles.Floor)
            {
                PlayerManager.Player.DoAction("ChangeDeltaPosition", new ChangePositionArgs(new Vector2(1, -1)));
                PlayerManager.Player.DoAction("ChangeDirectionOfAnimation", new ChangeDirectionOfAnimationArgs("right"));
            }
            else if (input.IsNewKeyPress(Keys.NumPad6) && (tower.getCurrentFloor())[x + 1][y] == (int)EnvTiles.Floor)
            {
                PlayerManager.Player.DoAction("ChangeDeltaPosition", new ChangePositionArgs(new Vector2(1, 0)));
                PlayerManager.Player.DoAction("ChangeDirectionOfAnimation", new ChangeDirectionOfAnimationArgs("right"));
            }
            else if (input.IsNewKeyPress(Keys.NumPad3) && (tower.getCurrentFloor())[x + 1][y + 1] == (int)EnvTiles.Floor)
            {
                PlayerManager.Player.DoAction("ChangeDeltaPosition", new ChangePositionArgs(new Vector2(1, 1)));
                PlayerManager.Player.DoAction("ChangeDirectionOfAnimation", new ChangeDirectionOfAnimationArgs("right"));
            }
            else if (input.IsNewKeyPress(Keys.NumPad2) && (tower.getCurrentFloor())[x][y + 1] == (int)EnvTiles.Floor)
            {
                PlayerManager.Player.DoAction("ChangeDeltaPosition", new ChangePositionArgs(new Vector2(0, 1)));
            }

            if (input.IsNewKeyPress(Keys.Escape))
                screenManager.AddScreen(new EndGameScreen());
        }