Example #1
0
    public void SwitchWorld(int worldID)
    {
        //  Get the current world camera
        Camera currentCamera = GetCurrentWorldCamera();

        isCurrentlyTransitioning = true;

        //  Update the layer
        Layers.ChangeLayers(playerController.gameObject, Layers.ViewAlways);

        //  Cache the player's position in normalized screen space coordinates.
        Vector2 transitionCenter = currentCamera.WorldToViewportPoint(playerController.transform.position);

        //  Determine which world ID to switch to and check if world is already active.
        if (worldID == 1)
        {
            //  Update world state
            CurrentWorldState = WorldState.Present;

            //  Update the parallax cameras
            UpdateParallaxes(CurrentWorldState);

            //  Perform transition
            cameraTransition.DoTransition(CameraTransitionEffects.SmoothCircle, currentCamera, PresentCamera, transitionDuration, new object[] { false, transitionEdgeSmoothness, transitionCenter });
        }
        else if (worldID == 2)
        {
            //  Update world state
            CurrentWorldState = WorldState.Past;

            //  Update the parallax cameras
            UpdateParallaxes(CurrentWorldState);

            //  Perform transition
            cameraTransition.DoTransition(CameraTransitionEffects.SmoothCircle, currentCamera, PastCamera, transitionDuration, new object[] { false, transitionEdgeSmoothness, transitionCenter });
        }
        else if (worldID == 3)
        {
            //  Update world state
            CurrentWorldState = WorldState.Future;

            //  Update the parallax cameras
            UpdateParallaxes(CurrentWorldState);

            //  Perform transition
            cameraTransition.DoTransition(CameraTransitionEffects.SmoothCircle, currentCamera, FutureCamera, transitionDuration, new object[] { false, transitionEdgeSmoothness, transitionCenter });
        }
    }
    public bool start()
    {
        if (m_cameraTransition != null)
        {
            return(false);
        }
        // TODO: CameraTransitionBehaviour不能支持多个transition特效公用一个behaviour对象
        m_cameraTransition = m_manager.addComponent(typeof(CameraTransition)) as CameraTransition;
        m_cameraTransition.ProgressMode = CameraTransition.ProgressModes.Manual;
        m_cameraTransition.Progress     = 0;
        m_cameraTransition.enabled      = true;

        if (m_cameraTransition == null || m_manager == null || m_duration <= 0)
        {
            return(false);
        }
        Camera from = m_manager.getMainCamera();
        Camera to   = m_manager.getSecondCamera();

        if (from == null || to == null)
        {
            return(false);
        }
        m_cameraTransition.DoTransition(CameraTransitionEffects.CrossFade, from, to, m_duration, null);
        return(true);
    }
Example #3
0
    public void TransitionToCamera(int CameraIndex)
    {
        previousCameraIndex = currentCameraIndex;

        PanelObjects[CameraIndex].SetActive(true);

        //  Cache the button position in normalized screen space coordinates.
        Vector2 transitionCenter = Cameras[currentCameraIndex].ScreenToViewportPoint(Input.mousePosition);

        playerAudio.randomizePitch(menuSound);
        int randomIndex = Random.Range(0, timeWarps.Length);

        menuSound.PlayOneShot(timeWarps[randomIndex]);

        //  Perform the transition
        cameraTransition.DoTransition(CameraTransitionEffects.SmoothCircle, Cameras[currentCameraIndex], Cameras[CameraIndex], transitionDuration, new object[] { false, transitionEdgeSmoothness, transitionCenter });

        //  Update player position
        playerTransform.position = new Vector3(playerTransform.position.x, playerTransform.position.y, Cameras[CameraIndex].transform.position.z + 5);

        currentCameraIndex = CameraIndex;
    }