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); } }
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(); } }
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(); }
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; } }
/* * Обработка нажатых клавиш */ 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); }
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); } }
void Start() { this._mainmenu = this.gameObject.GetComponent<MainMenu>(); this._menupaused = this.gameObject.GetComponent<MenuPaused>(); currentState = MasterStates.Starting; }