private void DropGems() { var speed = dropSpeed * transform.lossyScale.x; for (int j = 0; j < _grid.GetWidth(); j++) { var emptyBelow = 0; for (int i = _grid.GetHeight() - 1; i >= 0; i--) { var gem = _grid.GetValue(i, j); if (!gem) { emptyBelow++; } else { if (emptyBelow > 0) { gem.SetPosition(_grid.GetWorldPositionFromIndex(new MatrixIndex(i + emptyBelow, j)), speed); _grid.SetValue(i + emptyBelow, j, gem); _grid.SetValue(i, j, null); } } } } }
public bool HasPossibleMatch() { for (int i = 0; i < _grid.GetHeight(); i++) { for (int j = 0; j < _grid.GetWidth(); j++) { if (CheckLShapedPossibilities(i, j) || CheckVShapedPossibilities(i, j) || CheckLineShapedPossibilities(i, j)) { return(true); } } } return(false); }