Example #1
0
        // constructor
        public Collection()
        {
            initialPositions = new Vector2[] { 
                new Vector2(0, 0), 
                new Vector2(Game1.WIDTH - Entity.SIZE, 0), 
                new Vector2(0, Game1.HEIGHT - Entity.SIZE), 
                new Vector2(Game1.WIDTH - Entity.SIZE, Game1.HEIGHT - Entity.SIZE) 
            };
           
            entities = new List<Entity>();
            players = new List<Player>();
            enemies = new List<Enemy>();
            trails = new List<Trail>();

            List<Texture2D> sprites = new List<Texture2D>();
            Player player;
            for (int i = 0; i < NUM_OF_PLAYERS; i++)
            {
                player = new Player(initialPositions[i], i, (i + 1) % NUM_OF_PLAYERS);
                entities.Add(player);
                trails.Add(new Trail(ref player));
            }

            players = entities.Where(i => i.GetType() == typeof(Player)).ToList().Cast<Player>().ToList();
        
            // adds the AI objects
            for (int i = 0; i < NUM_OF_ENEMIES; i++)
            {
                Enemy enemy = new Enemy(Game1.random.Next(4));
                entities.Add(enemy);
            }

            enemies = entities.Where(i => i.GetType() == typeof(Enemy)).ToList().Cast<Enemy>().ToList();
        }
Example #2
0
        public Trail(ref Player player)
        {
            mPlayer = player;
            bound = new Rectangle(0, 0, Entity.SIZE, Entity.SIZE);

            positions = new List<Vector2>();
            sources = new List<Rectangle>();
            directions = new List<int>();

            for (int i = 0; i < SIZE; i++)
            {
                positions.Add(Vector2.Zero);
                sources.Add(player.Ani.source);
                directions.Add(0);
            }

            timer = new Counter(DELAY);
        }
Example #3
0
  public void setEntities(Player.STATE state)
 {
     players.ForEach(player => player.state = state);
 }