Added delays to GameVariables
This commit is contained in:
@@ -63,6 +63,9 @@ MonoBehaviour:
|
|||||||
bombExplodeSfx: {fileID: 8300000, guid: 9dcc9b1297952c446a5571fdb2fb7a2f, type: 3}
|
bombExplodeSfx: {fileID: 8300000, guid: 9dcc9b1297952c446a5571fdb2fb7a2f, type: 3}
|
||||||
bombDelay: 2
|
bombDelay: 2
|
||||||
bombRadius: 2
|
bombRadius: 2
|
||||||
dropHeight: 2
|
dropHeight: 3
|
||||||
gemSpeed: 4
|
gemSpeed: 5
|
||||||
scoreSpeed: 3
|
scoreSpeed: 3
|
||||||
|
cascadeDelayMs: 150
|
||||||
|
swapDelayMs: 600
|
||||||
|
fillBoardDelayMs: 500
|
||||||
|
|||||||
@@ -28,5 +28,10 @@ namespace ScriptableObjects {
|
|||||||
|
|
||||||
[Header("Score")]
|
[Header("Score")]
|
||||||
public float scoreSpeed = 5;
|
public float scoreSpeed = 5;
|
||||||
|
|
||||||
|
[Header("Delays")]
|
||||||
|
public int cascadeDelayMs = 150;
|
||||||
|
public int swapDelayMs = 600;
|
||||||
|
public int fillBoardDelayMs = 250;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,14 +138,14 @@ namespace Services {
|
|||||||
|
|
||||||
ApplySwap(from, to);
|
ApplySwap(from, to);
|
||||||
|
|
||||||
await UniTask.Delay(600);
|
await UniTask.Delay(this.gameVariables.swapDelayMs);
|
||||||
this.bombService.SetLastSwap(from, to);
|
this.bombService.SetLastSwap(from, to);
|
||||||
this.matchService.FindAllMatches();
|
this.matchService.FindAllMatches();
|
||||||
this.bombService.DetectBombSpawnFromLastSwap(this.matchService.CurrentMatches);
|
this.bombService.DetectBombSpawnFromLastSwap(this.matchService.CurrentMatches);
|
||||||
|
|
||||||
if (this.matchService.CurrentMatches.Count == 0) {
|
if (this.matchService.CurrentMatches.Count == 0) {
|
||||||
ApplySwap(to, from);
|
ApplySwap(to, from);
|
||||||
await UniTask.Delay(600);
|
await UniTask.Delay(this.gameVariables.swapDelayMs);
|
||||||
this.currentState = GameState.Move;
|
this.currentState = GameState.Move;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ namespace Services {
|
|||||||
foreach (Vector2Int p in matchPositions.Distinct())
|
foreach (Vector2Int p in matchPositions.Distinct())
|
||||||
await DestroyAtAsync(p);
|
await DestroyAtAsync(p);
|
||||||
|
|
||||||
await UniTask.Delay(600);
|
await UniTask.Delay(this.gameVariables.fillBoardDelayMs);
|
||||||
|
|
||||||
await MoveGemsDown();
|
await MoveGemsDown();
|
||||||
return;
|
return;
|
||||||
@@ -249,7 +249,7 @@ namespace Services {
|
|||||||
this.scoreService.ScoreCheck(gem.ScoreValue);
|
this.scoreService.ScoreCheck(gem.ScoreValue);
|
||||||
ReleaseMatchedGems(pos);
|
ReleaseMatchedGems(pos);
|
||||||
}
|
}
|
||||||
await UniTask.Delay(250);
|
await UniTask.Delay(this.gameVariables.fillBoardDelayMs);
|
||||||
await MoveGemsDown();
|
await MoveGemsDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,27 +283,45 @@ namespace Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async UniTask MoveGemsDown() {
|
private async UniTask MoveGemsDown() {
|
||||||
int nullCounter = 0;
|
while (true)
|
||||||
|
{
|
||||||
|
// Build moves from a snapshot of the current grid state (no mid-wave chaining)
|
||||||
|
List<(Vector2Int from, Vector2Int to, Gem gem)> moves = new List<(Vector2Int, Vector2Int, Gem)>();
|
||||||
|
|
||||||
for (int x = 0; x < this.gameBoard.Width; x++)
|
for (int x = 0; x < this.gameBoard.Width; x++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < this.gameBoard.Height; y++)
|
for (int y = 1; y < this.gameBoard.Height; y++)
|
||||||
{
|
{
|
||||||
Gem currentGem = this.gameBoard.GetGemAt(new Vector2Int(x, y));
|
Vector2Int from = new Vector2Int(x, y);
|
||||||
if (currentGem == null)
|
Vector2Int to = new Vector2Int(x, y - 1);
|
||||||
{
|
|
||||||
nullCounter++;
|
Gem gem = this.gameBoard.GetGemAt(from);
|
||||||
|
if (gem == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Gem below = this.gameBoard.GetGemAt(to);
|
||||||
|
if (below != null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
moves.Add((from, to, gem));
|
||||||
}
|
}
|
||||||
else if (nullCounter > 0)
|
|
||||||
{
|
|
||||||
currentGem.SetPosition(new Vector2Int(currentGem.Position.x, currentGem.Position.y - nullCounter));
|
|
||||||
this.gameBoard.SetGemAt(currentGem.Position, currentGem);
|
|
||||||
this.gameBoard.SetGemAt(new Vector2Int(x,y), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nullCounter = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await UniTask.Delay(600);
|
if (moves.Count == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Apply all moves simultaneously for this wave
|
||||||
|
for (int i = 0; i < moves.Count; i++)
|
||||||
|
{
|
||||||
|
(Vector2Int from, Vector2Int to, Gem gem) move = moves[i];
|
||||||
|
this.gameBoard.SetGemAt(move.to, move.gem);
|
||||||
|
this.gameBoard.SetGemAt(move.from, null);
|
||||||
|
move.gem.SetPosition(move.to);
|
||||||
|
}
|
||||||
|
|
||||||
|
await UniTask.Delay(this.gameVariables.cascadeDelayMs);
|
||||||
|
}
|
||||||
|
|
||||||
await FillBoard();
|
await FillBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +330,7 @@ namespace Services {
|
|||||||
|
|
||||||
this.matchService.FindAllMatches();
|
this.matchService.FindAllMatches();
|
||||||
if (this.matchService.CurrentMatches.Count > 0) {
|
if (this.matchService.CurrentMatches.Count > 0) {
|
||||||
await UniTask.Delay(600);
|
await UniTask.Delay(this.gameVariables.fillBoardDelayMs);
|
||||||
|
|
||||||
// In cascades, there is no "creating slot" bomb protection.
|
// In cascades, there is no "creating slot" bomb protection.
|
||||||
await DestroyMatchesAsync(new List<Vector2Int>());
|
await DestroyMatchesAsync(new List<Vector2Int>());
|
||||||
@@ -359,7 +377,7 @@ namespace Services {
|
|||||||
SpawnGemGameObject(gem);
|
SpawnGemGameObject(gem);
|
||||||
|
|
||||||
if (i < groups.Count - 1)
|
if (i < groups.Count - 1)
|
||||||
await UniTask.Delay(150);
|
await UniTask.Delay(this.gameVariables.cascadeDelayMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.currentState == GameState.Setup)
|
if(this.currentState == GameState.Setup)
|
||||||
|
|||||||
Reference in New Issue
Block a user