Пример #1
0
        static void Main(string[] args)
        {
            var parser = ParserValue();

            if (!parser.Succeeded)
            {
                Console.WriteLine(String.Join(Environment.NewLine, parser.Errors));
                Console.ReadLine();
                return;
            }

            ForestModel model;
            var         createResult = ForestModel.Create(f, p, height, width);

            if (!createResult.Succeeded)
            {
                Console.WriteLine(string.Join(Environment.NewLine, createResult.Errors));
            }
            else
            {
                Console.OutputEncoding = System.Text.Encoding.GetEncoding(1252);
                model = createResult.Value;
                timer = new Timer(new TimerCallback(Drawing), model, 0, interval);
            }

            Console.ReadLine();
        }
Пример #2
0
        public static void Drawing(Object model)
        {
            ForestModel forest = (ForestModel)model;

            Console.Clear();

            for (int y = 0; y < forest.HeightMap; y++)
            {
                Console.WriteLine("");
                for (int x = 0; x < forest.WidthMap; x++)
                {
                    switch (forest.GetState()[y, x])
                    {
                    //Пустое поле
                    case State.Empty:
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.Write($"•  ");
                        break;

                    //Поле с деревом
                    case State.Tree:
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write($"¥  ");
                        break;

                    //Поле с горящим деревом
                    case State.Fire:
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write($"Ï  ");
                        break;
                    }
                }
            }

            forest.Step();
        }