//public void FindPathOnButtonPress() { // List<PathPoint> listje = pathfindingNodeManager.ReturnNavPointList(); // PathPoint toFind = listje[Random.Range(0, listje.Count)]; // PathPoint start = listje[Random.Range(0, listje.Count)]; // if(toFind.GetNode != PathfindNode.Nonwalkable && start.GetNode != PathfindNode.Nonwalkable) { // pathfinder.FindPath(start.GetPosition, toFind.GetPosition); // } // else { // FindPathOnButtonPress(); // } //} private void OnDrawGizmos() { if (showPath) { pathfindingNodeManager = PathfindingNodeManager.Instance; if (pathfindingNodeManager.ReturnNavPointList().Count > 0) //If the grid is not empty { foreach (PathPoint n in pathfindingNodeManager.ReturnNavPointList()) //Loop through every node in the grid { if (n.GetNode == PathfindNode.Nonwalkable) //If the current node is a wall node { Gizmos.color = Color.white; //Set the color of the node } else { Gizmos.color = Color.yellow;//Set the color of the node } if (pathfindingNodeManager.FinalPath != null) //If the final path is not empty { if (pathfindingNodeManager.FinalPath.Contains(n)) //If the current node is in the final path { Gizmos.color = Color.red; //Set the color of that node } } Gizmos.DrawCube(new Vector3(n.GetPosition.x, 0, n.GetPosition.y), new Vector3(.3f, .3f, .3f));//Draw the node at the position of the node. } } } }
public void ClearMall() { pathfindingNodeManager = PathfindingNodeManager.Instance; tiles = Tiles.Instance; objectSpawner.Clear(); pathfindingNodeManager.Clear(); tiles.Clear(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); PathfindingNodeManager pfManager = (PathfindingNodeManager)target; if (GUILayout.Button("Recalculate Paths")) { pfManager.UpdateNodes(); } }
private void Awake() { mallWidth = mallWidth % 2 == 0 ? mallWidth - 1 : mallWidth; mallHeight = mallHeight % 2 == 0 ? mallHeight - 1 : mallHeight; storeFurnitureSpawner = StoreFurnitureSpawner.Instance; pathfindingNodeManager = PathfindingNodeManager.Instance; tiles = Tiles.Instance; tiles.Init(); objectSpawner = ObjectSpawner.Instance; objectSpawner.Init(); }
public void Init() { mallGenerator = MallGenerator.Instance; pathfindingNodeManager = PathfindingNodeManager.Instance; hallWidht = mallGenerator.hallWidht; gridSize = mallGenerator.gridSize; plazaSize = mallGenerator.plazaSize; storeWidth = mallGenerator.storeWidth; storeHeight = mallGenerator.storeHeight; storesOnHallway = mallGenerator.storesOnHallway; mallWidth = mallGenerator.mallWidth; mallHeight = mallGenerator.mallHeight; stores = new List <Tile[, ]>(); hallways = new Tile[mallWidth, mallHeight]; doors = new Tile[mallWidth, mallHeight]; outside = new Tile[mallWidth, mallHeight]; storeSpaces = new List <MallSpace>(); hallwaySpaces = new List <MallSpace>(); }
private void InitSettings(int storeNumber) { tiles = Tiles.Instance; objectSpawner = ObjectSpawner.Instance; pathfindingNodeManager = PathfindingNodeManager.Instance; stepsSize = (1 / tiles.gridSize); gridSize = tiles.gridSize; gridPercentage = (1 / gridSize); registers = Resources.LoadAll <GameObject>("Register"); pointsInRoom = new List <PathPoint>(); foreach (PathPoint point in pathfindingNodeManager.ReturnNavPointList()) { if (point.GetStoreNumber == storeNumber) { pointsInRoom.Add(point); } } stores = tiles.GetStoreSpaces; currentStore = stores[storeNumber]; storeSize = currentStore.GetHeightWidthofRoom; storeDecoration = Resources.LoadAll <GameObject>("StoreDecoration"); }
protected virtual void OnSceneGUI() { PathfindingNodeManager nodeManager = (PathfindingNodeManager)target; //Draw positions if (nodeManager.nodePositions != null) { for (int i = 0; i < nodeManager.nodePositions.Count; i++) { Vector3 nodePosition = nodeManager.nodePositions[i]; if (i == selectedNodeIndex) { Handles.color = Color.cyan; Handles.DrawWireCube(nodePosition + nodeManager.offset, Vector3.one * 2f); Handles.DrawWireCube(nodePosition + nodeManager.offset, Vector3.one * nodeManager.range * 2f); EditorGUI.BeginChangeCheck(); Vector3 newtargetPos = Handles.PositionHandle(nodePosition + nodeManager.offset, Quaternion.identity); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(nodeManager, "changed node position"); nodeManager.nodePositions [i] = newtargetPos - nodeManager.offset; } } else { Handles.color = Color.blue; if (Handles.Button(nodePosition + nodeManager.offset, Quaternion.LookRotation(Vector3.up), 1f, 2f, Handles.CircleHandleCap)) { selectedNodeIndex = i; Repaint(); } } } } //Draw Connections if (nodeManager.nodeList != null) { //Draw connections if (displayAllNeighbors) { for (int i = 0; i < nodeManager.nodeList.Count; i++) { if (i == selectedNodeIndex) { continue; } Node node = nodeManager.nodeList[i]; //Draw connections foreach (Node neighbor in node.GetNeighbors()) { Handles.color = Color.grey; Handles.DrawDottedLine((Vector3)node + nodeManager.offset, (Vector3)neighbor + nodeManager.offset, 10.0f); } } } //Draw selected node connections if (selectedNodeIndex > -1 && selectedNodeIndex < nodeManager.nodeList.Count) { Node selectedNode = nodeManager.nodeList[selectedNodeIndex]; //Draw connections foreach (Node neighbor in selectedNode.GetNeighbors()) { Handles.color = Color.cyan; DrawLineWithHeader((Vector3)selectedNode + nodeManager.offset, (Vector3)neighbor + nodeManager.offset, Node.SqrDistance(selectedNode, neighbor)); } } } }
public override void OnInspectorGUI() { EditorGUILayout.LabelField( "PATHFINDING NODES - " + "Use this for moving platforms and such."); serializedObject.Update(); PathfindingNodeManager nodeManager = (PathfindingNodeManager)target; EditorGUILayout.LabelField( "NODES - " + "Vector3's for positions."); listFolded = EditorGUILayout.Foldout(listFolded, "List of Nodes"); EditorGUI.BeginChangeCheck(); if (listFolded) { list.DoLayoutList(); } if (EditorGUI.EndChangeCheck()) { Debug.Log("Changed!"); } if (list.index != selectedIndexLastFrame) { selectedIndexLastFrame = list.index; selectedNodeIndex = list.index; } else if (selectedNodeIndex != list.index) { list.index = selectedNodeIndex; selectedIndexLastFrame = list.index; } x = EditorGUILayout.IntField("Grid Dimension X: ", x); y = EditorGUILayout.IntField("Grid Dimension Y: ", y); spacing = EditorGUILayout.FloatField("Spacing: ", spacing); if (GUILayout.Button("Grid")) { nodeManager.PopulateGrid(x, y, spacing); } nodeManager.range = EditorGUILayout.FloatField("Neighbor Detection Range: ", nodeManager.range); if (GUILayout.Button("Clear Nodes")) { nodeManager.DeleteNodesAndConnections(); } if (GUILayout.Button("Generate Nodes and Make Connections")) { Debug.Log("Making Connections!"); nodeManager.GenerateNodesAndNodeConnections(); } serializedObject.ApplyModifiedProperties(); }
void Start() { manager = PathfindingNodeManager.INSTANCE; }
private void Awake() { INSTANCE = this; GenerateNodesAndNodeConnections(); }
private void Start() { manager = PathfindingNodeManager.INSTANCE; closestNode = manager.ClosestNodeToPoint(transform.position); }