public GameRunUI(GameUniverse g) : base(g) { Messages = new MessageBuffer(this); Sidebar = new Sidebar(this); MapUI = new MapUI(this); MapRenderer = MapRenderer.Create(this); EscapeMenu = new EscapeMenu(this); CharacterScreens = new CharacterScreens(this); GameEventHandler = new GameEventHandler(this); UpdateSidebarOption(Option.IsSet(BoolOptionType.SidebarOnRight)); UpdateMessagesOption(Option.IsSet(BoolOptionType.MessagesAtBottom)); }
private void ChooseAction(PlayerTurnEvent e) { do { GameRunUI.DrawGameUI( sidebar: DrawOption.Normal, messages: DrawOption.Normal, environmentalDesc: DrawOption.Normal, commands: DrawOption.Normal ); MapRenderer.UpdateAllSettings(Player.Position); MapRenderer.DrawMap(e); //window update, set suspend if false... /*if(!Screen.Update()){ * GameUniverse.Suspend = true; * return; * }*/ // // if (walkDir != null) { if (Input.KeyIsAvailable) { Interrupt(); } else { Point targetPoint = Player.Position.PointInDir(walkDir.Value); if (!TileDefinition.IsPassable(TileTypeAt(targetPoint)) || CreatureAt(targetPoint) != null) { walkDir = null; } else { if (!Screen.WindowUpdate()) { Program.Quit(); } Thread.Sleep(10); //todo, make configurable e.ChosenAction = new WalkAction(Player, Player.Position.PointInDir(walkDir.Value)); return; } } } else if (Autoexplore) { if (Input.KeyIsAvailable) { Interrupt(); } else { ChooseAutoexploreAction(e); if (e.ChosenAction != null) { if (!Screen.WindowUpdate()) { Program.Quit(); } Thread.Sleep(10); //todo, make configurable } else { Interrupt("You don't see a path for further exploration. "); } return; } } else if (Path != null && NextPathIndex < Path.Count) { if (Input.KeyIsAvailable) { Interrupt(); } else { Point next = Path[NextPathIndex]; //todo check distance, walkable, etc.? Dir8 dir = Player.Position.GetDirectionOfNeighbor(next); Point pointInDir = Player.Position.PointInDir(dir); if (CreatureAt(pointInDir) != null) { Interrupt(); } else if (!TileDefinition.IsPassable(TileTypeAt(pointInDir))) { Interrupt(); // There's still more to consider regarding autoexplore AND travel destination calculation: // -do I want to make it weigh AGAINST the stairs, once they're known? // -it seems like I might want to allow some of the 'avoid this area' to _cross_ narrow bridges of known space, because // currently exploration is happy to go into a room because of ONE small unknown area, even if the OTHER side of the room is touching the large unknown area. // (that COULD be a tricky problem to solve...not sure.) // (this happens on one of the premade levels near the bottom of the map) } else { e.ChosenAction = new WalkAction(Player, Player.Position.PointInDir(dir)); NextPathIndex++; //todo, interruptedPath? (and index?) if (!Screen.WindowUpdate()) { Program.Quit(); } Thread.Sleep(10); //todo, make configurable return; } } } ConsoleKeyInfo key = Input.ReadKey(); bool shift = (key.Modifiers & ConsoleModifiers.Shift) == ConsoleModifiers.Shift; switch (key.Key) { case ConsoleKey.NumPad8: ChooseActionFromDirection(e, Dir8.N, shift); break; case ConsoleKey.NumPad6: ChooseActionFromDirection(e, Dir8.E, shift); break; case ConsoleKey.NumPad4: ChooseActionFromDirection(e, Dir8.W, shift); break; case ConsoleKey.NumPad2: ChooseActionFromDirection(e, Dir8.S, shift); break; case ConsoleKey.NumPad9: ChooseActionFromDirection(e, Dir8.NE, shift); break; case ConsoleKey.NumPad3: ChooseActionFromDirection(e, Dir8.SE, shift); break; case ConsoleKey.NumPad1: ChooseActionFromDirection(e, Dir8.SW, shift); break; case ConsoleKey.NumPad7: ChooseActionFromDirection(e, Dir8.NW, shift); break; case ConsoleKey.D: //todo, 'd' is definitely not 'descend' e.ChosenAction = new DescendAction(Player); break; case ConsoleKey.Escape: EscapeMenu.Open(); break; case ConsoleKey.I: CharacterScreens.Show(e, CharacterScreen.Inventory); break; case ConsoleKey.E: CharacterScreens.Show(e, CharacterScreen.Equipment); break; case ConsoleKey.Enter: CharacterScreens.Show(e, CharacterScreen.Actions); break; case ConsoleKey.V: CharacterScreens.Show(e, CharacterScreen.AdventureLog); break; case ConsoleKey.Tab: MapUI.LookMode(e); break; case ConsoleKey.X: MapUI.LookMode(e, true); break; } } while(e.ChosenAction == null); }
private CharacterScreen?ShowAdventureLog(PlayerTurnEvent e) { while (true) { const int rowOffset = 3; int colOffset = MapUI.ColOffset; Screen.HoldUpdates(); Screen.Clear(0, colOffset, ScreenUIMain.Rows, MapUI.MapDisplayWidth); DrawCommonSections(CharacterScreen.AdventureLog); Screen.Write(rowOffset, colOffset, "Adventure log of Charname III: "); Screen.Write(rowOffset + 1, colOffset, SeparatorBar); Screen.Write(rowOffset + 2, colOffset, "Entered the mountain pass 571 turns ago"); Screen.Write(rowOffset + 3, colOffset, "Skills: (none)"); //todo Screen.WriteListOfChoices(rowOffset + 5, colOffset, new[] { "Discovered locations", "Discovered items", "Recent messages", "Pause adventure, change options, or get help" }); Screen.Write(rowOffset + 9, colOffset, SeparatorBar); //todo, count? Screen.ResumeUpdates(); Screen.SetCursorPosition(rowOffset, colOffset + 31); ConsoleKeyInfo key = Input.ReadKey(); bool shift = (key.Modifiers & ConsoleModifiers.Shift) == ConsoleModifiers.Shift; switch (key.Key) { case ConsoleKey.Tab: if (shift) { return(CharacterScreen.Actions); } else { return(CharacterScreen.Inventory); } case ConsoleKey.Escape: case ConsoleKey.Spacebar: return(null); case ConsoleKey.Oem2: //todo check //todo help break; case ConsoleKey.A: RunDijkstraTest(); break; case ConsoleKey.B: { //todo for (int i = 0; i < GameUniverse.MapHeight; ++i) { for (int j = 0; j < GameUniverse.MapWidth; ++j) { if (dm[j, i] == DijkstraMap.Blocked || dm[j, i] == DijkstraMap.Unexplored) { continue; } dm[j, i] = (int)(-(dm[j, i]) * 1.4); } } //Map.Tiles[44, 20] = TileType.Staircase; //dm[44, 20] = 50; dm.RescanWithCurrentValues(); int min = 99999; for (int i = 0; i < GameUniverse.MapHeight; ++i) { for (int j = 0; j < GameUniverse.MapWidth; ++j) { if (dm[j, i] == DijkstraMap.Blocked || dm[j, i] == DijkstraMap.Unexplored) { continue; } if (dm[j, i] < min) { min = dm[j, i]; } } } for (int i = 0; i < GameUniverse.MapHeight; ++i) { for (int j = 0; j < GameUniverse.MapWidth; ++j) { if (dm[j, i] == DijkstraMap.Blocked || dm[j, i] == DijkstraMap.Unexplored) { continue; } dm[j, i] -= min; } } //PrintDijkstraTest(); } break; case ConsoleKey.C: break; case ConsoleKey.D: EscapeMenu.Open(false); if (GameUniverse.Suspend || GameUniverse.GameOver) { return(null); } break; } } }