Exemplo n.º 1
0
 public void Write()
 {
     foreach (var l in log)
     {
         CString.Write(l); Console.WriteLine();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Draws this <see cref="Map"/> to the console stream.
        /// </summary>
        /// <param name="Clear">Indicates wether to clear the console before writing to it.</param>
        public void DrawToConsole(bool Clear = false)
        {
            Program.gamelog.AddLog("Drawing the map to Console");
            if (Clear)
            {
                Console.Clear();
            }
            List <CString> strings = new List <CString>();

            strings.Add(new CString());
            for (int j = 0; j < Height; j++)
            {
                for (int i = 0; i < Width; i++)
                {
                    /*if (Locations[i, j].OnIt == Occupition.Food)
                     *  Console.ForegroundColor = FoodColor;
                     * else
                     * if (Locations[i, j].OnIt == Occupition.Snake)
                     *  Console.ForegroundColor = SnakeColor;
                     * else
                     *  if(Console.ForegroundColor!= ConsoleColor.White)
                     *  Console.ForegroundColor = ConsoleColor.White;*/
                    var color = GetColor(Locations[i, j].OnIt);
                    if (strings[strings.Count - 1].Color == color)
                    {
                        strings[strings.Count - 1] += DrawChar;
                    }
                    else
                    {
                        strings.Add(new CString(DrawChar, color));
                    }
                }
                strings.Add(new CString("*\n", ConsoleColor.Blue));
            }
            strings.Add(new CString(Multiply('*', Width + 1), ConsoleColor.Blue));
            CString.Write(strings);
            Program.gamelog.AddLog("Finished drawing the map");
        }