private void ExplosionCalculate(ICelestialObject celestialObject, GameSession gameSession, EngineSettings settings) { if (!(celestialObject is Missile missile)) { return; } Logger.Debug($"Missile {missile.Id} from spaceship {missile.OwnerId}"); var target = gameSession.GetCelestialObject(missile.TargetId).ToSpaceship(); var distance = GeometryTools.Distance(celestialObject.GetLocation(), target.GetLocation()); if (!(distance < celestialObject.Speed)) { return; } Logger.Info($"Missile {missile.Id} from spaceship {missile.OwnerId} hit to spaceship {target.Id}"); target.Damage(missile.Damage); _explodedMissiles.Add(celestialObject); var explosion = new Explosion(gameSession.Turn, target.Id) { OwnerId = celestialObject.OwnerId, PositionX = target.PositionX, PositionY = target.PositionY }; _addedExplosions.Add(explosion); var newGameEvent = new GameEvent { Type = GameEventTypes.ExplosionResult, Turn = gameSession.Turn + 1, IsPause = true, IsOpenWindow = true }; newGameEvent.GenericObjects.Add(new GameEventParameter(GameEventParameterTypes.OwnerId, missile.OwnerId)); newGameEvent.GenericObjects.Add(new GameEventParameter(GameEventParameterTypes.TargetId, missile.TargetId)); newGameEvent.GenericObjects.Add(new GameEventParameter(GameEventParameterTypes.ModuleId, missile.ModuleId)); newGameEvent.GenericObjects.Add(new GameEventParameter(GameEventParameterTypes.ActionId, missile.ActionId)); newGameEvent.GenericObjects.Add(new GameEventParameter(GameEventParameterTypes.Dice, missile.Dice)); newGameEvent.GenericObjects.Add(new GameEventParameter(GameEventParameterTypes.Damage, missile.Damage)); newGameEvent.GenericObjects.Add(new GameEventParameter(GameEventParameterTypes.Chance, missile.Chance)); if ((int)missile.Damage == 0) { newGameEvent.GenericObjects.Add(new GameEventParameter(GameEventParameterTypes.Result, "MISS")); } if (missile.Damage > 0) { newGameEvent.GenericObjects.Add(target.Shields > 0 ? new GameEventParameter(GameEventParameterTypes.Result, "HIT") : new GameEventParameter(GameEventParameterTypes.Result, "DESTROYED")); } gameSession.AddEvent(newGameEvent); }