public SpawnNode(NodesGrid.Node gridNode, int index) { Index = index; GridNode = gridNode; if (gridNode.Y == 0) { MainDirection = Direction.Up; } else if (gridNode.Y == 6) { MainDirection = Direction.Down; } else if (gridNode.X == 0) { MainDirection = Direction.Right; } else { MainDirection = Direction.Left; } if (gridNode.Y == 0 || gridNode.Y == 6) { if (gridNode.X == 0) { DirectionInCover = Direction.Right; } else if (gridNode.X == 6) { DirectionInCover = Direction.Left; } } }
private static void CreateShape(Node node, Type shapeType) { GameObject prefab = null; switch (shapeType.Name) { case "LineShape": prefab = ResourcesLoader.LineShapePrefab; break; case "CornerShape": prefab = ResourcesLoader.CornerShapePrefab; break; case "TeeShape": prefab = ResourcesLoader.TeeShapePrefab; break; default: Debug.LogError("incorrect type - " + shapeType.Name); break; } Vector3 pos = new Vector3(node.X, _shapeYpos, node.Y); var shapeGO = (GameObject)Object.Instantiate(prefab, pos, new Quaternion(0, 0, 0, 0)); shapeGO.transform.parent = SceneContainers.Shapes; Shape retShape = shapeGO.GetComponent <Shape>(); node.SetShape(retShape); _shapesCount++; }
private static void GenerateRecursively(Node node, Direction prevOutDirection) { if (!node.IsAvailable) return; CreateShape(node, typeof (TeeShape)); FastRotateToConnection((TeeShape)node.Shape, prevOutDirection); //генерация ноды, если свободная клетка List<KeyValuePair<Node,Direction>> nodes = NodesGrid.FindAvailableNeighborNodesForShapeSides(node); foreach (var nodeDirPair in nodes) { GenerateRecursively(nodeDirPair.Key, nodeDirPair.Value.GetOpposite()); } }
private static void CreateRandomShape(Node node) { switch (Random.Range(0, 3)) { case 0: CreateShape(node, typeof(LineShape)); break; case 1: CreateShape(node, typeof(CornerShape)); break; default: CreateShape(node, typeof(TeeShape)); break; } }
private static void GenerateRecursively(Node node, Direction prevOutDirection) { if (!node.IsAvailable) { return; } CreateShape(node, typeof(TeeShape)); FastRotateToConnection((TeeShape)node.Shape, prevOutDirection); //генерация ноды, если свободная клетка List <KeyValuePair <Node, Direction> > nodes = NodesGrid.FindAvailableNeighborNodesForShapeSides(node); foreach (var nodeDirPair in nodes) { GenerateRecursively(nodeDirPair.Key, nodeDirPair.Value.GetOpposite()); } }
private void CreateSofa(out Vector3 position, out Direction sofaDir, out int xIndex, out int yIndex) { sofaDir = (Direction)Random.Range(0, 4); //sofaDir = Direction.Left; Quaternion sofaQuaternion = DirectionUtils.DirectionToQuaternion(sofaDir); xIndex = 0; yIndex = 0; switch (sofaDir) { case Direction.Up: xIndex = Random.Range(2, 4); yIndex = Random.Range(3, 5); break; case Direction.Down: xIndex = 2; yIndex = Random.Range(2, 4); break; case Direction.Right: xIndex = Random.Range(3, 5); yIndex = Random.Range(2, 4); break; case Direction.Left: xIndex = Random.Range(2, 4); yIndex = Random.Range(2, 4); break; } NodesGrid.Node node = NodesGrid.Grid[xIndex, yIndex]; position = node.Position; var sofa = (Transform)Instantiate(_sofaPrefab, position, sofaQuaternion); GridAligner.AlignTwoNodeObject(sofa); sofa.parent = _furniture; }
public SpawnNode(NodesGrid.Node gridNode, int index) { Index = index; GridNode = gridNode; if (gridNode.Y == 0) MainDirection = Direction.Up; else if (gridNode.Y == 6) MainDirection = Direction.Down; else if (gridNode.X == 0) MainDirection = Direction.Right; else MainDirection = Direction.Left; if (gridNode.Y == 0 || gridNode.Y == 6) { if (gridNode.X == 0) DirectionInCover = Direction.Right; else if (gridNode.X == 6) DirectionInCover = Direction.Left; } }
private static void RemoveShape(Node node) { node.RemoveShape(); _shapesCount--; }
private static void CreateShape(Node node, Type shapeType) { GameObject prefab = null; switch (shapeType.Name) { case "LineShape": prefab = ResourcesLoader.LineShapePrefab; break; case "CornerShape": prefab = ResourcesLoader.CornerShapePrefab; break; case "TeeShape": prefab = ResourcesLoader.TeeShapePrefab; break; default: Debug.LogError("incorrect type - " + shapeType.Name); break; } Vector3 pos = new Vector3(node.X, _shapeYpos, node.Y); var shapeGO = (GameObject)Object.Instantiate(prefab, pos, new Quaternion(0, 0, 0, 0)); shapeGO.transform.parent = SceneContainers.Shapes; Shape retShape = shapeGO.GetComponent<Shape>(); node.SetShape(retShape); _shapesCount++; }