Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. public bool isMatched = false;
  2.  
  3. //........//
  4.  
  5. void CheckMatches()
  6. {
  7. //Check horizontal matching
  8. if (column > 0 && column < _grid.gridSizeX -1)
  9. {
  10. //Check samping kiri dan kanan nya
  11. GameObject leftTile = _grid.tiles[column - 1, row];
  12. GameObject rightTile = _grid.tiles[column + 1, row];
  13. if(leftTile != null && rightTile != null)
  14. {
  15. if (leftTile.CompareTag(gameObject.tag) && rightTile.CompareTag(gameObject.tag))
  16. {
  17. isMathced = true;
  18. rightTile.GetComponent<Tile>().isMathced = true;
  19. leftTile.GetComponent<Tile>().isMathced = true;
  20. }
  21. }
  22. }
  23. //Check vertical matching
  24. if (row > 0 && row < _grid.gridSizeY - 1)
  25. {
  26. Check samping atas dan bawahnya
  27. GameObject upTile = _grid.tiles[column, row + 1];
  28. GameObject downTile = _grid.tiles[column, row -1];
  29. if (upTile != null && downTile != null)
  30. {
  31. if (upTile.CompareTag(gameObject.tag) && downTile.CompareTag(gameObject.tag))
  32. {
  33. isMathced = true;
  34. downTile.GetComponent<Tile>().isMathced = true;
  35. upTile.GetComponent<Tile>().isMathced = true;
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement