示例#1
0
        public override void HandleKey(ConsoleKey key)
        {
            if (key == ConsoleKey.Escape)
            {
                if (!snake.IsDead(FieldSize, Padding))
                {
                    // Не ставить на паузу если змейка врезалась и
                    // пользователь выбирает действие
                    IsPaused = !IsPaused;
                }
            }
            else if (key == ConsoleKey.Spacebar)
            {
                speedUp = true;
            }

            snake.HandleKey(key);

            if (GameOverActionMenu.IsFocused)
            {
                GameOverActionMenu.HandleKey(key);
            }

            if (IsPaused)
            {
                MenuPaused.HandleKey(key);
            }
        }
示例#2
0
        public override void HandleKey(ConsoleKey key)
        {
            if (GameOverActionMenu.IsFocused)
            {
                GameOverActionMenu.HandleKey(key);
                return;
            }

            if (key == ConsoleKey.Escape)
            {
                MenuPaused.IsFocused = !MenuPaused.IsFocused;
            }

            if (MenuPaused.IsFocused)
            {
                MenuPaused.HandleKey(key);
                return;
            }

            if (key == ConsoleKey.W || key == ConsoleKey.UpArrow ||
                key == ConsoleKey.K || key == ConsoleKey.Spacebar)
            {
                bird.Jump();
            }
        }
示例#3
0
        void PauseMenuAction(Drawer d)
        {
            if (!MenuPaused.IsSelected)
            {
                return;
            }

            if (MenuPaused.SelectedIndex == 0)
            {
                MenuPaused.IsFocused = false;
            }
            else if (MenuPaused.SelectedIndex == 1)
            {
                RemoveGame(d);
                isGameOver = true;
            }
            MenuPaused.Reuse();
        }
示例#4
0
        void CheckPausedMenuSomethingSelected(Drawer d)
        {
            if (!MenuPaused.IsSelected)
            {
                return;
            }

            if (MenuPaused.SelectedIndex == 0)
            {
                IsPaused = false;
                MenuPaused.Reuse();
            }
            else if (MenuPaused.SelectedIndex == 1)
            {
                RemoveGame(d);
                isGameOver = true;
            }
        }
示例#5
0
 /*
  * Обработка нажатых клавиш
  */
 public override void HandleKey(ConsoleKey key)
 {
     if (key == ConsoleKey.Escape)
     {
         if (!playGround.GameOver)
         {
             // Не показывать меню паузы когда
             // игра закончилась
             IsPaused = !IsPaused;
         }
     }
     if (IsPaused)
     {
         MenuPaused.HandleKey(key);
     }
     if (playGround.GameOver)
     {
         GameOverActionMenu.HandleKey(key);
     }
     playGround.HandleKey(key);
 }
示例#6
0
        public override void HandleKey(ConsoleKey key)
        {
            if (key == ConsoleKey.Escape)
            {
                IsPaused             = !IsPaused;
                MenuPaused.IsFocused = IsPaused;
                return;
            }

            if (IsPaused)
            {
                MenuPaused.HandleKey(key);
                return;
            }

            if (FinalScreen)
            {
                if (key == ConsoleKey.Enter)
                {
                    Init();
                }
                else
                {
                    return;
                }
            }

            if (new ConsoleKey[] { ConsoleKey.W, ConsoleKey.A, ConsoleKey.S, ConsoleKey.D }.Contains(key))
            {
                snake1.HandleKey(key);
            }
            else if (new ConsoleKey[] { ConsoleKey.UpArrow, ConsoleKey.LeftArrow, ConsoleKey.DownArrow, ConsoleKey.RightArrow }.Contains(key))
            {
                snake2.HandleKey(key);
            }
        }
示例#7
0
 void Start()
 {
     this._mainmenu = this.gameObject.GetComponent<MainMenu>();
     this._menupaused = this.gameObject.GetComponent<MenuPaused>();
     currentState = MasterStates.Starting;
 }