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); } }
public void Execute(Collision collision) { IEnemy enemy = (IEnemy)collision.Collider; IPlayer player = (IPlayer)collision.Collidee; if (enemy is OldMan) { // do nothing } else if (enemy is Hand) { int damage = CollisionHandlerUtil.GetEnemyDamage(enemy.GetType()); player.ReceiveDamage(damage, new Vector2(0, 0)); if (player.PlayerInventory.HalfHeartCount != 0) { game.SetState(new GameStateWallmaster(game, player)); } } else { int damage = CollisionHandlerUtil.GetEnemyDamage(enemy.GetType()); player.ReceiveDamage(damage, CompassDirectionUtil.GetOppositeDirectionVector(collision.Side)); } }
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); } }