示例#1
0
    void ConnectRooms()
    {
        LinkedList <RoomNode> newCorridors  = new LinkedList <RoomNode> ();
        LinkedList <RoomNode> existingRooms = new LinkedList <RoomNode> ();

        Util.LLAppend <RoomNode> (existingRooms, roomNodeList);
        foreach (RoomNode roomA in roomNodeList)
        {
            foreach (RoomNode roomB in roomNodeList)
            {
                if (roomA != roomB && !roomA.connections.Contains(roomB))
                {
                    Vector3 touchDir = RoomNode.CheckRoomTouch(roomA.octTreeNode.boundary, roomB.octTreeNode.boundary);
                    if (touchDir != Vector3.zero && ((Random.Range(0, 100) < 50) || !roomA.ConnectsTo(roomB)))
                    {
                        RoomNode.MakeConnections(roomA, roomB);
                        foreach (RoomNode c in ConnectTwoRooms(roomA, roomB, existingRooms))
                        {
                            newCorridors.AddFirst(c);
                            existingRooms.AddFirst(c);
                        }
                    }
                }
            }
        }

        foreach (RoomNode c in newCorridors)
        {
            roomNodeList.AddFirst(c);
        }
    }
示例#2
0
 void ConnectMulti()
 {
     foreach (RoomGenerator a in roomGens)
     {
         foreach (RoomNode roomA in a.roomNodeList)
         {
             foreach (RoomGenerator b in roomGens)
             {
                 if (a != b)
                 {
                     foreach (RoomNode roomB in b.roomNodeList)
                     {
                         if (!roomA.isCorridor && !roomB.isCorridor && !roomA.connections.Contains(roomB))
                         {
                             Vector3 touchDir = RoomNode.CheckRoomTouch(roomA.octTreeNode.boundary, roomB.octTreeNode.boundary);
                             if (touchDir != Vector3.zero && ((Random.Range(0, 100) < 33) || !roomA.ConnectsTo(roomB)))
                             {
                                 RoomNode.MakeConnections(roomA, roomB);
                                 foreach (RoomNode c in a.BuildCorridors(roomA, roomB, Vector3.zero, allRooms))
                                 {
                                     interCorridors.AddFirst(c);
                                     allRooms.AddFirst(c);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#3
0
 public static void FurnishRooms(LinkedList <RoomNode> roomList, RoomStyle rmstyle, GameObject doorConnector)
 {
     foreach (RoomNode room in roomList)
     {
         if (room.isCorridor == false)
         {
             PlatformAssembler asm = room.roomObject.AddComponent <PlatformAssembler>();
             asm.placeableObjects = rmstyle.placeablePlatforms;
             LinkedList <PlatformingElement> doors = new LinkedList <PlatformingElement>();
             foreach (RoomNode neighbor in room.neighbors)
             {
                 Bounds overl = RoomNode.OverlapBounds(room.roomBounds, neighbor.roomBounds);
                 if (overl.extents.y > 0.01f)
                 {
                     GameObject newDoorPiece = (GameObject)Instantiate(doorConnector, overl.center - Vector3.Scale(Vector3.up, overl.extents), Quaternion.LookRotation(RoomNode.CheckRoomTouch(neighbor.roomBounds, room.roomBounds)));
                     doors.AddFirst(newDoorPiece.GetComponent <PlatformingElement>());
                 }
                 else
                 {
                     GameObject newDoorPiece = (GameObject)Instantiate(doorConnector, overl.center, Quaternion.LookRotation(RoomNode.CheckRoomTouch(neighbor.roomBounds, room.roomBounds)));
                     doors.AddFirst(newDoorPiece.GetComponent <PlatformingElement>());
                 }
             }
             if (doors.Count > 1)
             {
                 PlatformingElement[] starts = new PlatformingElement[doors.Count];
                 int doorind = 0;
                 foreach (PlatformingElement pe in doors)
                 {
                     starts[doorind++] = pe;
                 }
                 asm.ConnectDoorPieces(starts);
             }
         }
     }
 }