Exemplo n.º 1
0
 public void HandleCollisions(Player player)
 {
     for (int i = 0; i < pickups.Count;)
     {
         if (player.DamageRectangle.Intersects(pickups.ElementAt(i).CollisionRectangle))
         {
             player.CollectPickup(pickups.ElementAt(i));
             pickups.Remove(pickups.ElementAt(i));
         }
         else
         {
             i++;
         }
     }
 }
Exemplo n.º 2
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

            frontParticleSystem = new ParticleSystem();
            entityParticleSystem = new ParticleSystem();
            particleTools = new ParticleTools(frontParticleSystem, entityParticleSystem, Content);
            player = new Player(Content, particleTools, Units.TileToGame(ScreenWidth / 2), Units.TileToGame(ScreenHeight / 2));
            damageTexts.AddDamageable(player);
            bat = new FirstCaveBat(Content, Units.TileToGame(7), Units.TileToGame(ScreenHeight / 2 + 1));
            damageTexts.AddDamageable(bat);
            map = Map.CreateSlopeTestMap(Content);

            pickups.Add(new PowerDoritoPickup(Content, bat.CenterX, bat.CenterY, PowerDoritoPickup.SizeType.Medium));
            pickups.Add(new PowerDoritoPickup(Content, bat.CenterX, bat.CenterY, PowerDoritoPickup.SizeType.Medium));
            pickups.Add(new PowerDoritoPickup(Content, bat.CenterX, bat.CenterY, PowerDoritoPickup.SizeType.Medium));
            base.LoadContent();
        }