public void RenderField(PlayField field)
        {
            Console.Clear();
            foreach (var person in field.GetPeople())
            {
                Console.SetCursorPosition(person.Position.X, person.Position.Y);
                if (Console.ForegroundColor != person.SymbolColor)
                {
                    Console.ForegroundColor = person.SymbolColor;
                }
                Console.Write(person.Symbol);
            }

            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(0, 0);
            Console.WriteLine($"Robberies: {field.Robberies}   Arrests: {field.Arrests}   Prisoners: {field.PeopleInPrison}");
            if (field.PeopleInPrison > 0)
            {
                Console.WriteLine($"Next release in {field.NextRelease} ticks.");
            }
        }
Beispiel #2
0
        public void Initialize(int width, int height, int citizens, int cops, int thieves)
        {
            field    = new PlayField(width, height);
            renderer = new Renderer(width, height);
            for (int i = 0; i < citizens; i++)
            {
                var citizen = new Citizen();
                foreach (Item itemType in itemTypes)
                {
                    citizen.Inventory.Add(itemType.GetCopy());
                }
                field.AddPerson(citizen);
            }

            for (int i = 0; i < cops; i++)
            {
                field.AddPerson(new Police());
            }

            for (int i = 0; i < thieves; i++)
            {
                field.AddPerson(new Thief());
            }
        }