diff --git a/Assets/GameVariables.asset b/Assets/GameVariables.asset index 813415d..6691cf5 100644 --- a/Assets/GameVariables.asset +++ b/Assets/GameVariables.asset @@ -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 diff --git a/Assets/Scripts/Models/Gem.cs b/Assets/Scripts/Models/Gem.cs index 3fa3366..cbcefe8 100644 --- a/Assets/Scripts/Models/Gem.cs +++ b/Assets/Scripts/Models/Gem.cs @@ -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) { diff --git a/Assets/Scripts/Services/BombService.cs b/Assets/Scripts/Services/BombService.cs index 335b139..b4b0ea8 100644 --- a/Assets/Scripts/Services/BombService.cs +++ b/Assets/Scripts/Services/BombService.cs @@ -17,8 +17,14 @@ namespace Services if (matchPositions == null || matchPositions.Count == 0) return Array.Empty(); - HashSet candidates = new HashSet(); + + return matchPositions.Distinct().ToList(); + } + // This is the old implementation wherein any adjacent matches will detonate the bomb + private List DetonateThroughAdjacentMatches(IReadOnlyList matchPositions) { + HashSet candidates = new HashSet(); + 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(); } diff --git a/Assets/Scripts/Services/GameBoardService.cs b/Assets/Scripts/Services/GameBoardService.cs index 71fc820..345283d 100644 --- a/Assets/Scripts/Services/GameBoardService.cs +++ b/Assets/Scripts/Services/GameBoardService.cs @@ -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 bombCandidates = this.bombService.CollectTriggeredBombs(matchPositions); List initialBombs = new List(); @@ -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(); }