protected override void OnDeath(dynamic sourceObject = null) { // Explosions Explosion explosion = new Explosion(Game, 100); explosion.Position = Position; Game.Layer_OtherAbove.AddChild(explosion); explosion = new Explosion(Game, 60); explosion.Position = Utils.GetPointInDirection(Position, Rotation, 40); Game.Layer_OtherAbove.AddChild(explosion); explosion = new Explosion(Game, 60); explosion.Position = Utils.GetPointInDirection(Position, Rotation, -40); Game.Layer_OtherAbove.AddChild(explosion); // Deploy Rowboats if (AmountOfInfantry <= 6 || (AI != null && ((ShipAI)AI).ReachedBeach)) { base.OnDeath((object)sourceObject); return; } int amountOfRowboats = Utils.RandomInt(0, 2); for (int i = 0; i < amountOfRowboats; i++) { Rowboat rowboat = (Rowboat)Game.AIManager.SpawnEnemy(AIManager.TYPE_ROWBOAT, Utils.GetPointInDirection(Position, i == 0 ? 90 : -90, 100)); rowboat.Rotation = Rotation; } base.OnDeath((object)sourceObject); }
protected override void OnWaypointReached() { base.OnWaypointReached(); // Chance to step on landmine PossibleLandmineCount++; if (AlreadyAvoidedLandmine || PossibleLandmineCount < PossibleLandmineAtWaypoint) return; if (Game.Player != null && Game.Player.LandmineExplosionChance != 0 && Utils.RandomInt(1, 100) <= Game.Player.LandmineExplosionChance) { Explosion explosion = new Explosion(Game, 8); explosion.Position = Obj.Position; Game.Layer_Other.AddChild(explosion); Obj.Damage(Obj.Health, 0, Game.Player); } AlreadyAvoidedLandmine = true; }
protected override void OnDeath(dynamic sourceObject = null) { base.OnDeath((object)sourceObject); // Explosions Explosion explosion = new Explosion(Game, 60); explosion.Position = Position; Game.Layer_OtherAbove.AddChild(explosion); }
/// <param name="radius">If left at -1, will use ExplosionRadius.</param> /// <param name="directCall">If true, will not credit kill or activate pick-ups.</param> public override void Explode(Vector2f pos, float radius = -1, bool directCall = false) { if (radius == -1) { radius = ExplosionRadius; } // Collision bool hitSomething = false; int numChildren = Game.Layer_Objects.NumChildren; for (int i = 0; i < numChildren; i++) { dynamic obj = Game.Layer_Objects.GetChildAt(i); if (obj is PhysicalEntity && !obj.CanTakeDamage) { continue; } if ((!(obj is CollisionEntity) || obj.Collision == null) && !Utils.InCircle(pos, radius, obj.Position)) // Collide with Position if obj is not a CollisionEntity or has no Collision { continue; } if (obj.Collision is CircleShape && !Utils.CircleCircleCollision(pos, radius, obj.Position, obj.Collision.Radius)) { continue; } if (obj.Collision is RectangleShape && !Utils.CircleRectangleCollision(pos, radius, obj.Collision, obj.Rotation, obj.Position)) { continue; } if (obj is PhysicalEntity) { // Damage obj.Damage(Damage, 0, !directCall ? SourceObject : null); } else if (!directCall && obj is Pickup) { // Pickup obj.Activate(SourceObject); } // Removed? if (obj.Parent != Game.Layer_Objects && i <= numChildren - 1) { i--; numChildren--; } hitSomething = true; } if (hitSomething || Utils.InCircle(Game.Island, pos)) { // Explosion Explosion explosion = new Explosion(Game, radius); explosion.Position = pos; Game.Layer_OtherAbove.AddChild(explosion); // Sound if (Utils.RandomInt() == 0) { ExplosionSound1.Play(); } else { ExplosionSound2.Play(); } } else { // Splash Explosion explosion = new Explosion(Game, 15); explosion.Position = pos; Game.Layer_OtherAbove.AddChild(explosion); // Sound if (Utils.RandomInt() == 0) { SplashSound1.Play(); } else { SplashSound2.Play(); } } if (directCall || Game.Player == null) { return; } if (hitSomething) { Game.Player.IncreaseScoreMultiplier(); } else if (!Game.Player.HasPowerup(Powerup.TRIPLE_CANNON) && !Game.Player.HasPowerup(Powerup.OCTUPLE_CANNON)) { Game.Player.ResetScoreMultiplier(); } }
/// <param name="radius">If left at -1, will use ExplosionRadius.</param> /// <param name="directCall">If true, will not credit kill or activate pick-ups.</param> public override void Explode(Vector2f pos, float radius = -1, bool directCall = false) { if (radius == -1) radius = ExplosionRadius; // Collision bool hitSomething = false; int numChildren = Game.Layer_Objects.NumChildren; for (int i = 0; i < numChildren; i++) { dynamic obj = Game.Layer_Objects.GetChildAt(i); if (obj is PhysicalEntity && !obj.CanTakeDamage) continue; if ((!(obj is CollisionEntity) || obj.Collision == null) && !Utils.InCircle(pos, radius, obj.Position)) // Collide with Position if obj is not a CollisionEntity or has no Collision continue; if (obj.Collision is CircleShape && !Utils.CircleCircleCollision(pos, radius, obj.Position, obj.Collision.Radius)) continue; if (obj.Collision is RectangleShape && !Utils.CircleRectangleCollision(pos, radius, obj.Collision, obj.Rotation, obj.Position)) continue; if (obj is PhysicalEntity) { // Damage obj.Damage(Damage, 0, !directCall ? SourceObject : null); } else if (!directCall && obj is Pickup) { // Pickup obj.Activate(SourceObject); } // Removed? if (obj.Parent != Game.Layer_Objects && i <= numChildren - 1) { i--; numChildren--; } hitSomething = true; } if (hitSomething || Utils.InCircle(Game.Island, pos)) { // Explosion Explosion explosion = new Explosion(Game, radius); explosion.Position = pos; Game.Layer_OtherAbove.AddChild(explosion); // Sound if (Utils.RandomInt() == 0) ExplosionSound1.Play(); else ExplosionSound2.Play(); } else { // Splash Explosion explosion = new Explosion(Game, 15); explosion.Position = pos; Game.Layer_OtherAbove.AddChild(explosion); // Sound if (Utils.RandomInt() == 0) SplashSound1.Play(); else SplashSound2.Play(); } if (directCall || Game.Player == null) return; if (hitSomething) Game.Player.IncreaseScoreMultiplier(); else if (!Game.Player.HasPowerup(Powerup.TRIPLE_CANNON) && !Game.Player.HasPowerup(Powerup.OCTUPLE_CANNON)) Game.Player.ResetScoreMultiplier(); }