private GameObject CreateLayer(NodeLayer layer)//создание слоя { if (layer.direction == "i") { layer.direction = direction; } Vector3 rotation = GetRotation(layer.direction); Vector3 position = new Vector3(crd.x, floor.number, crd.z); if (layer.premitive == "Main") { switch (layer.name) { case "ControllQuad": return(GameObject.Instantiate(Game.GameManager.instance.ControllZone, position, Quaternion.Euler(rotation))); default: break; } } if (layer.nonWalkable) { Node node = GetSibling(layer.direction); if (!node.empty) { UnlinkNode(node); node.UnlinkNode(this); } } UnityEngine.Object prefab = Resources.Load("Stage/" + this.floor.stage.DesignName + "/" + layer.premitive + "/" + layer.name + "/" + this.order + "/" + layer.prefabNumber); return(GameObject.Instantiate(prefab, position, Quaternion.Euler(rotation)) as GameObject); }
public override List <NodeLayer> HookAddLayersToNode(List <NodeLayer> layers, Node node) { NodeLayer door = new NodeLayer(getPrefabNuber(), "Premetives/Portal", name); if (isExit) { door.direction = parentElement.rct.GetDirection(node.crd); } else { RCT dirRCT = Brother.parentElement.rct.Clone(); dirRCT.Grow(); door.direction = dirRCT.GetDirection(node.crd); door.InvertDirection(); } door.hasMesh = false; NodeLayer wall = node.Layers.Find(x => x.direction == door.direction && (x.name == "InnerWall" || x.name == "OuterWall")); node.Layers.Remove(wall); if (IsOpened() && isExit) { node.UnlinkNode(Brother.childNodes[0]); Brother.childNodes[0].UnlinkNode(node); node.LinkNode(Brother.childNodes[0], 1 + monoPortal.ExtraWeight); Brother.childNodes[0].LinkNode(node, 1 + monoPortal.ExtraWeight); } return(new List <NodeLayer>() { door }); }
public override List <NodeLayer> HookAddLayersToNode(List <NodeLayer> layers, Node node) { List <NodeLayer> nodeLayers = new List <NodeLayer>(); if (parentElement.GetType() == typeof(CrossroadRoad)) { if (node.BorderWidthType(typeof(Intersection))) { //nodeLayers.Add(new NodeLayer(0, "Premetives/Surface", "Sidewalk")); if (parentElement.parentElement.GetType() != typeof(BackgroundStreet)) { nodeLayers.Add(new NodeLayer(0, "Main", "ControllQuad")); } } else { NodeLayer layer = new NodeLayer(getPrefabNuber(), "Additions/SafetyZone", "End"); layer.direction = GetParentByClass(typeof(Crossroad)).rct.GetDirection(node.crd); layer.InvertDirection(); nodeLayers.Add(layer); if (parentElement.parentElement.GetType() != typeof(BackgroundStreet)) { nodeLayers.Add(new NodeLayer(0, "Main", "ControllQuad")); } } } else { nodeLayers = layers; } return(base.HookAddLayersToNode(nodeLayers, node)); }
public override void HookAddToChildElements() { NodeLayer column = new NodeLayer(getPrefabNuber(), "Premetives/Wall", "Column"); column.hasMesh = false; AddLayer(column); base.HookAddToChildElements(); }
public override void HookAddToChildElements() { surface = "Road"; NodeLayer layer = new NodeLayer(getPrefabNuber(), "Additions/Sidewalk", "OuterCorner"); layer.direction = direction; AddLayer(layer); AddLayer(new NodeLayer(0, "Main", "ControllQuad")); }
public override void HookAddToChildElements() { base.HookAddToChildElements(); NodeLayer floor = new NodeLayer(getPrefabNuber(), "Premetives/Surface", "Floor"); floor.hasMesh = false; AddLayer(floor); NodeLayer controllQuad = new NodeLayer(0, "Main", "ControllQuad"); controllQuad.positionCorrection = new Vector3(0, 0.05f, 0); AddLayer(controllQuad); }
public NodeLayer Clone() { NodeLayer layer = new NodeLayer(prefabNumber, premitive, name); layer.map = map; layer.mapping = mapping; layer.hasMesh = hasMesh; layer.direction = direction; layer.nonWalkable = nonWalkable; layer.ignorePreviosMesh = ignorePreviosMesh; layer.positionCorrection = positionCorrection; return(layer); }
public override void HookAddToChildElements() { surface = "Road"; NodeLayer corner = new NodeLayer(getPrefabNuber(), "Additions/Sidewalk", "OuterCorner"); string layerDirection = parentElement.rct.GetDirection(this.rct.Start); corner.direction = layerDirection; AddLayer(corner); AddLayer(new NodeLayer(0, "Main", "ControllQuad")); NodeLayer trafficLight = new NodeLayer(getPrefabNuber(), "Additions/Pilars", "TrafficLight"); trafficLight.direction = layerDirection; trafficLight.hasMesh = false; trafficLight.nonWalkable = true; AddLayer(trafficLight); }
public override void HookAddToChildElements() { surface = "Road"; AddLayer(new NodeLayer(0, "Premetives/Surface", "Sidewalk")); if (parentElement.GetType() != typeof(BackgroundStreet)) { AddLayer(new NodeLayer(0, "Main", "ControllQuad")); } NodeLayer lights = new NodeLayer(getPrefabNuber(), "Additions/Pilars", "NightLight"); int offset = 2; int roadOffset = getRoadOffset(offset); lights.addMap(StageConstructor.createPeriodicalMap(rct, axis, roadOffset, 7)); lights.hasMesh = false; lights.nonWalkable = true; AddLayer(lights); }
public override List <NodeLayer> HookAddLayersToNode(List <NodeLayer> layers, Node node) { List <NodeLayer> nodeLayers = new List <NodeLayer>(layers); if (node.crd == origin) { NodeLayer furniture = new NodeLayer(getPrefabNuber(), "Furniture", name); furniture.direction = furnitureDirection; nodeLayers.Add(furniture); } int controllzone = nodeLayers.FindIndex(x => x.name == "ControllQuad"); if (controllzone >= 0) { nodeLayers.RemoveAt(controllzone); } if (monoFurniture.Walkable) { nodeLayers.Add(new NodeLayer(0, "Main", "ControllQuad")); } return(base.HookAddLayersToNode(nodeLayers, node)); }
public void RemoveLayer(NodeLayer layer)// удаляет у елемента объект слой узла { this.layers.Remove(layer); }
public void AddLayer(NodeLayer layer)// добавляет елементу объект слой узла { this.layers.Add(layer); }
public override List <NodeLayer> HookAddLayersToNode(List <NodeLayer> layers, Node node) { List <NodeLayer> nodeLayers = new List <NodeLayer>(layers); int oldVontrollZone = nodeLayers.FindIndex(x => x.name == "ControllQuad"); if (oldVontrollZone >= 0) { nodeLayers.RemoveAt(oldVontrollZone); } if (node.IsOnMapElementBorder()) { List <string> walls = node.GetWall(); for (int w = 0; w < walls.Count; w++) { if ((node.crd.x == rct.Start.x && walls[w] == "t") || (node.crd.x == rct.End.x && walls[w] == "b") || (node.crd.z == rct.Start.z && walls[w] == "l") || (node.crd.z == rct.End.z && walls[w] == "r")) { walls.RemoveAt(w); w--; continue; } NodeLayer wall = new NodeLayer(getPrefabNuber(), "Premetives/Wall", "OuterWall"); wall.direction = walls[w]; wall.hasMesh = false; nodeLayers.Add(wall); } /*for (int w = 0; w < walls.Count; w++) * { * * NodeLayer border = new NodeLayer(getPrefabNuber(), "Premetives/Surface", "BuildingBorder"); * border.direction = walls[w]; * border.hasMesh = false; * nodeLayers.Add(border); * }*/ List <string> outerCorners = node.GetOuterCorners(); /*for (int c = 0; c < outerCorners.Count; c++) * { * NodeLayer border = new NodeLayer(getPrefabNuber(), "Premetives/Surface", "BuildingBorderOuterCorner"); * border.direction = outerCorners[c]; * border.hasMesh = false; * nodeLayers.Add(border); * }*/ for (int c = 0; c < outerCorners.Count; c++) { NodeLayer corner = new NodeLayer(getPrefabNuber(), "Premetives/Wall", "OuterWallOuterCorner"); corner.direction = outerCorners[c]; corner.hasMesh = false; nodeLayers.Add(corner); Node n1 = node.GetSibling(outerCorners[c][0].ToString()); Node n2 = node.GetSibling(outerCorners[c][1].ToString()); n1.UnlinkNode(n2); n2.UnlinkNode(n1); } } return(base.HookAddLayersToNode(nodeLayers, node)); }
public override List <NodeLayer> HookAddLayersToNode(List <NodeLayer> layers, Node node) { List <NodeLayer> nodeLayers = new List <NodeLayer>(layers); if (node.IsOnMapElementBorder()) { List <string> walls = node.GetWall(); for (int w = 0; w < walls.Count; w++) { NodeLayer wall = new NodeLayer(getPrefabNuber(), "Premetives/Wall", "InnerWall"); wall.direction = walls[w]; wall.hasMesh = false; nodeLayers.Add(wall); Node wallNode = node.GetSibling(walls[w]); List <Node> wallNodes = wallNode.GetMapElementSiblingdsNoDiagonals(); wallNodes.Add(wallNode); List <Node> nodes = node.GetMapElementSiblingdsNoDiagonals(); nodes.Add(node); node.UnlinkNode(wallNodes); wallNode.UnlinkNode(nodes); foreach (Node wNode in wallNodes) { wNode.UnlinkNode(node); } foreach (Node sNode in nodes) { sNode.UnlinkNode(wallNode); } if (walls.Count >= 2) { Node ocNode; if (walls.Contains("l") && walls.Contains("t")) { ocNode = node.GetSibling("lt"); ocNode.UnlinkNode(node); node.UnlinkNode(ocNode); } if (walls.Contains("l") && walls.Contains("b")) { ocNode = node.GetSibling("lb"); ocNode.UnlinkNode(node); node.UnlinkNode(ocNode); } if (walls.Contains("r") && walls.Contains("t")) { ocNode = node.GetSibling("rt"); ocNode.UnlinkNode(node); node.UnlinkNode(ocNode); } if (walls.Contains("r") && walls.Contains("b")) { ocNode = node.GetSibling("rb"); ocNode.UnlinkNode(node); node.UnlinkNode(ocNode); } } } List <string> outerCorners = node.GetOuterCorners(); for (int c = 0; c < outerCorners.Count; c++) { NodeLayer outerCorner = new NodeLayer(getPrefabNuber(), "Premetives/Wall", "innerWallOuterCorner"); outerCorner.direction = outerCorners[c]; outerCorner.hasMesh = false; nodeLayers.Add(outerCorner); Node n1 = node.GetSibling(outerCorners[c][0].ToString()); Node n2 = node.GetSibling(outerCorners[c][1].ToString()); n1.UnlinkNode(n2); n2.UnlinkNode(n1); /*Debug.Log("node" + node.crd.x + ":" + node.crd.z); * Debug.Log("n1" + n1.crd.x + ":" + n1.crd.z); * Debug.Log("n2" + n2.crd.x + ":" + n2.crd.z);*/ } } return(base.HookAddLayersToNode(nodeLayers, node)); }