Exemplo n.º 1
0
        public static void PrintMap(Sea map, int cursorLeft, int cursorTop)
        {
            for (int i = 0; i < map.GetLengthMapCells(0); i++)
            {
                Console.SetCursorPosition(cursorLeft, cursorTop);

                for (int j = 0; j < map.GetLengthMapCells(1); j++)
                {
                    switch (map[i, j])
                    {
                    case MapCondition.MissedShot:
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.Write($"{(char)Symbol.MissedShot} ");
                        break;

                    case MapCondition.NoneShot:
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write("- ");
                        break;

                    case MapCondition.ShipSafe:
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write($"{(char)Symbol.ShipSafe}");
                        break;

                    case MapCondition.ShipInjured:
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.Write($"{(char)Symbol.ShipInjured} ");
                        break;

                    case MapCondition.ShipDestroyed:
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write($"{(char)Symbol.DestroyedShip} ");
                        break;

                    default:
                        break;
                    }
                }
                cursorTop++;
                Console.WriteLine();
            }

            Console.CursorTop = 0;
        }