private static string GetTileValue(Boards.BoardTile tile, bool enemy) { string s = " "; if (tile.Ship != null && tile.Destroyed && (!enemy || tile.Ship.HP == 0)) { s = $"{HIT[0]}{tile.Ship.Index.ToString(),BOX_WIDTH - 4}{HIT[1]}"; // known ship hits } else if (enemy && tile.Ship != null && tile.Destroyed) { s = $" {HIT,BOX_WIDTH - 4} "; // hits on unknown ships } else if (tile.Destroyed) { s = $" {MISS,BOX_WIDTH - 4} "; // missed shots } else if (!enemy && tile.Ship != null) { s = $" {tile.Ship.Index.ToString(),BOX_WIDTH - 4} "; // show shop on friendly map } else if (ShipPlacerController.Start != null && ShipPlacer.IsValidEndPoint(tile.Coords)) { s = $" {VALID_PLACE,BOX_WIDTH - 4} "; // valid end point for ship } int ws = (BOX_WIDTH - 2 - s.Length); return(s.PadLeft((int)Math.Floor((float)ws / 2) + s.Length).PadRight(ws + s.Length)); }
public static MenuNode GetMenu(this Boards.BoardTile bt) { var n = new MenuNode("__DOOT__", new List <MenuNode>() { new MenuNode("__TILE__", null, null, (m) => { var ship = bt.GetShipAs(Players.CurrentPlayer); m.SubNodes = new List <MenuNode>() { new MenuNode(PadWithSep($" {bt.Board.Player}'s base: {bt.ToString()} ")), new MenuNode(Sep), new MenuNode( (ship == null ? $" No {(bt.Board.Player == Players.CurrentPlayer ? "" : "known ")}ships at this tile" : "Ship at this tile:\n" + $"\t{ship}\n" + $"\t Condition at this tile: {(bt.Destroyed ? "destroyed" : "OK")}" )), new MenuNode(""), new MenuNode(Sep), new MenuNode("Bomb [1x1]", () => { GameUI.ShowGame(bt.Coords); AddHitMessages(bt.Board.Explode(bt.Coords, 1)); Menu.Stop = true; }), new MenuNode($"Nuke [3x3] ({Players.CurrentPlayer.Nukes} left)", () => { if (Players.CurrentPlayer.Nukes > 0) { GameUI.ShowGame(bt.Coords, 2); Players.CurrentPlayer.Nukes--; AddHitMessages(bt.Board.Explode(bt.Coords, 2)); Menu.Stop = true; } }), //new MenuNode(Sep), }; }) }); n.Selectable = false; n.SetUpdateAction((m) => Menu.Stop = true); return(n.SubNodes[0]); }
public static void OnEnter(this Boards.BoardTile bt) { Menu.CurrentNode = bt.GetMenu(); Menu.Run(); }