示例#1
0
    HallSection SpawnHall(ZDir direction)
    {
        Vector3 loc;

        if (direction.IsPositive())
        {
            loc = halls[frontierPos].transform.position + Vector3.forward * HallSection.ZLength;
        }
        else
        {
            loc = halls[frontierNeg].transform.position + Vector3.back * HallSection.ZLength;
        }
        var hall = Instantiate(HallObject, loc, Quaternion.identity);

        hall.TriggerHandler  += HallTriggerHandler;
        hall.transform.parent = transform;

        if (direction.IsPositive())
        {
            halls[++frontierPos] = hall;
        }
        else
        {
            halls[--frontierNeg] = hall;
        }

        return(hall);
    }
示例#2
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;
    }
示例#3
0
    public void Initialize(ZDir direction)
    {
        initialized = true;

        Memo.MemoPickedUp += onMemoPickedUp;

        Vector3 pos = transform.position + (direction.IsPositive() ? Vector3.forward : Vector3.back) * HallSection.ZLength / 2;

        halls    = new Dictionary <int, HallSection>(MaxSections);
        halls[0] = Instantiate(HallObject, pos, Quaternion.identity);
        halls[0].TriggerHandler  += HallTriggerHandler;
        halls[0].transform.parent = transform;

        for (int i = 1; i < MaxSections; i++)
        {
            SpawnHall(direction);
        }
    }