Beispiel #1
0
        public static void RenderToConsolePretty(GameMap gameMap, char playerKey)
        {
            Console.Clear();
            var render = new ConsoleRender(gameMap);

            bool insideMap = false;

            foreach (var character in render.RenderTextGameState().ToString())
            {
                if (character == '#')
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    insideMap = true;
                }
                if (character == '\t')
                {
                    insideMap = false;
                }
                if (character == '+')
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                }
                if (character == '!')
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                if (character == '&')
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                }
                if (character == '$')
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                if (character == '*')
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                }
                if (insideMap && (character == playerKey || Char.ToUpperInvariant(character) == playerKey))
                {
                    Console.ForegroundColor = ConsoleColor.Magenta;
                }

                Console.Write(character);

                Console.ResetColor();
            }
        }
        public static void RenderToConsolePretty(GameMap gameMap, PlayerType playerType)
        {
            Console.Clear();
            var render = new ConsoleRender(gameMap);
            var inMap  = false;

            foreach (var character in render.RenderTextGameState(playerType, false, true).ToString())
            {
                if (character == 'X' || character == '-')
                {
                    inMap = false;
                }
                if (character == '#')
                {
                    inMap = true;
                }
                if (character == '|')
                {
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                }
                if (character == '!')
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }
                if (character == '~' && inMap)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                if (char.IsLower(character) && inMap)
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                }
                if (char.IsUpper(character) && inMap)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                }

                Console.Write(character);

                Console.ResetColor();
            }
        }