示例#1
0
        public void Start()
        {
            Console.CursorVisible = false;
            string[,] sizeOfTown  = new string[25, 100]; // Världen

            ThisWorld = new World(sizeOfTown);

            for (int i = 0; i <= 10; i++) // Lägga till T [Samma för de två for loopar där nere fast för P och M]
            {
                thief = new Thief(placement.Next(0, 100), placement.Next(0, 25));
                thieves.Add(thief);
            }

            for (int i = 0; i <= 20; i++)
            {
                police = new Police(placement.Next(0, 100), placement.Next(0, 25));
                polices.Add(police);
            }

            for (int i = 0; i <= 30; i++)
            {
                pedestrian = new Pedestrian(placement.Next(0, 100), placement.Next(0, 25));
                pedestrians.Add(pedestrian);
            }



            RunLoop();
        }
示例#2
0
        public City(int column, int row, int citizens, int police, int thieves)
        {
            TheCity = new char[row, column];

            for (row = 0; row <= TheCity.GetUpperBound(0); row++)
            {
                for (column = 0; column <= TheCity.GetUpperBound(1); column++)
                {
                    TheCity[row, column] = ' ';
                }
            }

            Person person;

            for (int i = 1; i <= citizens; i++)
            {
                person = new Citizen(this, ThePersonList, false);
                ThePersonList.Add(person);
            }
            for (int i = 1; i <= police; i++)
            {
                person = new Police(this, ThePersonList);
                ThePersonList.Add(person);
            }
            for (int i = 1; i <= thieves; i++)
            {
                person = new Thief(this, ThePersonList);
                ThePersonList.Add(person);
            }

            PlacePersons();
        }
 private static char[,] PopulateGameboard(List <Person> people, List <string> events, char[,] gameBoard, List <Thief> prison)
 {
     foreach (Person person in people)
     {
         char c = person switch
         {
             Cop cop => 'P',
             Thief thief => 'T',
             Citizen citizen => 'M',
                     _ => 'N'
         };
         if (person is Thief thief1 && thief1.LokeckedUp > 0)
         {
             thief1.LokeckedUp--;
             if (thief1.LokeckedUp == 0)
             {
                 prison.Remove(thief1);
                 events.Add("Theif is out of prison");
             }
         }