// Get a snapshot of the final path public void FinalPathSnapshot(NodeGrid <Node> grid, List <Node> path) { GridSnapshotAction gridSnapshotAction = new GridSnapshotAction(); gridSnapshotAction.AddAction(HideVisuals); for (int x = 0; x < grid.GetWidth(); x++) { for (int y = 0; y < grid.GetHeight(); y++) { for (int z = 0; z < grid.GetDepth(); z++) { Node node = grid.GetGridObject(x, y, z); int g = node.g; int h = node.h; int f = node.f; Vector3 gridPos = new Vector3(node.x, node.y, node.z) * grid.GetNodeSize() + Vector3.one * grid.GetNodeSize() * 5f; bool isInPath = path.Contains(node); int tmpX = x; int tmpY = y; int tmpZ = z; gridSnapshotAction.AddAction(() => { Transform visualNode = visualNodeArray[tmpX, tmpY, tmpZ]; SetupVisualNode(visualNode, g, h, f); Material material; if (isInPath) { material = nodeSearching; } else { material = nodeDefault; } visualNode.GetComponent <MeshRenderer>().material = material; }); } } } gridSnapshotActions.Add(gridSnapshotAction); }
public void TakeSnapshot(Grid <PathNode> grid, PathNode current, List <PathNode> openList, List <PathNode> closedList) { GridSnapshotAction gridSnapshotAction = new GridSnapshotAction(); gridSnapshotAction.AddAction(HideNodeVisuals); for (int x = 0; x < grid.GetWidth(); x++) { for (int y = 0; y < grid.GetHeight(); y++) { PathNode pathNode = grid.GetGridObject(x, y); int gCost = pathNode.gCost; int hCost = pathNode.hCost; int fCost = pathNode.fCost; Vector3 gridPosition = new Vector3(pathNode.x, pathNode.y) * grid.GetCellSize() + Vector3.one * grid.GetCellSize() * .5f; bool isCurrent = pathNode == current; bool isInOpenList = openList.Contains(pathNode); bool isInClosedList = closedList.Contains(pathNode); bool hasBeenWalkedOn = pathNode.hasBeenWalkedOn; int tmpX = x; int tmpY = y; gridSnapshotAction.AddAction(() => { Transform visualNode = visualNodeArray[tmpX, tmpY]; SetupVisualNode(visualNode, gCost, hCost, fCost); Color backgroundColor = UtilsClass.GetColorFromString("636363"); if (hasBeenWalkedOn) { backgroundColor = UtilsClass.GetColorFromString("ffffff"); } if (isInClosedList) { backgroundColor = new Color(1, 0, 0); } if (isInOpenList) { backgroundColor = UtilsClass.GetColorFromString("009AFF"); } if (isCurrent) { backgroundColor = new Color(0, 1, 0); } visualNode.Find("sprite").GetComponent <SpriteRenderer>().color = backgroundColor; }); } } gridSnapshotActionList.Add(gridSnapshotAction); }
public void TakeSnapshot(GridBase <PathNode> grid, PathNode current, List <PathNode> openList, List <PathNode> closedList) { GridSnapshotAction gridSnapshotAction = new GridSnapshotAction(); gridSnapshotAction.AddAction(HideNodeVisuals); for (int x = 0; x < grid.Width; x++) { for (int y = 0; y < grid.Height; y++) { PathNode pathNode = grid.GetCell(x, y); int gCost = pathNode.gCost; int hCost = pathNode.hCost; int fCost = pathNode.fCost; Vector3 gridPosition = new Vector3(pathNode.Position.x, pathNode.Position.y) * grid.CellSize + Vector3.one * grid.CellSize * .5f; bool isCurrent = pathNode == current; bool isInOpenList = openList.Contains(pathNode); bool isInClosedList = closedList.Contains(pathNode); int tmpX = x; int tmpY = y; gridSnapshotAction.AddAction(() => { Transform visualNode = visualNodeArray[tmpX, tmpY]; SetupVisualNode(visualNode, gCost, hCost, fCost); Color backgroundColor = UtilsClass.GetColorFromString("636363"); if (isInClosedList) { backgroundColor = new Color(1, 0, 0); } if (isInOpenList) { backgroundColor = UtilsClass.GetColorFromString("009AFF"); } if (isCurrent) { backgroundColor = new Color(0, 1, 0); } var sprite = visualNode.GetComponentInChildren <SpriteRenderer>(); if (sprite != null) { sprite.color = backgroundColor; } }); } } gridSnapshotActionList.Add(gridSnapshotAction); }
public void TakeSnapshotFinalPath(Grid <PathNode> grid, List <PathNode> path) { GridSnapshotAction gridSnapshotAction = new GridSnapshotAction(); gridSnapshotAction.AddAction(HideNodeVisuals); for (int x = 0; x < grid.GetWidth(); x++) { for (int y = 0; y < grid.GetHeight(); y++) { PathNode pathNode = grid.GetGridObject(x, y); int gCost = pathNode.gCost; int hCost = pathNode.hCost; int fCost = pathNode.fCost; Vector3 gridPosition = new Vector3(pathNode.x, pathNode.y) * grid.GetCellSize() + Vector3.one * grid.GetCellSize() * .5f; bool isInPath = path.Contains(pathNode); bool hasBeenWalkedOn = pathNode.hasBeenWalkedOn; int tmpX = x; int tmpY = y; gridSnapshotAction.AddAction(() => { Transform visualNode = visualNodeArray[tmpX, tmpY]; SetupVisualNode(visualNode, gCost, hCost, fCost); Color backgroundColor; if (isInPath) { pathNode.SetHasBeenWalked(); StatsHandler.Instance.updateTilesWalked(grid); backgroundColor = new Color(0, 1, 0); } else if (hasBeenWalkedOn) { backgroundColor = UtilsClass.GetColorFromString("ffffff"); } else { backgroundColor = UtilsClass.GetColorFromString("636363"); } visualNode.Find("sprite").GetComponent <SpriteRenderer>().color = backgroundColor; // Globals of Interface; Globals.isRunning = false; }); } } gridSnapshotActionList.Add(gridSnapshotAction); }
public void TakeSnapshot(Grilla <Nodo> grid, Nodo current, List <Nodo> openList, List <Nodo> closedList) { GridSnapshotAction gridSnapshotAction = new GridSnapshotAction(); gridSnapshotAction.AddAction(HideNodeVisuals); for (int x = 0; x < grid.GetWidth(); x++) { for (int y = 0; y < grid.GetHeight(); y++) { Nodo Nodo = grid.GetGridObject(x, y); int CostoG = Nodo.CostoG; int CostoH = Nodo.CostoH; int CostoF = Nodo.CostoF; Vector3 gridPosition = new Vector3(Nodo.x, Nodo.y) * grid.GetCellSize() + Vector3.one * grid.GetCellSize() * .5f; bool isCurrent = Nodo == current; bool isInOpenList = openList.Contains(Nodo); bool isInClosedList = closedList.Contains(Nodo); int tmpX = x; int tmpY = y; gridSnapshotAction.AddAction(() => { Transform visualNode = visualNodeArray[tmpX, tmpY]; SetupVisualNode(visualNode, CostoG, CostoH, CostoF); Color backgroundColor = UtilsClass.GetColorFromString("636363"); if (isInClosedList) { backgroundColor = new Color(1, 0, 0); } if (isInOpenList) { backgroundColor = UtilsClass.GetColorFromString("009AFF"); } if (isCurrent) { backgroundColor = new Color(0, 1, 0); } visualNode.Find("sprite").GetComponent <SpriteRenderer>().color = backgroundColor; }); } } gridSnapshotActionList.Add(gridSnapshotAction); }
public void TakeSnapshotFinalPath(Grid <PathNode> grid, List <PathNode> path) { GridSnapshotAction gridSnapshotAction = new GridSnapshotAction(); gridSnapshotAction.AddAction(HideNodeVisuals); for (int x = 0; x < grid.GetWidth(); x++) { for (int y = 0; y < grid.GetHeight(); y++) { PathNode pathNode = grid.GetGridObject(x, y); int gCost = pathNode.gCost; int hCost = pathNode.hCost; int fCost = pathNode.fCost; Vector3 gridPosition = new Vector3(pathNode.x, pathNode.y) * grid.GetCellSize() + Vector3.one * grid.GetCellSize() * .5f; bool isInPath = path.Contains(pathNode); int tmpX = x; int tmpY = y; gridSnapshotAction.AddAction(() => { Transform visualNode = visualNodeArray[tmpX, tmpY]; SetupVisualNode(visualNode, gCost, hCost, fCost); Color backgroundColor; if (isInPath) { backgroundColor = new Color(0, 1, 0); } else { backgroundColor = UtilsClass.GetColorFromString("636363"); } visualNode.Find("sprite").GetComponent <SpriteRenderer>().color = backgroundColor; }); } } _gridSnapshotActionList.Add(gridSnapshotAction); }
public void TakeSnapshotFinalPath(Grilla <CasillaNodo> grid, List <CasillaNodo> path) { GridSnapshotAction gridSnapshotAction = new GridSnapshotAction(); gridSnapshotAction.AddAction(HideNodeVisuals); for (int x = 0; x < grid.GetWidth(); x++) { for (int y = 0; y < grid.GetHeight(); y++) { CasillaNodo CasillaNodo = grid.GetGridObject(x, y); Vector3 gridPosition = new Vector3(CasillaNodo.x, CasillaNodo.y) * grid.GetCellSize() + Vector3.one * grid.GetCellSize() * .5f; bool isInPath = path.Contains(CasillaNodo); int tmpX = x; int tmpY = y; gridSnapshotAction.AddAction(() => { Transform visualNode = visualNodeArray[tmpX, tmpY]; Color backgroundColor; if (isInPath) { backgroundColor = new Color(0, 1, 0); } else { backgroundColor = UtilsClass.GetColorFromString("636363"); } visualNode.Find("sprite").GetComponent <SpriteRenderer>().color = backgroundColor; }); } } gridSnapshotActionList.Add(gridSnapshotAction); }