private bool CheckLineShapedPossibilities(int i, int j) { var gem = _grid.GetValue(i, j); if (i >= 3) { if (_grid.GetValue(i - 1, j).CompareTag(gem.tag) && _grid.GetValue(i - 3, j).CompareTag(gem.tag)) { return(true); } } if (i < _grid.GetHeight() - 3) { if (_grid.GetValue(i + 1, j).CompareTag(gem.tag) && _grid.GetValue(i + 3, j).CompareTag(gem.tag)) { return(true); } } if (j >= 3) { if (_grid.GetValue(i, j - 1).CompareTag(gem.tag) && _grid.GetValue(i, j - 3).CompareTag(gem.tag)) { return(true); } } if (j < _grid.GetWidth() - 3) { if (_grid.GetValue(i, j + 1).CompareTag(gem.tag) && _grid.GetValue(i, j + 3).CompareTag(gem.tag)) { return(true); } } return(false); }
private IEnumerator Swap(MatrixIndex indexA, MatrixIndex indexB, bool returning = false) { SetBusy(true); AudioSource.PlayClipAtPoint(swapClip, _camera.transform.position); var speed = swapSpeed * transform.lossyScale.x; _grid.GetValue(indexA).SetPosition(_grid.GetWorldPositionFromIndex(indexB), speed); _grid.GetValue(indexB).SetPosition(_grid.GetWorldPositionFromIndex(indexA), speed); var tempGem = _grid.GetValue(indexA); _grid.SetValue(indexA, _grid.GetValue(indexB)); _grid.SetValue(indexB, tempGem); yield return(new WaitForSeconds(stepTime)); if (!returning) { ProcessSwap(indexA, indexB); } else { SetBusy(false); } }