private static void GameOverUpdate(object sender, UpdateEventArgs e) { RLKeyPress introKeyPress = _rootConsole.Keyboard.GetKeyPress(); if (introKeyPress != null) { if (introKeyPress.Key == RLKey.T) { Game.MessageLog.Add("You Cheater! You were resurrected", Swatch.DbBlood); Player.Health = Player.MaxHealth; Player.Hunger = 1200; IsGameOver = false; _rootConsole.Update -= GameOverUpdate; _rootConsole.Render -= GameOverRender; _rootConsole.Update += OnRootConsoleUpdate; _rootConsole.Render += OnRootConsoleRender; } else if (introKeyPress.Key == RLKey.L) { _rootConsole.Update -= GameOverUpdate; _rootConsole.Render -= GameOverRender; _rootConsole.Update += OnRootConsoleUpdate; _rootConsole.Render += OnRootConsoleRender; } else if (introKeyPress.Key == RLKey.E || introKeyPress.Key == RLKey.X) { _rootConsole.Close(); } } else { _renderRequired = true; } }
// Event handler for RLNET's Update event private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { bool did_player_act = false; RLKeyPress key_press = _root_console.Keyboard.GetKeyPress(); if (key_press != null) { if (key_press.Key == RLKey.Keypad8) { did_player_act = command_system.MovePlayer(Direction.up); } else if (key_press.Key == RLKey.Keypad2) { did_player_act = command_system.MovePlayer(Direction.down); } else if (key_press.Key == RLKey.Keypad4) { did_player_act = command_system.MovePlayer(Direction.left); } else if (key_press.Key == RLKey.Keypad6) { did_player_act = command_system.MovePlayer(Direction.right); } else if (key_press.Key == RLKey.Escape) { _root_console.Close(); } } if (did_player_act) { _render_required = true; } }
private static void OnIntroUpdate(object sender, UpdateEventArgs e) { RLKeyPress introKeyPress = _rootConsole.Keyboard.GetKeyPress(); if (introKeyPress != null) { if (introKeyPress.Key == RLKey.N) { _rootConsole.Update -= OnIntroUpdate; _rootConsole.Render -= OnIntroRender; _rootConsole.Update += OnRootConsoleUpdate; _rootConsole.Render += OnRootConsoleRender; } else if (introKeyPress.Key == RLKey.L) { _rootConsole.Update -= OnIntroUpdate; _rootConsole.Render -= OnIntroRender; _rootConsole.Update += OnStoryUpdate; _rootConsole.Render += OnStoryRender; } else if (introKeyPress.Key == RLKey.E || introKeyPress.Key == RLKey.X || introKeyPress.Key == RLKey.Escape) { _rootConsole.Close(); } } else { _renderRequired = true; } }
private void Update_GameOver(RLKeyPress keyPress) { if (keyPress != null) { StateManager.ChangeState(GameState.HighScore); } }
public override void Update(KeyboardState keyboard, RLKeyPress keyPress) { if (keyPress?.Key == RLKey.Escape) { StateManager.ChangeState(GameState.Destroyed); } switch (StateManager.CurrentState) { case GameState.Title: Update_Title(keyPress); break; case GameState.Running: Update_Running(keyPress); break; case GameState.GameOver: Update_GameOver(keyPress); break; case GameState.HighScore: Update_HighScore(keyPress); break; case GameState.Splash: Update_Splash(keyPress); break; } }
public void HandleKey(RLKeyPress keyPress) { base.HandleKey(keyPress, this.player); OnPlayerMove(new PlayerMoveEventArgs { playerPos = player.pos, engine = this }); }
/// <summary> /// Allow the player to interact with the splash screen. /// </summary> private void OnSplashUpdate(object sender, UpdateEventArgs e) { // Event handler for RLNET's Update event didPlayerAct = false; keyPress = console.Keyboard.GetKeyPress(); if (keyPress != null) { // User presses "N" for New Game if (keyPress.Key == RLKey.N) { // Remove now unneeded event handlers for console console.Update -= OnSplashUpdate; console.Render -= OnSplashRender; // Now start the game StartGame(); } // User presses "E" to exit game else if (keyPress.Key == RLKey.E) { console.Close(); } } else { _renderRequired = true; } }
private IDisplay HandleKeyPressed(RLKeyPress keyPress) { if (keyPress == null) { throw new InvalidOperationException("Called HandleKeyPressed with null, don't do this!"); } switch (keyPress.Key) { case RLKey.Escape: this.Reset(); return(this.parent); case RLKey.Keypad4: case RLKey.H: case RLKey.Left: this.entityIndex--; break; case RLKey.Keypad6: case RLKey.Right: case RLKey.L: this.entityIndex++; break; default: break; } return(this); }
private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { bool didPlayerAct = false; RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); if (keyPress != null) { if (keyPress.Key == RLKey.Up) { didPlayerAct = CommandSystem.MovePlayer(DooRany.Up); } else if (keyPress.Key == RLKey.Down) { didPlayerAct = CommandSystem.MovePlayer(DooRany.Down); } else if (keyPress.Key == RLKey.Left) { didPlayerAct = CommandSystem.MovePlayer(DooRany.Left); } else if (keyPress.Key == RLKey.Right) { didPlayerAct = CommandSystem.MovePlayer(DooRany.Right); } else if (keyPress.Key == RLKey.Escape) { _rootConsole.Close(); } } if (didPlayerAct) { _renderRequired = true; } }
public IDisplay OnRootConsoleUpdate(RLConsole console, RLKeyPress keyPress) { // Explicit exit conditions if (keyPress == null) { return(this); } else if (keyPress.Key == RLKey.Escape) { return(this.parentDisplay); } // Key logic if (keyPress.Key == RLKey.BackSpace) { this.weaponSelection = null; } else if (keyPress.Char != null && char.IsLetter((char)keyPress.Char)) { if (this.weaponSelection == null) { this.TryStoreWeaponSelection((char)keyPress.Char); } else { TrySwapWeaponToMount(this.GetEntityByChar(this.holstersDict, (char)this.weaponSelection), this.GetEntityByChar(this.mountsDict, (char)keyPress.Char)); this.weaponSelection = null; } } return(this); }
// Event handler for RLNET's Update event private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { // Set background color and text for each console // so that we can verify they are in the correct positions _mapConsole.SetBackColor(0, 0, _mapWidth, _mapHeight, RLColor.Black); _mapConsole.Print(1, 1, "Map", RLColor.White); _mapConsole.Set(2, 2, RLColor.Red, RLColor.Green, 'L'); RLCell cell = new RLCell(RLColor.Yellow, RLColor.Brown, 'X'); _mapConsole.Set(3, 3, cell); _messageConsole.SetBackColor(0, 0, _messageWidth, _messageHeight, RLColor.Gray); _messageConsole.Print(1, 1, "Messages", RLColor.White); _statConsole.SetBackColor(0, 0, _statWidth, _statHeight, RLColor.Brown); _statConsole.Print(1, 1, "Stats", RLColor.White); _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, RLColor.Cyan); _inventoryConsole.Print(1, 1, "Inventory", RLColor.White); RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); if (keyPress != null) { _mapConsole.Print(10, 10, "Key: " + keyPress.ToString(), RLColor.White); } else { var str = _rootConsole.Mouse.X + "," + _rootConsole.Mouse.Y; _mapConsole.Print(10, 10, "Mouse: " + str, RLColor.White); } }
static void rootConsole_Update(object sender, UpdateEventArgs e) { RLKeyPress keyPress = rootConsole.Keyboard.GetKeyPress(); if (keyPress != null) { if (keyPress.Key == RLKey.Up) { playerY--; } else if (keyPress.Key == RLKey.Down) { playerY++; } else if (keyPress.Key == RLKey.Left) { playerX--; } else if (keyPress.Key == RLKey.Right) { playerX++; } if (keyPress.Key == RLKey.Escape) { rootConsole.Close(); } } }
// Event handler for RLNET's Update event private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { bool didPlayerAct = false; RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); if (keyPress != null) { if (keyPress.Key == RLKey.Up) { didPlayerAct = CommandSystem.MovePlayer(Direction.Up); } else if (keyPress.Key == RLKey.Down) { didPlayerAct = CommandSystem.MovePlayer(Direction.Down); } else if (keyPress.Key == RLKey.Left) { didPlayerAct = CommandSystem.MovePlayer(Direction.Left); } else if (keyPress.Key == RLKey.Right) { didPlayerAct = CommandSystem.MovePlayer(Direction.Right); } else if (keyPress.Key == RLKey.Escape) { _rootConsole.Close(); } } if (didPlayerAct) { // MessageLog.Add($"Step # {++_steps}"); // Temporary code to test the message log. _renderRequired = true; } }
private void Update_HighScore(RLKeyPress keyPress) { var editable = Settings.HighScore.Find(h => h.Editable); if (editable != null) { if (keyPress?.Key == RLKey.Enter) { editable.Editable = false; SettingsManager.Write(Settings); } else if (keyPress?.Key == RLKey.BackSpace) { if (nameBuffer.Length > 0) { nameBuffer.Length--; editable.Name = nameBuffer.ToString(); } } else if (keyPress?.Char != null && nameBuffer.Length < HighScoreEntry.MaxNameLength) { char character = char.ToUpperInvariant(keyPress.Char.Value); nameBuffer.Append(character); editable.Name = nameBuffer.ToString(); } } else if (keyPress != null) { StateManager.ChangeState(GameState.Title); } }
private static void OnHelpUpdate(object sender, UpdateEventArgs e) { RLKeyPress inputKey = rootConsole.Keyboard.GetKeyPress(); renderRequired = true; if (inputKey != null) { if (indexHelpText < 6) { menuConsole.Print((screenWidth - helpText[indexHelpText].Length) / 2, 10 + 5 * indexHelpText, helpText[indexHelpText], RLColor.White, null); indexHelpText++; } else if (indexHelpText < 8) { menuConsole.Print((screenWidth - helpText[indexHelpText].Length) / 2, 20 + 5 * indexHelpText, helpText[indexHelpText], RLColor.White, null); indexHelpText++; } else { indexHelpText = 0; menuConsole.Clear(); FillMenu(); rootConsole.Update -= OnHelpUpdate; rootConsole.Update += OnMenuUpdate; } } }
private void Update_Running(RLKeyPress keyPress) { SetDirection(keyPress); if (!direction.HasValue || (DateTime.Now - lastUpdate).TotalMilliseconds < GetTickRate(Level)) { return; } var newHead = nodes.First.Value.Shifted(direction).Warp(0, NokiaApp.ScreenWidth, 0, NokiaApp.ScreenHeight); if (!HasSelfCollision(newHead) && !HasObstacleCollision(newHead)) { nodes.AddFirst(newHead); nodes.RemoveLast(); CheckForTreatsCollision(); CheckForLevelUp(); lastUpdate = DateTime.Now; } else { StateManager.ChangeState(GameState.GameOver); StateManager.ChangeState(GameState.Splash); } }
private static void OnShopSelectionUpdate(object sender, UpdateEventArgs e) { RLKeyPress selectionKeyPress = _rootConsole.Keyboard.GetKeyPress(); if (selectionKeyPress != null) { if (selectionKeyPress.Key == RLKey.B) { IsShopSelectionScreenShowing = false; ToggleShopSelectionUpdate(); IsBuyScreenShowing = true; TogglePopupUpdate(); } else if (selectionKeyPress.Key == RLKey.S) { IsShopSelectionScreenShowing = false; ToggleShopSelectionUpdate(); IsSellScreenShowing = true; TogglePopupUpdate(); } else if (selectionKeyPress.Key == RLKey.E || selectionKeyPress.Key == RLKey.X || selectionKeyPress.Key == RLKey.Escape) { IsShopSelectionScreenShowing = false; ToggleShopSelectionUpdate(); } } else { _renderRequired = true; } }
//This is the event handler for the Update Event of RLNET private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { //Determines player keyboard input using rootConsole bool didPlayerAct = false; RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); //Reads and commands the player movement based on keyboard input if (keyPress != null) { if (keyPress.Key == RLKey.Up) { didPlayerAct = CommandSystem.MovePlayer(Direction.Up); } else if (keyPress.Key == RLKey.Down) { didPlayerAct = CommandSystem.MovePlayer(Direction.Down); } else if (keyPress.Key == RLKey.Left) { didPlayerAct = CommandSystem.MovePlayer(Direction.Left); } else if (keyPress.Key == RLKey.Right) { didPlayerAct = CommandSystem.MovePlayer(Direction.Right); } else if (keyPress.Key == RLKey.Escape) { _rootConsole.Close(); } } if (didPlayerAct) { _renderRequired = true; } }
public int Update(RLKeyPress keypress) { var msg = Client.ReadMessage(); if (msg != null) { switch (msg.MessageType) { case NetIncomingMessageType.DiscoveryResponse: var name = msg.ReadString(); var endpoint = msg.SenderEndPoint; if (!servers.ContainsKey(name)) { servers.Add(name, endpoint); } if (!sellist.Contains(name)) { sellist.Add(name); } break; } } if (keypress != null) { switch (keypress.Key) { case RLKey.Up: if (curIndex == 0) { break; } else { curIndex--; break; } case RLKey.Down: if (curIndex == sellist.Count - 1) { break; } else { curIndex++; } break; case RLKey.Enter: if (servers.Count > 0) { return(1); } break; } } return(0); }
private void Update_Title(RLKeyPress keyPress) { if (keyPress != null) { Initialize(); StateManager.ChangeState(GameState.Splash); } }
// Event handler for Update event private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { //might move this junk out of consoleupdate to clean up, but this moves char for now bool didPlayerAct = false; RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); if (CommandSystem.IsPlayerTurn) { if (keyPress != null) { if (keyPress.Key == RLKey.Up) { didPlayerAct = CommandSystem.MovePlayer(Direction.Up); } else if (keyPress.Key == RLKey.Down) { didPlayerAct = CommandSystem.MovePlayer(Direction.Down); } else if (keyPress.Key == RLKey.Left) { didPlayerAct = CommandSystem.MovePlayer(Direction.Left); } else if (keyPress.Key == RLKey.Right) { didPlayerAct = CommandSystem.MovePlayer(Direction.Right); } else if (keyPress.Key == RLKey.Escape) { _rootConsole.Close(); } else if (keyPress.Key == RLKey.Period) { if (DungeonMap.CanMoveDownToNextLevel()) { _mapLevel += 1; MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 50, 5, 13, _mapLevel); DungeonMap = mapGenerator.CreateMap(); MessageLog = new MessageLog(); CommandSystem = new CommandSystem(); string consoleTitle = $"D$ DungeonZ Level {_mapLevel} - Seed {seed}"; didPlayerAct = true; } } } if (didPlayerAct) { _renderRequired = true; CommandSystem.EndPlayerTurn(); } } else { CommandSystem.ActivateMonsters(); _renderRequired = true; } }
// Event handler for RLNET's Update event private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { bool didPlayerAct = false; RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); if (CommandSystem.IsPlayerTurn) { if (keyPress != null) { if (keyPress.Key == RLKey.Up) { didPlayerAct = CommandSystem.MovePlayer(Direction.Up); } else if (keyPress.Key == RLKey.Down) { didPlayerAct = CommandSystem.MovePlayer(Direction.Down); } else if (keyPress.Key == RLKey.Left) { didPlayerAct = CommandSystem.MovePlayer(Direction.Left); } else if (keyPress.Key == RLKey.Right) { didPlayerAct = CommandSystem.MovePlayer(Direction.Right); } else if (keyPress.Key == RLKey.Escape) { _rootConsole.Close(); } else if (keyPress.Key == RLKey.Period) { if (DungeonMap.CanMoveDownToNextLevel()) { MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, ++_mapLevel); DungeonMap = mapGenerator.CreateMap(); MessageLog = new MessageLog(); CommandSystem = new CommandSystem(); _rootConsole.Title = $"RougeSharp RLNet Tutorial - Level {_mapLevel}"; didPlayerAct = true; } } } if (didPlayerAct) { _renderRequired = true; CommandSystem.EndPlayerTurn(); } } else { CommandSystem.ActivateMonsters(); _renderRequired = true; } }
// Event handler for RLNET's Update event private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { _inventoryConsole.SetBackColor(0, 0, _inventoryWidth, _inventoryHeight, Palette.DbWood); _inventoryConsole.Print(1, 1, "Inventory", Colors.TextHeading); bool didPlayerAct = false; RLKeyPress keyPress = _rootConsole.Keyboard.GetKeyPress(); if (CommandSystem.IsPlayerTurn) { if (keyPress != null) { if (keyPress.Key == RLKey.Up) { didPlayerAct = CommandSystem.MovePlayer(Directions.Up); } else if (keyPress.Key == RLKey.Down) { didPlayerAct = CommandSystem.MovePlayer(Directions.Down); } else if (keyPress.Key == RLKey.Left) { didPlayerAct = CommandSystem.MovePlayer(Directions.Left); } else if (keyPress.Key == RLKey.Right) { didPlayerAct = CommandSystem.MovePlayer(Directions.Right); } else if (keyPress.Key == RLKey.Escape) { _rootConsole.Close(); } else if (keyPress.Key == RLKey.Period) { if (DungeonMap.CanMoveDownToNextLevel()) { MapGenerator mapGenerator = new MapGenerator(_mapWidth, _mapHeight, 20, 13, 7, ++_mapLevel); DungeonMap = mapGenerator.CreateMap(); MessageLog = new MessageLog(); CommandSystem = new CommandSystem(); _rootConsole.Title = $"SharpRogue - Level {_mapLevel}"; didPlayerAct = true; } } } if (didPlayerAct) { _renderRequired = true; CommandSystem.EndPlayerTurn(); } } else { CommandSystem.ActivateMonsters(); _renderRequired = true; } }
public bool OnUpdate(RLKeyPress keyPress) { if (keyPress != null) { menuControls.CheckInput(keyPress); return(true); } return(false); }
public IDisplay OnRootConsoleUpdate(RLConsole console, RLKeyPress keyPress) { if (keyPress != null) { return(this.HandleKeyPressed(keyPress)); } else { return(this); } }
public IDisplay OnRootConsoleUpdate(RLConsole console, RLKeyPress keyPress) { if (keyPress != null) { return(this.mainMenu); } else { return(this); } }
// Event handler for RLNET's Update event private static void OnRootConsoleUpdate(object sender, UpdateEventArgs e) { RLKeyPress keyPress = rlRoot.Keyboard.GetKeyPress(); bool didPlayerAct = false; if (keyPress != null) { if (keyPress.Key == RLKey.Up) { Player.Instance.y = Math.Max(1, Player.Instance.y - 1); didPlayerAct = true; } else if (keyPress.Key == RLKey.Down) { Player.Instance.y = Math.Min(HEIGHT - 2, Player.Instance.y + 1); didPlayerAct = true; } else if (keyPress.Key == RLKey.Left) { Player.Instance.x = Math.Max(1, Player.Instance.x - 1); didPlayerAct = true; } else if (keyPress.Key == RLKey.Right) { Player.Instance.x = Math.Min(WIDTH - 2, Player.Instance.x + 1); didPlayerAct = true; } } if (didPlayerAct) { _renderRequired = true; } for (int i = 0; i < WIDTH; i++) { for (int j = 0; j < HEIGHT; j++) { if (Player.Instance.x == i && Player.Instance.y == j) { rlRoot.Print(i, j, "@", RLColor.White); } else if (grid[i, j] == 0) { rlRoot.Print(i, j, ".", RLColor.White); } else { rlRoot.Print(i, j, "#", RLColor.White); } } } }
public IDisplay OnRootConsoleUpdate(RLConsole console, RLKeyPress keyPress) { // Drawing sets this.arenaConsole.SetBackColor(0, 0, Menu_Floor.arenaConsoleWidth, Menu_Floor.arenaConsoleHeight, RLColor.Black); this.arenaConsole.Print(1, 1, "Arena", RLColor.White); this.infoConsole.SetBackColor(0, 0, Menu_Floor.infoConsoleWidth, Menu_Floor.infoConsoleHeight, RLColor.Black); this.status1Console.SetBackColor(0, 0, Menu_Floor.statusWidth, Menu_Floor.statusHeight, RLColor.LightBlue); this.logConsole.SetBackColor(0, 0, Menu_Floor.statusWidth, Menu_Floor.statusHeight, RLColor.Black); // Logic if (this.dungeon.PlayerLost) { return(new Menu_Death(this.parent, this.Floor.Level)); } else if (this.dungeon.PlayerWon) { return(new Menu_NextLevel(this.parent, this, this.Floor.Level + 1)); } if (!this.dungeon.ShouldWaitForPlayerInput) { while (!this.dungeon.ShouldWaitForPlayerInput) { this.dungeon.TryFindAndExecuteNextCommand(); } return(this); } // TODO: logic here is !?!? else if (this.inventoryMenu.SelectedItem != null && this.targetMenu.Targeted && this.targetMenu.TargetedEntity != null) { var selected = this.inventoryMenu.SelectedItem; var target = this.targetMenu.TargetedEntity; this.inventoryMenu.Reset(); var stub = new CommandStub_UseItem(this.Floor.Player.EntityID, selected.EntityID, target.EntityID); this.dungeon.ResolveStub(stub); return(this); } else if (keyPress != null) { return(this.HandleKeyPressed(keyPress)); } else { this.dungeon.TryFindAndExecuteNextCommand(); return(this); } }
public override void Update(KeyboardState keyboard, RLKeyPress keyPress) { if (keyPress?.Key == RLKey.Escape) { StateManager.ChangeState(GameState.Destroyed); } switch (StateManager.CurrentState) { case GameState.Running: Update_Running(keyboard); break; } }
//TODO: Undo this hack. It's just in place as an experiment. public void Update (RLKeyPress keypress) { Player.GetComponent<GameFlowComponent> ().TurnBegins (); Player.Update (); if (keypress != null) Player.GetComponent<KeyboardInputComponent> ().Input (keypress); if (Player.GetComponent<GameFlowComponent> ().StopFlow) return; foreach (GameObject actor in Objects) { // if (keypress != null && actor.HasComponent<KeyboardInputComponent> ()) // actor.GetComponent<KeyboardInputComponent> ().Input (keypress); actor.Update (); } }
private void Update_Splash(RLKeyPress keyPress) { if (keyPress != null) { if (StateManager.PreviousState == GameState.GameOver) { Settings.PutScore(nameBuffer.ToString(), Score); StateManager.ChangeState(GameState.HighScore); } else { StateManager.ChangeState(GameState.Running); } } }