コード例 #1
0
        public static List <Person> CreatePeople(int height, int width)
        {
            int           numberOfPeople = 8; //just a random number added for simplification conmtrols the amount of citizen,police,thieves where the amount of each type is equal.
            Random        rnd            = new Random();
            List <Person> people         = new List <Person>();

            for (int i = 0; i < numberOfPeople; i++)
            {
                Thief thief = new Thief
                {
                    PositionX = rnd.Next(0 + 1, width - 1), //rand initial position
                    PositionY = rnd.Next(0 + 1, height - 1),
                    Inventory = new List <Item>(),
                };
                people.Add(thief);

                Citizen citizen = new Citizen
                {
                    PositionX = rnd.Next(0 + 1, width - 1),
                    PositionY = rnd.Next(0 + 1, height - 1),
                    Inventory = new List <Item>()

                    {
                        Item.Phone,
                        Item.Watch,
                        Item.Money,
                        Item.Keys,
                    }
                };
                people.Add(citizen);

                Police police = new Police
                {
                    PositionX = rnd.Next(0 + 1, width - 1),
                    PositionY = rnd.Next(0 + 1, height - 1),
                    Inventory = new List <Item>()
                };
                //no cond that prevents objects to generate with the same x,ycoord
                people.Add(police);
            }
            return(people);
        }
コード例 #2
0
 public void HandlePrison(Thief arrested) //no timefunction added
 {
     arrested.TimeInJail = 30000;
     arrested.TimeServed();
     Prison.Add(arrested);
 }