Adjust Bomb Behavior
This commit is contained in:
@@ -53,20 +53,9 @@ MonoBehaviour:
|
||||
scoreValue: 10
|
||||
width: 7
|
||||
height: 7
|
||||
bombColors:
|
||||
- type: 0
|
||||
color: {r: 0.02800417, g: 0, b: 1, a: 1}
|
||||
- type: 1
|
||||
color: {r: 0, g: 1, b: 0.056184053, a: 1}
|
||||
- type: 2
|
||||
color: {r: 1, g: 0, b: 0, a: 1}
|
||||
- type: 3
|
||||
color: {r: 1, g: 0.9118239, b: 0, a: 1}
|
||||
- type: 4
|
||||
color: {r: 0.9601507, g: 0, b: 1, a: 1}
|
||||
bombDelay: 0.75
|
||||
bombSelfDelay: 0.25
|
||||
bombDelay: 0.5
|
||||
bombSelfDelay: 1
|
||||
bombRadius: 2
|
||||
dropHeight: 2
|
||||
gemSpeed: 0.00625
|
||||
scoreSpeed: 1
|
||||
scoreSpeed: 3
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace Services {
|
||||
public int ScoreValue => this.scoreValue;
|
||||
|
||||
private GemType colorType;
|
||||
|
||||
public GemType MatchColor => this.type == GemType.Bomb ? this.colorType : this.type;
|
||||
|
||||
public Gem(GemType type, Vector2Int position, int scoreValue, GemType? colorType = null) {
|
||||
|
||||
@@ -17,8 +17,14 @@ namespace Services
|
||||
if (matchPositions == null || matchPositions.Count == 0)
|
||||
return Array.Empty<Vector2Int>();
|
||||
|
||||
HashSet<Vector2Int> candidates = new HashSet<Vector2Int>();
|
||||
|
||||
return matchPositions.Distinct().ToList();
|
||||
}
|
||||
|
||||
// This is the old implementation wherein any adjacent matches will detonate the bomb
|
||||
private List<Vector2Int> DetonateThroughAdjacentMatches(IReadOnlyList<Vector2Int> matchPositions) {
|
||||
HashSet<Vector2Int> candidates = new HashSet<Vector2Int>();
|
||||
|
||||
foreach (Vector2Int p in matchPositions)
|
||||
{
|
||||
candidates.Add(p + Vector2Int.left);
|
||||
@@ -26,7 +32,7 @@ namespace Services
|
||||
candidates.Add(p + Vector2Int.up);
|
||||
candidates.Add(p + Vector2Int.down);
|
||||
}
|
||||
|
||||
|
||||
return candidates.ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -193,15 +193,6 @@ namespace Services {
|
||||
matchPositions.Add(pos);
|
||||
}
|
||||
|
||||
foreach (Vector2Int pos in matchPositions.Distinct().ToList()) {
|
||||
Gem gem = GetGem(pos);
|
||||
if (gem == null) continue;
|
||||
if (gem.Type == GemType.Bomb) continue;
|
||||
|
||||
this.scoreService.ScoreCheck(gem.ScoreValue);
|
||||
DestroyMatchedGems(pos);
|
||||
}
|
||||
|
||||
IReadOnlyList<Vector2Int> bombCandidates = this.bombService.CollectTriggeredBombs(matchPositions);
|
||||
|
||||
List<Vector2Int> initialBombs = new List<Vector2Int>();
|
||||
@@ -217,7 +208,40 @@ namespace Services {
|
||||
}
|
||||
initialBombs = initialBombs.Distinct().ToList();
|
||||
|
||||
await this.bombService.DetonateChainAsync(initialBombs, InBounds, GetGem, DestroyAtAsync, this.gameVariables.bombRadius, this.gameVariables.bombDelay, this.gameVariables.bombSelfDelay);
|
||||
// If a bomb is part of the match, do NOT destroy matching pieces immediately.
|
||||
// Let the bomb's manhattan-distance explosion destroy them in sequence.
|
||||
if (initialBombs.Count > 0) {
|
||||
await this.bombService.DetonateChainAsync(
|
||||
initialBombs,
|
||||
InBounds,
|
||||
GetGem,
|
||||
DestroyAtAsync,
|
||||
this.gameVariables.bombRadius,
|
||||
this.gameVariables.bombDelay,
|
||||
this.gameVariables.bombSelfDelay);
|
||||
|
||||
await MoveGemsDown();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (Vector2Int pos in matchPositions.Distinct().ToList()) {
|
||||
Gem gem = GetGem(pos);
|
||||
if (gem == null) continue;
|
||||
if (gem.Type == GemType.Bomb) continue;
|
||||
|
||||
this.scoreService.ScoreCheck(gem.ScoreValue);
|
||||
DestroyMatchedGems(pos);
|
||||
}
|
||||
|
||||
await this.bombService.DetonateChainAsync(
|
||||
initialBombs,
|
||||
InBounds,
|
||||
GetGem,
|
||||
DestroyAtAsync,
|
||||
this.gameVariables.bombRadius,
|
||||
this.gameVariables.bombDelay,
|
||||
this.gameVariables.bombSelfDelay);
|
||||
|
||||
await MoveGemsDown();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user