public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { // Process logic for moving the entity. bool keyHit = false; if (info.IsKeyReleased(Keys.Up)) { _position.Y -= 1; keyHit = true; } else if (info.IsKeyReleased(Keys.Down)) { _position.Y += 1; keyHit = true; } if (info.IsKeyReleased(Keys.Left)) { _position.X -= 1; keyHit = true; } else if (info.IsKeyReleased(Keys.Right)) { _position.X += 1; keyHit = true; } return(keyHit); }
private bool ProcessKeyboardRunning(SadConsole.Input.KeyboardInfo info) { bool processedKeyboard = false; if (player.ProcessKeyboard(info)) { processedKeyboard = true; if (info.IsKeyDown(Keys.Up)) { upKeyAnimation.Run(); } else if (info.IsKeyDown(Keys.Down)) { downKeyAnimation.Run(); } else if (info.IsKeyDown(Keys.Left)) { leftKeyAnimation.Run(); } else if (info.IsKeyDown(Keys.Right)) { rightKeyAnimation.Run(); } } return(processedKeyboard); }
public bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { foreach (var k in ButtonConfiguration.Keys) { if (info.KeysPressed.Contains(SadConsole.Input.AsciiKey.Get(k))) { Fire(GetButton(k)); return(true); } } return(false); }
private bool ProcessKeyboardGameOver(SadConsole.Input.KeyboardInfo info) { bool processedKeyboard = false; if (info.IsKeyReleased(Keys.Multiply)) { astrickKeyAnimation.Run(); CreateMenu(); processedKeyboard = true; } return(processedKeyboard); }
public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { // Forward the keyboard data to the entity to handle the movement code. // We could detect if the users hit ESC and popup a menu or something. // By not setting the entity as the active object, twe let this // "game level" (the console we're hosting the entity on) determine if // the keyboard data should be sent to the entity. // Process logic for moving the entity. bool keyHit = false; if (info.IsKeyReleased(Keys.Up)) { player.Position = new Point(player.Position.X, player.Position.Y - 1); keyHit = true; } else if (info.IsKeyReleased(Keys.Down)) { player.Position = new Point(player.Position.X, player.Position.Y + 1); keyHit = true; } if (info.IsKeyReleased(Keys.Left)) { player.Position = new Point(player.Position.X - 1, player.Position.Y); keyHit = true; } else if (info.IsKeyReleased(Keys.Right)) { player.Position = new Point(player.Position.X + 1, player.Position.Y); keyHit = true; } if (keyHit) { // Entity moved. Let's draw a trail of where they moved from. // We are not detecting when the player tries to move off the console area. // We could detected that though and then move the player back to where they were. SetGlyph(playerPreviousPosition.X, playerPreviousPosition.Y, 250); playerPreviousPosition = player.Position; return(true); } // You could have multiple entities in the game for example, and change // which entity gets keyboard commands. return(false); }
public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { if (info == null) { return(false); } if (info.KeysReleased.Count > 0) { if (releaseCount > 0) { releaseCount--; return(true); } if (playAgain == false) { // Clear Line for (int x = 8; x < 39; x++) { this.CellData.SetCharacter(x, 24, 0, CastleGame.GameColor); } this.CellData.Print(8, 24, CastleAdventureResources.PlayAgain, CastleGame.GameColor); playAgain = true; return(true); } if (info.IsKeyReleased(Keys.Y)) { if (RestartGame != null) { RestartGame(this, new EventArgs()); } return(true); } if (info.IsKeyReleased(Keys.N)) { if (QuitGame != null) { QuitGame(this, new EventArgs()); } return(true); } return(false); } else { return(false); } }
public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { if (info.IsKeyReleased(Keys.P)) { if (PlayGame != null) { PlayGame(this, new EventArgs()); } return(true); } if (info.IsKeyReleased(Keys.I)) { PrintInstructions(); return(true); } return(false); }
public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { switch (gameState) { case GameState.MenuScreen: return(ProcessKeyboardMenu(info)); case GameState.Running: return(ProcessKeyboardRunning(info)); case GameState.GameOver: return(ProcessKeyboardGameOver(info)); default: return(false); } }
public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { if (info == null) { return(false); } if (gameOver == false) { if (player.ProcessKeyboard(info)) { return(true); } else { base.ProcessKeyboard(info); } return(false); } else { if (info.KeysReleased.Count > 0) { if (firstRelease) { firstRelease = false; return(true); } else { if (StopGamePlay != null) { StopGamePlay(this, new EventArgs()); } return(true); } } else { return(false); } } }
public bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { // Process logic for moving the entity. bool keyHit = false; if (info.IsKeyDown(Keys.Up)) { if (CurrentDirection != Direction.Down) { this.CurrentDirection = Direction.Up; } keyHit = true; } else if (info.IsKeyDown(Keys.Down)) { if (CurrentDirection != Direction.Up) { this.CurrentDirection = Direction.Down; } keyHit = true; } if (info.IsKeyDown(Keys.Left)) { if (CurrentDirection != Direction.Right) { this.CurrentDirection = Direction.Left; } keyHit = true; } else if (info.IsKeyDown(Keys.Right)) { if (CurrentDirection != Direction.Left) { this.CurrentDirection = Direction.Right; } keyHit = true; } return(keyHit); }
public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { if (info.KeysReleased.Count > 0) { if (releaseCount > 0) { releaseCount--; return(true); } if (playAgain == false) { Print(8, 24, "PLAY AGAIN (Y/N)? ", Color.White); playAgain = true; return(true); } if (info.IsKeyReleased(Keys.Y)) { if (RestartGame != null) { RestartGame(this, new EventArgs()); } return(true); } if (info.IsKeyReleased(Keys.N)) { if (QuitGame != null) { QuitGame(this, new EventArgs()); } return(true); } return(false); } else { return(false); } }
public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { // Forward the keyboard data to the entity to handle the movement code. // We could detect if the users hit ESC and popup a menu or something. // By not setting the entity as the active object, twe let this // "game level" (the console we're hosting the entity on) determine if // the keyboard data should be sent to the entity. if (_player.ProcessKeyboard(info)) { // Entity moved. Let's draw a trail of where they moved from. // We are not detecting when the player tries to move off the console area. // We could detected that though and then move the player back to where they were. _cellData.SetCharacter(_playerPreviousPosition.X, _playerPreviousPosition.Y, 250); _playerPreviousPosition = _player.Position; return(true); } // You could have multiple entities in the game for example, and change // which entity gets keyboard commands. return(false); }
public override bool ProcessKeyboard(SadConsole.Input.KeyboardInfo info) { if (info == null) { return(false); } // Process logic for moving the entity. bool keyHit = false; if (info.IsKeyDown(Keys.Up)) { this.CurrentDirection = Direction.Up; keyHit = true; } else if (info.IsKeyDown(Keys.Down)) { this.CurrentDirection = Direction.Down; keyHit = true; } if (info.IsKeyDown(Keys.Left)) { this.CurrentDirection = Direction.Left; keyHit = true; } else if (info.IsKeyDown(Keys.Right)) { this.CurrentDirection = Direction.Right; keyHit = true; } switch (CurrentDirection) { case Direction.Up: if (info.IsKeyReleased(Keys.Up)) { this.CurrentDirection = Direction.None; keyHit = true; } break; case Direction.Down: if (info.IsKeyReleased(Keys.Down)) { this.CurrentDirection = Direction.None; keyHit = true; } break; case Direction.Left: if (info.IsKeyReleased(Keys.Left)) { this.CurrentDirection = Direction.None; keyHit = true; } break; case Direction.Right: if (info.IsKeyReleased(Keys.Right)) { this.CurrentDirection = Direction.None; keyHit = true; } break; } return(keyHit); }