//////////////////////////////////////////////////////////////////////////// // Create Map Nodes //////////////////////////////////////////////////////// private Dictionary <WorldNode, List <MapNode> > CreateMapNodes(List <WorldNode> worldNodes) { // Wrap map Nodes around around Initial Dictionary <WorldNode, List <MapNode> > worldNodeAndWrapperNodes = new Dictionary <WorldNode, List <MapNode> >(); foreach (WorldNode worldNode in worldNodes) { List <Vector3> mapVects = GetMapVects(worldNode); List <MapNode> mapNodes = new List <MapNode>(); bool shipEntrance = false; int shipEntranceProbablity = 20; if (worldNode.nodeSize == 3 && Random.Range(0, shipEntranceProbablity) == 0) { shipEntrance = true; _nodeBuilder.AttachCoverToNode(worldNode, worldNode.gameObject, CoverTypes.LargeGarageCover); } int mapCount = 0; foreach (Vector3 vect in mapVects) { int rotation = 0; int mapType = -1; if (shipEntrance) { mapType = MAPTYPE_SHIPPORT; } else { mapType = MAPTYPE_MAP; } int mapPiece = Random.Range(0, 4); // 3 is the number of availble map pieces MapNode mapNode = CreateNode <MapNode>(worldNode.gameObject.transform, vect, rotation, mapType, mapPiece, NodeTypes.MapNode); mapNode.nodeSize = 1; mapNode.neighbours = new int[6]; for (int i = 0; i < mapNode.neighbours.Length; i++) { mapNode.neighbours[i] = 1; } mapNode.worldNodeParent = worldNode; mapNodes.Add(mapNode); if (!shipEntrance) { _nodeBuilder.AttachCoverToNode(mapNode, mapNode.gameObject, CoverTypes.NormalCover); } /*// dont think need this anymore But not deleteing incase still do * if (vect.y <= lowestYpos) // this is find lowest point to make LayerCounts * { * lowestYpos = vect.y; * } * if (vect.y >= highestYpos) // this is find highest point to make LayerCounts * { * highestYpos = vect.y; * }*/ mapCount++; } worldNode.mapNodes = mapNodes; worldNodeAndWrapperNodes.Add(worldNode, mapNodes); //////////////// //// Map Neighbours int[] worldNodeNeighbours = worldNode.neighbours; if (worldNode.nodeSize == 1) { MapNode mapNode = worldNode.mapNodes[0]; int[] mapNeighbours = mapNode.neighbours; for (int i = 0; i < worldNodeNeighbours.Length; i++) { if (worldNodeNeighbours[i] != -1) { mapNeighbours[i] = 1; } else { mapNeighbours[i] = -1; mapNode.entranceSides.Add(i); } } } //////// if (worldNode.nodeSize == 3) { // bottom SetMapNeighboursWithMultipleLinks(worldNode, 0, 4, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }, shipEntrance); // Front SetMapNeighboursWithMultipleLinks(worldNode, 1, 10, new int[] { 0, 1, 2, 9, 10, 11, 18, 19, 20 }, shipEntrance); // Left SetMapNeighboursWithMultipleLinks(worldNode, 2, 12, new int[] { 0, 3, 6, 9, 12, 15, 18, 21, 24 }, shipEntrance); // Right SetMapNeighboursWithMultipleLinks(worldNode, 3, 14, new int[] { 2, 5, 8, 11, 14, 17, 20, 23, 26 }, shipEntrance); // Back SetMapNeighboursWithMultipleLinks(worldNode, 4, 16, new int[] { 6, 7, 8, 15, 16, 17, 24, 25, 26 }, shipEntrance); // Top SetMapNeighboursWithMultipleLinks(worldNode, 5, 22, new int[] { 18, 19, 20, 21, 22, 23, 24, 25, 26 }, shipEntrance); } } /* // dont think need this anymore But not deleteing incase still do * // figure out LayerCount (DONT LIKE THIS) basicly have to re-run whats just happened to get count * foreach (WorldNode worldNode in worldNodeAndWrapperNodes.Keys) * { * List<MapNode> wrapperNodes = worldNodeAndWrapperNodes[worldNode]; * foreach (MapNode nodeScript in wrapperNodes) * { * nodeScript.nodeLayerCount = GetLayerCountForNodePos(nodeScript.nodeLocation); * } * }*/ return(worldNodeAndWrapperNodes); }