private bool IsMoveValid(TankBlasterBot bot, BotMove move) { var newLocation = _locationService.GetNewLocation(bot.Location, move.Direction); return(_locationService.IsLocationValid(newLocation) && _field.Board[newLocation.X, newLocation.Y] == BoardTile.Empty && !_field.Bots.Any(blasterBot => blasterBot.Id != bot.Id && blasterBot.Location == newLocation)); }
private IEnumerable <Point> CalculateExplosionRay(ExplodableBase explodable, MoveDirection direction) { var currentPoint = explodable.Location; for (var i = 1; i <= explodable.ExplosionRadius; i++) { currentPoint = _locationService.GetNewLocation(currentPoint, direction); if (!_locationService.IsLocationValid(currentPoint)) { yield break; } yield return(currentPoint); if (_field.Board[currentPoint.X, currentPoint.Y] != BoardTile.Empty) { yield break; } } }