Add a per distance detonation sequence for bombs
This commit is contained in:
@@ -60,27 +60,31 @@ namespace Services
|
||||
|
||||
processed.Add(bombPos);
|
||||
|
||||
int neighborDelayMs = Mathf.Max(0, Mathf.RoundToInt(bombDelaySeconds * 1000f));
|
||||
if (neighborDelayMs > 0)
|
||||
await UniTask.Delay(neighborDelayMs);
|
||||
int ringDelayMs = Mathf.RoundToInt(bombDelaySeconds * 1000f);
|
||||
|
||||
foreach (Vector2Int n in DiamondNeighbors(bombPos, radius))
|
||||
for (int dist = 1; dist <= radius; dist++)
|
||||
{
|
||||
if (!inBounds(n))
|
||||
continue;
|
||||
if (ringDelayMs > 0)
|
||||
await UniTask.Delay(ringDelayMs);
|
||||
|
||||
Gem g = getGemAt(n);
|
||||
if (g == null)
|
||||
continue;
|
||||
|
||||
if (g.Type == GemType.Bomb)
|
||||
foreach (Vector2Int n in DiamondRing(bombPos, dist))
|
||||
{
|
||||
if (!processed.Contains(n))
|
||||
queue.Enqueue(n);
|
||||
continue;
|
||||
}
|
||||
if (!inBounds(n))
|
||||
continue;
|
||||
|
||||
await destroyAtAsync(n);
|
||||
Gem g = getGemAt(n);
|
||||
if (g == null)
|
||||
continue;
|
||||
|
||||
if (g.Type == GemType.Bomb)
|
||||
{
|
||||
if (!processed.Contains(n))
|
||||
queue.Enqueue(n);
|
||||
continue;
|
||||
}
|
||||
|
||||
await destroyAtAsync(n);
|
||||
}
|
||||
}
|
||||
|
||||
int selfDelayMs = Mathf.Max(0, Mathf.RoundToInt(bombSelfDelaySeconds * 1000f));
|
||||
@@ -93,17 +97,19 @@ namespace Services
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<Vector2Int> DiamondNeighbors(Vector2Int center, int radius)
|
||||
private static IEnumerable<Vector2Int> DiamondRing(Vector2Int center, int distance)
|
||||
{
|
||||
for (int x = -radius; x <= radius; x++)
|
||||
for (int distanceX = -distance; distanceX <= distance; distanceX++)
|
||||
{
|
||||
int maxY = radius - Mathf.Abs(x);
|
||||
for (int y = -maxY; y <= maxY; y++)
|
||||
int distanceY = distance - Mathf.Abs(distanceX);
|
||||
if (distanceY == 0)
|
||||
{
|
||||
if (x == 0 && y == 0)
|
||||
continue;
|
||||
|
||||
yield return new Vector2Int(center.x + x, center.y + y);
|
||||
yield return new Vector2Int(center.x + distanceX, center.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new Vector2Int(center.x + distanceX, center.y + distanceY);
|
||||
yield return new Vector2Int(center.x + distanceX, center.y - distanceY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ namespace Services {
|
||||
if (this.gemTypeToPools[type].Count > 0) {
|
||||
gemView = this.gemTypeToPools[type].Pop();
|
||||
|
||||
|
||||
gemView.transform.localPosition = vector2Position;
|
||||
return gemView;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user