public void Execute(Collision collision)
        {
            IProjectile projectile = (IProjectile)collision.Collider;
            IItem       item       = (IItem)collision.Collidee;

            IPlayer player;

            switch (projectile)
            {
            case Boomerang _:
                player = ((Boomerang)projectile).Player;
                CollisionHandlerUtil.HandlePlayerPickupItem(game, player, item);
                break;

            case Arrow _:
                if (item.GetType() == typeof(Fairy))
                {
                    player = ((Arrow)projectile).Player;
                    CollisionHandlerUtil.HandlePlayerPickupItem(game, player, item);
                }
                break;
            }

            if (!projectile.GetType().Equals(typeof(SwordBeam)) && !projectile.GetType().Equals(typeof(EnemyBoomerang)) && !projectile.GetType().Equals(typeof(Fireballs)) && !(projectile is PortalProjectile) && !(projectile is CandleFire))
            {
                AudioManager.PlayItemSound(item);
            }
        }
Esempio n. 2
0
        public void Execute(Collision collision)
        {
            IPlayer player = (IPlayer)collision.Collider;
            IItem   item   = (IItem)collision.Collidee;

            if (!(player.GetType() == typeof(Player2) && game.Mode == 2))
            {
                CollisionHandlerUtil.HandlePlayerPickupItem(game, player, item);

                AudioManager.PlayItemSound(item);
            }
        }