BuildingGridNode.cs 894 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BuildingGridNode {
  5. GridXZ<BuildingGridNode> grid;
  6. int x, z;
  7. private Transform transform;
  8. public BuildingGridNode(GridXZ<BuildingGridNode> grid, int x, int z) {
  9. this.grid = grid;
  10. this.x = x;
  11. this.z = z;
  12. }
  13. public void SetTransform(Transform transform) {
  14. this.transform = transform;
  15. grid.TriggerGridObjectChanged(x, z);
  16. }
  17. public void ClearTransform() {
  18. this.transform = null;
  19. grid.TriggerGridObjectChanged(x, z);
  20. }
  21. public bool CanBuild() {
  22. if (UnityEngine.EventSystems.EventSystem.current.IsPointerOverGameObject()) return false; // Check if over UI element
  23. return transform == null;
  24. }
  25. public override string ToString() {
  26. return x + ", " + z + " \n" + transform;
  27. }
  28. }