public void Execute(Collision collision) { IProjectile proj = (IProjectile)collision.Collider; IPlayer player = (IPlayer)collision.Collidee; switch (proj) { case EnemyBoomerang _: if (player.GetDirection() != CompassDirectionUtil.GetDirectionCharCaps(collision.Side)) { player.ReceiveDamage(boomerangDamage, CompassDirectionUtil.GetOppositeDirectionVector(collision.Side)); } else { AudioManager.PlayFireForget(shield); } proj.BeginDespawn(); break; case Fireballs _: player.ReceiveDamage(fireballDamage, CompassDirectionUtil.GetOppositeDirectionVector(collision.Side)); proj.BeginDespawn(); break; case CandleFire _: player.ReceiveDamage(fireballDamage, CompassDirectionUtil.GetOppositeDirectionVector(collision.Side)); break; } }
public void Execute(Collision collision) { IProjectile proj = ((IProjectile)collision.Collider); IEnvironment envo = (IEnvironment)collision.Collidee; if (envo is LaserField) { proj.BeginDespawn(); } else if (envo is PortalBlock portalBlock) { PortalUtil.HandleProjectilePortal(portalBlock, proj, game.Screen); } else if (proj is BombProjectile && proj.GetHitbox().Width > bombWidth && proj.GetHitbox().Height > bombHeight) { RoomUtil.OpenBombableDoor(game.Screen, envo); } else if (!(proj is SwordBeam) && !(proj is BombProjectile)) { if (collision.IntersectionRec.X >= rightBorder || collision.IntersectionRec.X <= leftBorder || collision.IntersectionRec.Y >= bottomBorder || collision.IntersectionRec.Y <= topBorder) { proj.BeginDespawn(); } } else if (proj is Fireballs) { proj.BeginDespawn(); } }
public void Execute(Collision collision) { IProjectile proj = (IProjectile)collision.Collider; IEnemy enemy = (IEnemy)collision.Collidee; Vector2 knockbackDirect = new Vector2(0, 0); if (enemy.GetType() != typeof(Aquamentus) || proj.GetType() == typeof(Boomerang)) { knockbackDirect = CompassDirectionUtil.GetOppositeDirectionVector(collision.Side); } if (collision.Collider.GetType() == typeof(Boomerang)) { switch (enemy) { case Jelly _: case Bat _: enemy.ReceiveDamage(halfHeart, knockbackDirect); proj.BeginDespawn(); break; case Aquamentus _: break; case Dodongo _: enemy.ReceiveDamage(halfHeart, knockbackDirect); proj.BeginDespawn(); break; default: if (enemy.StunnedTimer != int.MaxValue) { enemy.StunnedTimer = boomerangStunTime; } proj.BeginDespawn(); break; } } else if (proj.GetType() == typeof(Arrow)) { enemy.ReceiveDamage(twoHearts, knockbackDirect); proj.BeginDespawn(); } else if (proj.GetType() == typeof(SwordBeam)) { enemy.ReceiveDamage(oneHeart, knockbackDirect); proj.BeginDespawn(); } else if (proj.GetType() == typeof(BombProjectile)) { if (enemy.GetType() == typeof(Dodongo) && proj.GetHitbox().Width == bombWidth && proj.GetHitbox().Height == bombHeight) { if (collision.IntersectionRec.Height < dodongoHeadHeight || collision.IntersectionRec.Width < dodongoHeadWidth) { enemy.ReceiveDamage(0f, knockbackDirect); proj.BeginDespawn(); } else { enemy.StunnedTimer = bombStunTime; proj.BeginDespawn(); } } else if (proj.GetHitbox().Width != bombWidth && proj.GetHitbox().Height != bombHeight) { enemy.ReceiveDamage(fourHearts, knockbackDirect); } } else if (proj.GetType() == typeof(CandleFire)) { enemy.ReceiveDamage(halfHeart, knockbackDirect); } }