public static string GetLocationList() { List <string> locationKeys = new List <string>(); foreach (string key in LocationLookupDictionary.Keys) { locationKeys.Add(key); } return(TextUtils.Borderize(TextUtils.Columnize(locationKeys))); }
public string GuiStringHorizontal() { int itemMaxLength = 20; StringBuilder sb = new StringBuilder(); sb.Append($"Name: {Name.PadRight(itemMaxLength).Substring(0, itemMaxLength)} | Health: {HP,6:n0} / {MaxHP,-6:n0}\n"); sb.Append($"Weapon: {Weapon.GuiString().PadRight(itemMaxLength).Substring(0, itemMaxLength)} | Armor: {Armor.GuiString().PadRight(itemMaxLength).Substring(0, itemMaxLength)}\n"); if (IsHumanoid) { sb.Append($"{TextUtils.Columnize("Items:", TextUtils.WordWrap(Inventory.GuiStringHorizontal(), 60), 2)}\n"); } sb.Append($"Status: {GuiStatusHorizontal()}"); return(sb.ToString()); }
public string GetFullInGameView() { StringBuilder sb = new StringBuilder(); sb.Append(Environment.NewLine).Append(TextUtils.Borderize(GuiStringHorizontal(), margin: 2)); sb.Append(Environment.NewLine).Append(TextUtils.Columnize( TextUtils.Borderize(Location.Name, 20), TextUtils.WordWrap(Location.GetDescription(this), 48), centerMargin: 4 )); sb.Append(Environment.NewLine); AssignActions(); if (actions.Count > 0) { sb.Append(Environment.NewLine).Append(TextUtils.GetOptionsMenuString(actions)); } sb.Append(Environment.NewLine).Append($"Notifications:\n{TextUtils.Borderize(TextUtils.WordWrap(GetNotifications(), 72), 72)}"); sb.Append(Environment.NewLine); return(sb.ToString()); }
public static string GetPrefabUnitList() { return(TextUtils.Borderize(TextUtils.Columnize(TextUtils.GetStringListFromEnum <UnitType>(numbered: true)))); }
private static void HandleKeyInput(ConsoleKey key) { bool subdueMenuRepeat = false; if (!GameEngine.Running) { switch (key) { case ConsoleKey.X: case ConsoleKey.Q: WriteLine("Exiting..."); done = true; break; case ConsoleKey.S: GameTask = Task.Factory.StartNew(() => LaunchGameWithThreadName()); while (!GameEngine.Running) { Thread.Sleep(100); } break; case ConsoleKey.L: GameTask = Task.Factory.StartNew(() => LaunchGameWithThreadName()); while (!GameEngine.Running) { Thread.Sleep(100); } GameEngine.PlayAsServer(); break; case ConsoleKey.K: GameTask = Task.Factory.StartNew(() => LaunchGameWithThreadName(false)); while (!GameEngine.Running) { Thread.Sleep(100); } GameEngine.PlayAsServer(); break; case ConsoleKey.C: StandaloneClient.RunClient(); break; case ConsoleKey.D: StandaloneClient.RunClient("dstults.net", 11111); break; default: subdueMenuRepeat = true; break; } } else { switch (key) { case ConsoleKey.X: case ConsoleKey.Q: WriteLine("Exiting..."); GameEngine.Shutdown(); GameTask.Wait(); done = true; break; case ConsoleKey.S: WriteLine(WorldMap.GetLocationList()); Write($" Where? > "); Location unitLoc = WorldMap.GetLocation(Console.ReadLine()); if (unitLoc == null) { WriteLine("Invalid location name"); break; } WriteLine(Prefabs.GetPrefabUnitList()); Write($" What unit? > "); Player myUnit = Prefabs.SpawnUnitAtLocation(Console.ReadLine(), unitLoc); if (myUnit != null) { WriteLine($"Playable unit [{myUnit.Name}] spawned at [{unitLoc.Name}]."); } else { WriteLine($"Invalid unit type or incomplete unit creation."); } break; case ConsoleKey.I: WriteLine(WorldMap.GetLocationList()); Write($" Where? > "); Location itemLoc = WorldMap.GetLocation(Console.ReadLine()); if (itemLoc == null) { WriteLine("Invalid location name"); break; } WriteLine(Prefabs.GetPrefabItemList()); Write($" What item? > "); Item myItem = Prefabs.SpawnItemAtLocation(Console.ReadLine(), itemLoc); if (myItem != null) { WriteLine($"Item [{myItem.Title}] spawned at [{itemLoc.Name}]."); GameEngine.SayToLocation(itemLoc, $"All of the sudden {myItem.SetName()} appears!"); } else { WriteLine($"Invalid item name."); } break; case ConsoleKey.P: WriteLine("Polling current clients:"); WriteLine(NetworkServer.GetConnectionPolling(verbose: true, detailed: false)); break; case ConsoleKey.D: WriteLine("Polling current clients (detailed):"); WriteLine(NetworkServer.GetConnectionPolling(verbose: true, detailed: true)); break; case ConsoleKey.G: WriteLine(GameEngine.GameInfo()); break; case ConsoleKey.V: WriteLine(TextUtils.Borderize(TextUtils.Columnize(TextUtils.GetCustomListFromNamedList(GameEngine.Players, numbered: true, lowered: true)))); Write($" ? (1-{GameEngine.Players.Count}) > "); Player viewPlayer = GameEngine.GetPlayer(Console.ReadLine()); if (viewPlayer != null) { WriteLine("\n================================================================"); WriteLine(viewPlayer.GetFullInGameView()); } else { WriteLine("No such player."); } break; case ConsoleKey.O: WriteLine(TextUtils.Borderize(TextUtils.Columnize(TextUtils.GetCustomListFromNamedList(GameEngine.Players, numbered: true, lowered: true)))); Write($" ? (1-{GameEngine.Players.Count}) > "); Player possessPlayer = GameEngine.GetPlayer(Console.ReadLine()); if (possessPlayer != null) { GameEngine.PlayAsServer(possessPlayer); } else { WriteLine("No such player."); } break; case ConsoleKey.Z: GameEngine.TogglePause(); break; default: subdueMenuRepeat = true; break; } } if (!subdueMenuRepeat && !done) { ShowMenu(); } }