Esempio n. 1
0
 void Start()
 {
     AmbientAudio.Initialise();
     Music.Initialise();
     lensCapAnimation.SwitchLensCapState(LensCapState.OPENING);
     telescopeCreak.audioSource.PlayOneShot(telescopeCreak.lensCapSlideOpen);
 }
Esempio n. 2
0
    //void FadeInOverlay()
    //{
    //    if (gameState == GameState.INTRO)
    //    {
    //        Vector3 distance = transform.position - fadePosition.position;
    //        distance.z = 0.0f;

    //        if (distance.magnitude < fadeDistance)
    //        {
    //            GetComponent<UnityStandardAssets.ImageEffects.ScreenOverlay>().intensity = Mathf.Lerp(GetComponent<UnityStandardAssets.ImageEffects.ScreenOverlay>().intensity, Mathf.Lerp(0.0f, 1.0f, 1.0f - Mathf.Clamp01((zoomSize - minFadeSize) / (maxFadeSize / minFadeSize))), Time.deltaTime * 2f);
    //        }
    //        else
    //        {
    //            GetComponent<UnityStandardAssets.ImageEffects.ScreenOverlay>().intensity = Mathf.Lerp(GetComponent<UnityStandardAssets.ImageEffects.ScreenOverlay>().intensity, 0.0f, Time.deltaTime * 10);
    //        }
    //    }
    //    else
    //    {
    //        GetComponent<UnityStandardAssets.ImageEffects.ScreenOverlay>().intensity = Mathf.Lerp(GetComponent<UnityStandardAssets.ImageEffects.ScreenOverlay>().intensity, 1.0f, Time.deltaTime * 1.5f);
    //    }
    //}

    public void CheckZoomZones()
    {
        ZoomZone highestPriorityZone = null;

        foreach (ZoomZone zoomZone in zoomZones)
        {
            if (zoomZone)
            {
                // Check if the zoom zone is linked and should jump
                float zoomJump = zoomZone.GetLinkedZoomJump(Camera.main.GetComponent <Collider>().bounds);

                if (zoomJump != 0.0f)
                {
                    if (gameState == GameState.INTRO)
                    {
                        gameState = GameState.MAIN;
                        SaveManager.Save_PassedIntro();
                    }

                    ZoomZone linkedZoomZone = zoomZone.GetLinkedZoomZone();

                    Vector3 newCameraPosition = linkedZoomZone.transform.position + zoomZone.GetZoomZoneOffset(Camera.main.transform.position) * zoomJump;

                    Debug.Log("Zoom Offset: " + zoomZone.GetZoomZoneOffset(Camera.main.transform.position), zoomZone);
                    Debug.Log("Zoom Jump: " + zoomJump, zoomZone);

                    Camera.main.transform.position = new Vector3(newCameraPosition.x, newCameraPosition.y, Camera.main.transform.position.z);
                    zoomSize = zoomSize * zoomJump;

                    if (Camera.main.orthographic)
                    {
                        Camera.main.orthographicSize     = zoomSize;
                        Camera.main.transform.localScale = Vector3.one * zoomSize;
                    }
                    else
                    {
                        Camera.main.fieldOfView = zoomSize;
                    }

                    zoomZone.UnRecordZoomZone(linkedZoomZone);
                    linkedZoomZone.RecordZoomZone(zoomZone);

                    //Ambient Audio
                    if (linkedZoomZone.ambientSound != null && AmbientAudio.currentTrack != linkedZoomZone.ambientSound)
                    {
                        if (AmbientAudio.isFading)
                        {
                            StopCoroutine(AmbientAudio.GetFadeCoroutine());
                        }

                        AmbientAudio.SetFadeCoroutine(StartCoroutine(AmbientAudio.FadeAudio(linkedZoomZone.ambientSound)));
                    }

                    //Music
                    if (linkedZoomZone.musicTrack != null && Music.currentTrack != linkedZoomZone.musicTrack)
                    {
                        if (Music.isFading)
                        {
                            StopCoroutine(Music.GetFadeCoroutine());
                        }

                        Music.SetFadeCoroutine(StartCoroutine(Music.FadeAudio(linkedZoomZone.musicTrack)));
                    }
                }

                if (zoomZone.InsideZoomZone(Camera.main.transform.position) && (highestPriorityZone == null || zoomZone.priority > highestPriorityZone.priority))
                {
                    highestPriorityZone = zoomZone;
                }

                if (zoomJump != 0.0f)
                {
                    break;
                }
            }
        }

        if (highestPriorityZone)
        {
            float minZoomSize = highestPriorityZone.GetMinZoomAtPoint(Camera.main.transform.position);

            if (minZoomSize > zoomSize)
            {
                zoomSize = Mathf.Lerp(zoomSize, minZoomSize, Time.deltaTime);
            }
        }
    }