Exemple #1
0
    private void UseDoor()
    {
        if (!_linkedDoor)
        {
            return;
        }

        if (_autoLinkBack)
        {
            _linkedDoor._linkedDoor = this;
        }

        RoomScript otherRoom = _linkedDoor.GetComponentInParent <RoomScript>();

        foreach (Renderer renderer in otherRoom.GetComponentsInChildren <Renderer>())
        {
            renderer.enabled = true;
        }

        player.transform.SetParent(otherRoom.transform);

        player.transform.localPosition = _linkedDoor.transform.localPosition;
        player.GetComponent <PlayerMovement>().Update();

        if (_frontDoor)
        {
            StartCoroutine(Tweening(this, _linkedDoor));
        }
        else
        {
            StartCoroutine(Tweening(_linkedDoor, this));
        }
    }
Exemple #2
0
    IEnumerator Tweening(DoorBehaviour front, DoorBehaviour back)
    {
        camera.GetComponent <CameraBehaviour>().target      = back.gameObject;
        main_camera.GetComponent <CameraBehaviour>().target = front.gameObject;

        RoomScript frontRoom = front.GetComponentInParent <RoomScript>();

        player.GetComponent <PlayerMovement>().enabled     = false;
        player.GetComponent <PlayerInteractions>().enabled = false;

        float alpha  = 0.0f;
        float offset = 0.0f;

        for (float i = 0.0f; i <= 1.0f; i += 0.025f)
        {
            alpha = i;

            if (!frontDoor)
            {
                alpha = 1 - i;
            }

            offset = alpha * frontRoom.depth;

            main_camera.GetComponent <CameraBehaviour>().ZOffset = offset;
            camera.GetComponent <CameraBehaviour>().ZOffset      = offset - frontRoom.depth;

            tweenBehaviour.SetAlpha(alpha);

            yield return(null);
        }

        main_camera.GetComponent <CameraBehaviour>().target  = player;
        main_camera.GetComponent <CameraBehaviour>().ZOffset = 0.0f;

        yield return(null);

        tweenBehaviour.SetAlpha(0.0f);

        player.GetComponent <PlayerMovement>().enabled     = true;
        player.GetComponent <PlayerInteractions>().enabled = true;

        RoomScript oldRoom;
        RoomScript newRoom;

        if (frontDoor)
        {
            oldRoom = frontRoom;
            newRoom = back.GetComponentInParent <RoomScript>();
        }
        else
        {
            oldRoom = back.GetComponentInParent <RoomScript>();
            newRoom = frontRoom;
        }

        if (newRoom != GetComponentInParent <RoomScript>())
        {
            foreach (Renderer renderer in oldRoom.GetComponentsInChildren <Renderer>())
            {
                renderer.enabled = false;
            }
        }
    }