Esempio n. 1
0
 public bool AttemptConnectRoom(Room room, Exits exit, bool connectReverse = false)
 { //This should not happen, as we should check for exits first
     if (!roomType_.ContainsExit(exit))
     {
         Debug.LogWarning("Cannot connect " + room + " to exit " + exit + ", " + roomType_.name_ + " does not have it");
         return(false);
     }
     ;
     if (connectedRooms_.ContainsKey(exit))
     { // Already contains the exit
         Debug.Log("Cannot connect to exit " + exit + ", " + this + " already has a connection. (connecting reverse: " + connectReverse + ")");
         return(false);
     }
     else
     {
         connectedRooms_.Add(exit, room);
         if (connectReverse)
         {
             room.AttemptConnectRoom(this, FacilitySpawner.GetOppositeExit(exit));
         }
         connectedRoomsDebug_.Add(room.gameObject);
         connectedRoomsDebugDirs_.Add(exit);
         Debug.Log("Connected the exit " + exit + "of this room (" + this + ") to " + room + "(connectReverse: " + connectReverse + ")");
         return(true);
     }
 }
Esempio n. 2
0
 public void AttemptConnectAll(bool connectReverse = true)
 { // Attempts to connect all exits, based on the coordinate data
     foreach (Exits exit in roomType_.exits_)
     {
         if (!connectedRooms_.ContainsKey(exit))
         {
             // See if there's something in that direction
             if (!FacilitySpawner.TryCoordinatesStatic(this, exit))
             {
                 // Find the room that is there, and attempt a double-sided connection
                 Room occupyingRoom = FacilitySpawner.instance_.ReturnRoomAtCoordinates(FacilitySpawner.GetNewCoordinates(coordinate_, exit));
                 if (occupyingRoom != null)
                 {
                     if (occupyingRoom.roomType_.ContainsExit(FacilitySpawner.GetOppositeExit(exit)))
                     {
                         this.AttemptConnectRoom(occupyingRoom, exit, connectReverse);
                     }
                     ;
                 }
             }
         }
     }
 }