Exemple #1
0
    // this REQUIRES that the memos are placed in such a way that players can NEVER pick them up from inside the trigger zone
    IEnumerator roomSwitch()
    {
        // close door
        doorClosing = true;
        Door.Instance.TryCloseDoor();
        yield return(new WaitWhile(() => Door.Instance.Open));

        doorClosing = false;

        // switch rooms
        currentRoom.Despawn();
        if (destroyCurrentRoomOnSwitch)
        {
            destroyCurrentRoomOnSwitch = false;
            Destroy(currentRoom.gameObject);             // ... onSwitch
        }

        currentRoom    = waitingRoom;
        currentRoomDir = currentRoomDir.Flipped();

        if (pooledRooms.Count > 0)
        {
            nextRoomIndex = (int)Mathf.Repeat(nextRoomIndex + 1, pooledRooms.Count);
            var nextPrefab = pooledRooms[nextRoomIndex];
            waitingRoom = nextPrefab.Respawn(currentRoomDir.Flipped());
        }

        nextIsBedroom = false;

        currentRoomTrigger = currentRoomDir.IsPositive() ? FrontTrigger : BackTrigger;
        waitingRoomTrigger = currentRoomDir.IsNegative() ? FrontTrigger : BackTrigger;
    }
Exemple #2
0
    // moves an already instantiated room
    public Room Respawn(ZDir direction)
    {
        switchLights(true);

        if (twin != null)
        {
            return(twin);
        }

        if (spawned)
        {
            Room twinning = Initialize(this, direction);

            twinning.twin = this;
            twin          = twinning;

            return(twin);
        }

        spawned = true;

        transform.position    = Vector3.zero;
        transform.eulerAngles = new Vector3(0, direction.IsNegative() ? 0 : 180, 0);

        return(this);
    }
Exemple #3
0
    // define the direction of the room as the direction you face when walking into it
    public static Room Initialize(Room room, ZDir direction)
    {
        room.spawned = true;

        var r = Instantiate(room);

        r.transform.eulerAngles = new Vector3(0, direction.IsNegative() ? 0 : 180, 0);
        return(r);
    }