private static void ResolveDamage(Actor defender, int damage) { MessageLogWindow MessageLog = GameLoop.UIManager.MessageLog; if (damage > 0) { BodyPart hitPart = defender.anatomy.RandomItem(); hitPart.HpCurrent -= damage; defender.Health -= damage; MessageLog.AddTextNewline($" {hitPart.Name} was hit for {damage} damage, now at {hitPart.HpCurrent}. {defender.Name} at {defender.Health}."); if (hitPart.HpCurrent <= 0) { hitPart.Severance(0 - hitPart.HpCurrent); } if (defender.Health <= 0) { ResolveDeath(defender); } } else { MessageLog.AddTextNewline($"{defender.Name} blocked all damage!"); } }
public static void InitHUD() { SadConsole.Themes.Library.Default.Colors.ControlHostBack = Color.Black; SadConsole.Themes.Library.Default.Colors.ControlHostFore = Color.Black; var console = new SadConsole.Console(WindowWidth, WindowHeight); SadConsole.Global.CurrentScreen = console; SkillsConsole = new CustomConsole(Microsoft.Xna.Framework.Color.Blue, SkillsWidth, SkillsHeight) { Position = new Point(0, 0) }; MapConsole = new CustomConsole(Microsoft.Xna.Framework.Color.Black, MapWidth, MapHeight) { Position = new Point(0, 5) }; MapScrollConsole = new ScrollingConsole(MapWidth, MapHeight, Global.FontDefault); SidebarInventory = new CustomConsole(Microsoft.Xna.Framework.Color.Green, InventoryWidth, InventoryHeight) { Position = new Point(60, 0) }; SidebarPlayerProfile = new CustomConsole(Microsoft.Xna.Framework.Color.Red, ProfileWidth, ProfileHeight) { Position = new Point(60, 10) }; MessageConsole = new CustomConsole(Microsoft.Xna.Framework.Color.Black, MessageWidth, MessageHeight) { Position = new Point(0, 25) }; MessageLog = new MessageLogWindow(MessageWidth, MessageHeight, "Message Log"); console.Children.Add(SkillsConsole); console.Children.Add(MapConsole); console.Children.Add(SidebarInventory); console.Children.Add(SidebarPlayerProfile); console.Children.Add(MessageConsole); MapConsole.Children.Add(MapScrollConsole); MessageConsole.Children.Add(MessageLog); MessageConsole.Fill(Color.Black, Color.Black, 176); MessageLog.Fill(Color.Black, Color.Black, 176); MessageLog.Show(); MessageLog.Position = new Point(0, 0); MessageLog.Add("Welcome to the dungeon."); }
public (bool sucess, long ticks) RunAi(Map map, MessageLogWindow messageLog) { // TODO: Fix, because it hardly works, at least i saw the actor attacking if (Parent is not GoRogue.GameFramework.IGameObject parent) { return(false, -1); } Actor actor = (Actor)GameLoop.World.CurrentMap.GetEntityById(parent.ID); int walkSpeed = TimeHelper.GetWalkTime(actor); if (TryGetDirectionMove(map, actor)) { return(true, walkSpeed); } else { return(true, TimeHelper.Wait); } }
public static bool BumpAttack(Actor attacker, Actor defender) { MessageLogWindow MessageLog = GameLoop.UIManager.MessageLog; StringBuilder attackMessage = new StringBuilder(); StringBuilder defenseMessage = new StringBuilder(); int hits = ResolveAttack(attacker, defender, attackMessage); int blocks = ResolveDefense(defender, hits, attackMessage, defenseMessage); int damage = hits - blocks; MessageLog.AddTextNewline(attackMessage.ToString()); if (!string.IsNullOrWhiteSpace(defenseMessage.ToString())) { MessageLog.AddTextNewline(defenseMessage.ToString()); } ResolveDamage(defender, damage); return(true); }