Ejemplo n.º 1
0
 public void HandleEnemyProjectileHittingPlayer(Player player, Projectile projectile, ParticleManager particleManager)
 {
     // if hitting the player
     if (projectile.BoundingBoxes[0].Intersects(player.BoundingBoxes[0]))
     {
         projectile.ToBeDestroyed = true;
         player.GetHit(projectile.Damage);
         particleManager.Burst(player.Transform.Position, new Vector2(2, 2), Color.Red, 25, Vector2.One);
         SceneManager.SoundManager.PlaySound("hit", 0.05f, 0.0f, 0.0f);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the collision between an enemy and a projectile created by the player
        /// </summary>
        /// <param name="player"></param>
        /// <param name="enemy"></param>
        public void HandlePlayerProjectileAttackEnemyCollision(Player player, Projectile projectile, Enemy enemy, ParticleManager particleManager)
        {
            // if player weapon intersects enemy bounding box
            switch (enemy.Name)
            {
            // if it's a bat just check the regular bounding box
            case "bat":
            case "babyfishdemon":
            case "gargoyle":
                if (projectile.BoundingBoxes[0].Intersects(enemy.BoundingBoxes[0]))
                {
                    HandleEnemyGettingHitByProjectile(player, projectile, enemy, new Vector2(5, 0));
                    particleManager.Burst(enemy.Transform.Position, new Vector2(3, 3), Color.Red, 25, Vector2.One);
                }
                break;

            case "mushroomminion":
            case "skulldemon":
                if (projectile.BoundingBoxes[0].Intersects(enemy.BoundingBoxes[0]))
                {
                    HandleEnemyGettingHitByProjectile(player, projectile, enemy, new Vector2(1, 0));
                    particleManager.Burst(enemy.Transform.Position, new Vector2(3, 3), Color.Red, 25, Vector2.One);
                }
                break;

            case "mushroomboss":
                foreach (Rectangle box in enemy.BoundingBoxes)
                {
                    if (projectile.BoundingBoxes[0].Intersects(box))
                    {
                        HandleEnemyGettingHitByProjectile(player, projectile, enemy, new Vector2(0, 0));
                        particleManager.Burst(projectile.Transform.Position, new Vector2(3, 3), Color.DarkSlateBlue, 100, Vector2.One);
                    }
                }
                break;
            }
        }