Ejemplo n.º 1
0
    private void GenerateLevel(RoomNode node, RoomTransformation prevChunk)
    {
        //Place the Chunk somewhere, where it won't collide with another chunk
        GameObject chunk = InstantiateChunk(node, new Vector3(tmpChunkPos, 0f, tmpChunkStep));

        if (isConstraintError)
        {
            return;
        }

        tmpChunkPos += tmpChunkStep;
        //Obtain the actual position, the chunk will have later on
        Vector3            chunkSize     = ChunkSize(chunk);
        RoomTransformation roomTransform = new RoomTransformation(chunk, node.Position, chunkSize, spacing);

        roomTransform.AddConnection(prevChunk);
        positionMeta.Add(roomTransform);
        debugData.AddRoomMeta(chunk, node);

        if (prevChunk != null)
        {
            HallwayMeta hallway = prevChunk.FindMatchingDoors(roomTransform);
            hallwayMeta.Add(hallway);
        }

        //Recursively generate subrooms
        foreach (RoomNode subNode in node.Connections)
        {
            GenerateLevel(subNode, roomTransform);
        }
    }