Esempio n. 1
0
        public Entities Build(int number, int height, int width)
        {
            var    Dico = new Dictionary <string, Entity>(number);
            Entity CreatedEntity;
            var    Entities = new Entities();
            var    Rng      = new Random();
            var    ObsCol   = new CollisionObserver(Entities);
            string key;

            while (number-- > 0)
            {
                key = Guid.NewGuid().ToString();
                if (Rng.Next() % 2 == 0)
                {
                    CreatedEntity = new Pigeon(Rng.Next() % width, Rng.Next() % height, key, ObsCol);
                    if (Rng.Next() % 2 == 0)
                    {
                        CreatedEntity = new PacificPigeonDecorator((Pigeon)CreatedEntity);
                    }
                }
                else
                {
                    CreatedEntity = new Rat(Rng.Next() % width, Rng.Next() % height, key, ObsCol);
                }
                Dico.Add(key, CreatedEntity);
            }

            Entities.AllEntities = Dico;

            return(new Entities(Dico));
        }
Esempio n. 2
0
        public Entities Build(int number, int height, int width)
        {
            int    tmpRng;
            var    Dico     = new Dictionary <string, Entity>(number);
            var    Entities = new Entities();
            var    Rng      = new Random();
            var    ObsCol   = new CollisionObserver(Entities);
            Entity CreatedEntity;
            string key;

            while (number-- > 0)
            {
                tmpRng = Rng.Next() % 3;
                key    = Guid.NewGuid().ToString();

                switch (tmpRng)
                {
                case 0:
                    CreatedEntity = new Zombie(Rng.Next() % width, Rng.Next() % height, key, ObsCol);
                    break;

                case 1:
                    CreatedEntity = new Pigeon(Rng.Next() % width, Rng.Next() % height, key, ObsCol);
                    if (Rng.Next() % 2 == 0)
                    {
                        CreatedEntity = new PacificPigeonDecorator((Pigeon)CreatedEntity);
                    }
                    break;

                case 2:
                default:
                    CreatedEntity = new Rat(Rng.Next() % width, Rng.Next() % height, key, ObsCol);
                    break;
                }
                Dico.Add(key, CreatedEntity);
            }

            Entities.AllEntities = Dico;

            return(Entities);
        }
Esempio n. 3
0
 public Pigeon(int x, int y, string key, CollisionObserver obs) : base(x, y, key, obs)
 {
     Token = 'P';
 }
Esempio n. 4
0
 protected Entity(int x, int y, string key, CollisionObserver collisionObserver)
 {
     CollisionObserver = collisionObserver;
     Position          = new Tuple <int, int>(x, y);
     Key = key;
 }
Esempio n. 5
0
 public Rat(int x, int y, string key, CollisionObserver obs) : base(x, y, key, obs)
 {
     Token = 'R';
 }
Esempio n. 6
0
 public Zombie(int x, int y, string key, CollisionObserver obs) : base(x, y, key, obs)
 {
     Token = 'Z';
 }