Exemplo n.º 1
0
        public IEnumerator LeaveRoomImmediate(DoorBetweenLevels door)
        {
            heldItem   = combiningItem = null;
            targetItem = null;
            if (door.zoomoutCircleTransformPosition != null)
            {
                SetInCutScene(true, CutsceneTools.Type.ZoomOut, door.zoomoutCircleTransformPosition.position, false, 0.0001f);
            }
            else
            {
                SetInCutScene(true, CutsceneTools.Type.ZoomOut, transform.position + door.zoomoutCircleOffset, false, 0.0001f);
            }

            PersistentEngine.SetArrivalDoor(SceneManager.GetActiveScene().path);

            audioManager.Fadeout();

            scene.arrivalCave = -1;

            if (door.GetLevelIndex() == -1)
            {
                LoadLevelInternal(0);
            }
            else
            {
                LoadLevelInternal(door.GetLevelIndex());
            }

            yield return(null);
        }
Exemplo n.º 2
0
        public IEnumerator LeaveRoom(DoorBetweenLevels door, State walkOption = State.WalkSide)
        {
            heldItem   = combiningItem = null;
            targetItem = null;

            if (!staticCharacter)
            {
                if (door.zoomoutCircleTransformPosition != null)
                {
                    Debug.Log("LeaveRoom transfrom pos" + door);
                    SetInCutScene(true, CutsceneTools.Type.ZoomOut, door.zoomoutCircleTransformPosition.position, false, 0.0001f, false);
                }
                else
                {
                    SetInCutScene(true, CutsceneTools.Type.ZoomOut, transform.position + door.zoomoutCircleOffset, false, 0.0001f, false);
                }

                autoPilotTarget = door.outsideOffset + door.gameObject.transform.position;
                autoPilotDelta  = autoPilotTarget - transform.position;
                isInAutopilot   = true;
                autoPilotSpeed  = 1 / 1.5f;
                autoPilotSpeed  = door.walkInOutSpeed;

                ChangeState(walkOption);
                direction = transform.position.x < (autoPilotTarget.x) ? 1 : -1;
                ProcessDirectionAndScale(false);
            }

            PersistentEngine.SetArrivalDoor(SceneManager.GetActiveScene().path);

            audioManager.Fadeout();

            if (!staticCharacter)
            {
                float maxTime   = 1 / autoPilotSpeed;
                float startTime = Time.time;
                float dist      = 100f;
                while (true)
                {
                    dist = Vector3.Distance(transform.position, door.transform.position + door.outsideOffset);
                    if (dist < 0.1f)
                    {
                        break;
                    }
                    if (Time.time - startTime > maxTime)
                    {
                        break;
                    }
                    yield return(new WaitForSeconds(0.02f));
                }
            }
            StartCoroutine(DisableAutopilot(true));
            yield return(StartCoroutine(door.ExitTranslationAnimation()));

            scene.arrivalCave = -1;

            if (door.GetLevelIndex() == -1)
            {
                LoadLevelInternal(0);
            }
            else
            {
                LoadLevelInternal(door.GetLevelIndex());
            }
        }