Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool isMatched = false;
- //........//
- void CheckMatches()
- {
- //Check horizontal matching
- if (column > 0 && column < _grid.gridSizeX -1)
- {
- //Check samping kiri dan kanan nya
- GameObject leftTile = _grid.tiles[column - 1, row];
- GameObject rightTile = _grid.tiles[column + 1, row];
- if(leftTile != null && rightTile != null)
- {
- if (leftTile.CompareTag(gameObject.tag) && rightTile.CompareTag(gameObject.tag))
- {
- isMathced = true;
- rightTile.GetComponent<Tile>().isMathced = true;
- leftTile.GetComponent<Tile>().isMathced = true;
- }
- }
- }
- //Check vertical matching
- if (row > 0 && row < _grid.gridSizeY - 1)
- {
- Check samping atas dan bawahnya
- GameObject upTile = _grid.tiles[column, row + 1];
- GameObject downTile = _grid.tiles[column, row -1];
- if (upTile != null && downTile != null)
- {
- if (upTile.CompareTag(gameObject.tag) && downTile.CompareTag(gameObject.tag))
- {
- isMathced = true;
- downTile.GetComponent<Tile>().isMathced = true;
- upTile.GetComponent<Tile>().isMathced = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement