Cleanup GameBOardService

This commit is contained in:
2025-12-17 06:34:57 +08:00
parent b3dc2cb4bd
commit 2de9359dda
6 changed files with 91 additions and 79 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Cysharp.Threading.Tasks;
using Enums;
using Models.Interfaces;
using Services.Interfaces;
@@ -50,6 +51,22 @@ namespace Services {
return false;
}
public UniTask<List<Vector2Int>> GetMatchPositionsAsync(List<Vector2Int> protectedPositions) {
List<Vector2Int> matchPositions = new List<Vector2Int>(CurrentMatches.Count);
for (int i = 0; i < CurrentMatches.Count; i++) {
Gem match = CurrentMatches[i];
if (match == null) continue;
Vector2Int pos = match.Position;
if (protectedPositions != null && protectedPositions.Contains(pos))
continue;
matchPositions.Add(pos);
}
return UniTask.FromResult(matchPositions);
}
public void FindAllMatches() {
this.currentMatches.Clear();