PathNode.cs 756 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class PathNode {
  6. private GridXZ<PathNode> grid;
  7. public int x;
  8. public int z;
  9. public int gCost;
  10. public int hCost;
  11. public int fCost;
  12. public bool isWalkable;
  13. public PathNode cameFromNode;
  14. public PathNode(GridXZ<PathNode> grid, int x, int z) {
  15. this.grid = grid;
  16. this.x = x;
  17. this.z = z;
  18. isWalkable = true;
  19. }
  20. public void CalculateFCost() {
  21. fCost = gCost + hCost;
  22. }
  23. public override string ToString() {
  24. return x + "," + z;
  25. }
  26. internal void SetIsWalkable(bool value) {
  27. isWalkable = value;
  28. grid.TriggerGridObjectChanged(x, z);
  29. }
  30. }