/// <summary> /// Scans the SadConsole's Global KeyboardState and triggers behaviour /// based on the button pressed. /// </summary> /// <param name="info"></param> /// <returns></returns> public override bool ProcessKeyboard(Keyboard info) { if (GameLoop.World != null) { if (HandleMove(info)) { if (!GetPlayer.Bumped && GameLoop.World.CurrentMap.ControlledEntitiy is Player) { GameLoop.World.ProcessTurn(TimeHelper.GetWalkTime(GetPlayer), true); } else if (GameLoop.World.CurrentMap.ControlledEntitiy is Player) { GameLoop.World.ProcessTurn(TimeHelper.GetAttackTime(GetPlayer), true); } return(true); } if (info.IsKeyPressed(Keys.NumPad5) || info.IsKeyPressed(Keys.OemPeriod)) { GameLoop.World.ProcessTurn(TimeHelper.Wait, true); } if (info.IsKeyPressed(Keys.A)) { bool sucess = CommandManager.DirectAttack(GameLoop.World.Player); GameLoop.World.ProcessTurn(TimeHelper.GetAttackTime(GameLoop.World.Player), sucess); } if (info.IsKeyPressed(Keys.G)) { Item item = GameLoop.World.CurrentMap.GetEntityAt <Item>(GameLoop.World.Player.Position); bool sucess = CommandManager.PickUp(GameLoop.World.Player, item); InventoryScreen.ShowItems(GameLoop.World.Player); GameLoop.World.ProcessTurn(TimeHelper.Interact, sucess); } if (info.IsKeyPressed(Keys.D)) { bool sucess = CommandManager.DropItems(GameLoop.World.Player); Item item = GameLoop.World.CurrentMap.GetEntityAt <Item>(GameLoop.World.Player.Position); InventoryScreen.RemoveItemFromConsole(item); InventoryScreen.ShowItems(GameLoop.World.Player); GameLoop.World.ProcessTurn(TimeHelper.Interact, sucess); } if (info.IsKeyPressed(Keys.C)) { bool sucess = CommandManager.CloseDoor(GameLoop.World.Player); GameLoop.World.ProcessTurn(TimeHelper.Interact, sucess); MapWindow.MapConsole.IsDirty = true; } if (info.IsKeyPressed(Keys.I)) { InventoryScreen.Show(); } if (info.IsKeyPressed(Keys.H)) { bool sucess = CommandManager.SacrificeLifeEnergyToMana(GameLoop.World.Player); GameLoop.World.ProcessTurn(TimeHelper.MagicalThings, sucess); } if (info.IsKeyPressed(Keys.L)) { if (!(target != null)) { target = new Target(GetPlayer.Position); } if (target.EntityInTarget()) { if (target.TargetList != null) { LookWindow w = new LookWindow(target.TargetList[0]); w.Show(); return(true); } } if (GameLoop.World.CurrentMap.ControlledEntitiy is not Player && !target.EntityInTarget()) { GameLoop.World.ChangeControlledEntity(GetPlayer); GameLoop.World.CurrentMap.Remove(target.Cursor); target = null; return(true); } GameLoop.World.CurrentMap.Add(target.Cursor); GameLoop.World.ChangeControlledEntity(target.Cursor); return(true); } if (info.IsKeyDown(Keys.LeftShift) && info.IsKeyPressed(Keys.Z)) { var spellBase = GetPlayer.Magic.QuerySpell("magic_missile"); var entity = GameLoop.World.CurrentMap.GetClosestEntity(GetPlayer.Position, spellBase.SpellRange); if (entity != null) { bool sucess = spellBase.CastSpell( entity.Position, GetPlayer); GameLoop.World.ProcessTurn(TimeHelper.MagicalThings, sucess); return(true); } else { GameLoop.UIManager.MessageLog.Add("There is no target for the spell!"); return(false); } } #if DEBUG if (info.IsKeyPressed(Keys.F10)) { CommandManager.ToggleFOV(); MapWindow.MapConsole.IsDirty = true; } if (info.IsKeyPressed(Keys.F8)) { GetPlayer.AddComponent(new Components.TestComponent(GetPlayer)); } if (info.IsKeyPressed(Keys.NumPad0)) { LookWindow w = new LookWindow(GetPlayer); w.Show(); } #endif if (info.IsKeyPressed(Keys.Escape) && NoPopWindow) { //SadConsole.Game.Instance.Exit(); MainMenu.Show(); MainMenu.IsFocused = true; } } return(base.ProcessKeyboard(info)); }