示例#1
0
    Room SpawnRoom(RoomData nextRoomData, Room previousRoom = null, Exits exit = Exits.NONE)
    {     // Spawns a room and aligns it with the exit in question
        if (exit != Exits.NONE)
        { // Checks to make sure the exit works
            if (!nextRoomData.ContainsExit(exit))
            {
                Debug.LogWarning("Tried to connect room (" + nextRoomData + ") that does not contain exit " + GetOppositeExit(exit));
                return(null);
            }
        }
        ;
        // This allows for the first room to spawn
        Vector3 oldPosition = transform.position;

        if (previousRoom != null)
        {
            oldPosition = previousRoom.transform.position;
        }
        GameObject returnRoomGO = GameObject.Instantiate(nextRoomData.prefab_, GetNewPosition(oldPosition, exit), Quaternion.identity);
        Room       returnRoom   = returnRoomGO.GetComponent <Room>();

        // Set room type, and room's new coordinates
        returnRoom.roomType_ = nextRoomData;
        if (previousRoom != null)
        {
            returnRoom.coordinate_     = GetNewCoordinates(coordinates_[previousRoom], GetOppositeExit(exit));
            returnRoom.gameObject.name = returnRoom.roomType_.name_ + "(" + returnRoom.coordinate_ + ")";
        }
        return(returnRoom);
    }
示例#2
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);
     }
 }
示例#3
0
    // Use this for initialization
    public void Start()
    {
        data = GetComponent <Room>().roomType_;
        if (data == null)
        {
            Debug.LogWarning("No data set. Set data.");
            return;
        }

        foreach (Door door in doors)
        {
            if (data.ContainsExit(door.direction))
            {
                door.doorObj.SetActive(false);
            }
            else
            {
                door.doorObj.SetActive(true);
            }
        }
    }