public void calculateNeighbors() { if (this.neighbors != null && this.neighbors.Length > 0) { return; } int[] curTriangles = parent.filter.mesh.triangles; List <int> neighborIndices = new List <int> (); for (int i = 0; i < curTriangles.Length; i++) { if (curTriangles [i] == index) { int relativePosition = i % 3; switch (relativePosition) { case 0: if (i + 1 < curTriangles.Length && !neighborIndices.Contains(curTriangles[i + 1])) { neighborIndices.Add(curTriangles[i + 1]); } if (i + 2 < curTriangles.Length && !neighborIndices.Contains(curTriangles[i + 2])) { neighborIndices.Add(curTriangles[i + 2]); } break; case 1: if (!neighborIndices.Contains(curTriangles[i - 1])) { neighborIndices.Add(curTriangles[i - 1]); } if (i + 1 < curTriangles.Length && !neighborIndices.Contains(curTriangles[i + 1])) { neighborIndices.Add(curTriangles[i + 1]); } break; case 2: if (!neighborIndices.Contains(curTriangles[i - 1])) { neighborIndices.Add(curTriangles[i - 1]); } if (!neighborIndices.Contains(curTriangles[i - 2])) { neighborIndices.Add(curTriangles[i - 2]); } break; } } } neighbors = new Vertex[neighborIndices.Count]; for (int j = 0; j < neighbors.Length; j++) { neighbors [j] = parent.getVertex(neighborIndices [j]); } }
public void setPath() { path = AStar.FindPath(sphere.getVertex(sphere.findIndexOfNearest(transform.position)), targetGoal, this.gameObject); if (path != null && path.Count > 1) { curIndex = 0; curTarget = path[1]; disabled = false; } else if (path != null && path.Count == 1) { curTarget = path[0]; disabled = false; } else { disabled = true; } }
// Use this for initialization void Start() { if (buildingLocations == null) { buildingLocations = new List <Vertex> (); } freeBois = new List <SmolMan>(); busyBois = new List <SmolMan>(); if (huts == null) { huts = new List <Vertex> (); } goods = new Dictionary <string, int> (); SphereTerrain terrain = FindObjectOfType <SphereTerrain> (); setCampfireVertex(terrain.getVertex(terrain.findIndexOfNearest(gameObject.transform.position))); AddBois(5); GetComponent <TierController>().FireBuilt(); }