override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                MainCamera mainCam = KickStarter.mainCamera;
                RunSelf(mainCam, fadeSpeed);

                if (willWait && !isInstant)
                {
                    return(fadeSpeed);
                }

                return(0f);
            }

            else
            {
                isRunning = false;
                return(0f);
            }
        }
        protected void RunSelf(MainCamera mainCam, float _time)
        {
            if (mainCam == null)
            {
                return;
            }

            mainCam.StopCrossfade();

            if (fadeType == FadeType.fadeIn)
            {
                if (isInstant)
                {
                    mainCam.FadeIn(0f);
                }
                else
                {
                    mainCam.FadeIn(_time, forceCompleteTransition);
                }
            }
            else
            {
                Texture2D texToUse = tempTexture;
                if (!setTexture)
                {
                    texToUse = null;
                }

                float timeToFade = _time;
                if (isInstant)
                {
                    timeToFade = 0f;
                }

                mainCam.FadeOut(timeToFade, texToUse, forceCompleteTransition);
            }
        }
		private void RunSelf (MainCamera mainCam, float _time)
		{
			if (mainCam == null)
			{
				return;
			}

			mainCam.StopCrossfade ();

			if (fadeType == FadeType.fadeIn)
			{
				if (isInstant)
				{
					mainCam.FadeIn (0f);
				}
				else
				{
					mainCam.FadeIn (_time);
				}
			}
			else
			{
				Texture2D texToUse = tempTexture;
				if (!setTexture)
				{
					texToUse = null;
				}

				float timeToFade = _time;
				if (isInstant)
				{
					timeToFade = 0f;
				}

				mainCam.FadeOut (timeToFade, texToUse);
			}
		}
Exemple #4
0
        public override float Run()
        {
            if (!isRunning)
            {
                isRunning = true;
                MainCamera mainCam = KickStarter.mainCamera;

                if (runtimeLinkedCamera && mainCam.attachedCamera != runtimeLinkedCamera)
                {
                    if (runtimeLinkedCamera is GameCameraThirdPerson)
                    {
                        GameCameraThirdPerson tpCam = (GameCameraThirdPerson)runtimeLinkedCamera;
                        tpCam.ResetRotation();
                    }
                    else if (runtimeLinkedCamera is GameCameraAnimated)
                    {
                        GameCameraAnimated animCam = (GameCameraAnimated)runtimeLinkedCamera;
                        animCam.PlayClip();
                    }

                    runtimeLinkedCamera.MoveCameraInstant();
                    mainCam.Crossfade(transitionTime, runtimeLinkedCamera, fadeCurve);

                    if (transitionTime > 0f && willWait)
                    {
                        return(transitionTime);
                    }
                }
            }
            else
            {
                isRunning = false;
            }

            return(0f);
        }
Exemple #5
0
        protected void RunSelf(MainCamera mainCam, float _time)
        {
            if (mainCam == null)
            {
                return;
            }

            mainCam.StopCrossfade();

            if (isInstant)
            {
                _time = 0f;
            }

            if (fadeType == FadeType.fadeIn)
            {
                mainCam.FadeIn(_time, forceCompleteTransition, cameraFadePauseBehaviour, fadeCurve);
            }
            else
            {
                Texture2D texToUse = (setTexture) ? tempTexture : null;
                mainCam.FadeOut(_time, texToUse, forceCompleteTransition, cameraFadePauseBehaviour, fadeCurve);
            }
        }
Exemple #6
0
        /**
         * <summary>Syncs the component with the correct scene.</summary>
         * <param name = "_multiSceneChecker">The MultiSceneChecker component in the scene for which this component is to sync with.</param>
         */
        public void Initialise(MultiSceneChecker _multiSceneChecker)
        {
                        #if UNITY_5_3 || UNITY_5_4 || UNITY_5_3_OR_NEWER
            UnityEngine.SceneManagement.Scene scene = _multiSceneChecker.gameObject.scene;
            gameObject.name = "SubScene " + scene.buildIndex;

            kickStarter = _multiSceneChecker.GetComponent <KickStarter>();

            sceneInfo = new SceneInfo(scene.name, scene.buildIndex);

            localVariables = _multiSceneChecker.GetComponent <LocalVariables>();
            sceneSettings  = _multiSceneChecker.GetComponent <SceneSettings>();

            UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(gameObject, scene);

            kickStarter = UnityVersionHandler.GetOwnSceneInstance <KickStarter> (gameObject);
            if (kickStarter != null)
            {
                kickStarter.gameObject.SetActive(false);
            }

            mainCamera = UnityVersionHandler.GetOwnSceneInstance <MainCamera> (gameObject);
            if (mainCamera != null)
            {
                mainCamera.gameObject.SetActive(false);
            }

            Player ownPlayer = UnityVersionHandler.GetOwnSceneInstance <Player> (gameObject);
            if (ownPlayer != null)
            {
                ownPlayer.gameObject.SetActive(false);
            }

            KickStarter.sceneChanger.RegisterSubScene(this);
                        #endif
        }
Exemple #7
0
        /**
         * <summary>Syncs the component with the correct scene.</summary>
         * <param name = "_multiSceneChecker">The MultiSceneChecker component in the scene for which this component is to sync with.</param>
         */
        public void Initialise(MultiSceneChecker _multiSceneChecker)
        {
            Scene scene = _multiSceneChecker.gameObject.scene;

            gameObject.name = "SubScene " + scene.buildIndex;

            kickStarter = _multiSceneChecker.GetComponent <KickStarter>();

            sceneIndex = scene.buildIndex;

            localVariables = _multiSceneChecker.GetComponent <LocalVariables>();
            sceneSettings  = _multiSceneChecker.GetComponent <SceneSettings>();

            UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(gameObject, scene);

            kickStarter = _multiSceneChecker.GetComponent <KickStarter> ();
            _multiSceneChecker.gameObject.SetActive(false);

            mainCamera = UnityVersionHandler.GetOwnSceneInstance <MainCamera> (gameObject);
            if (mainCamera != null)
            {
                mainCamera.gameObject.SetActive(false);
            }

            Player ownPlayer = UnityVersionHandler.GetOwnSceneInstance <Player> (gameObject);

            if (ownPlayer != null)
            {
                ownPlayer.gameObject.SetActive(false);
            }
            if (sceneSettings.OverridesCameraPerspective())
            {
                ACDebug.LogError("The added scene (" + scene.name + ", " + scene.buildIndex + ") overrides the default camera perspective - this feature should not be used in conjunction with multiple-open scenes.", gameObject);
            }
            KickStarter.sceneChanger.RegisterSubScene(this);
        }
Exemple #8
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            base.ProcessFrame(playable, info, playerData);

            if (MainCamera == null)
            {
                return;
            }

            int      activeInputs   = 0;
            ClipInfo clipA          = new ClipInfo();
            ClipInfo clipB          = new ClipInfo();
            float    shakeIntensity = 0f;

            for (int i = 0; i < playable.GetInputCount(); ++i)
            {
                float weight = playable.GetInputWeight(i);
                ScriptPlayable <MainCameraPlayableBehaviour> clip = (ScriptPlayable <MainCameraPlayableBehaviour>)playable.GetInput(i);

                MainCameraPlayableBehaviour shot = clip.GetBehaviour();

                if (shot != null)
                {
                    callCustomEvents = shot.callCustomEvents;
                }

                if (shot != null &&
                    shot.IsValid &&
                    playable.GetPlayState() == PlayState.Playing &&
                    weight > 0.0001f)
                {
                    clipA = clipB;

                    clipB.camera         = shot.gameCamera;
                    clipB.weight         = weight;
                    clipB.localTime      = clip.GetTime();
                    clipB.duration       = clip.GetDuration();
                    clipB.shakeIntensity = shot.shakeIntensity;

                    if (++activeInputs == 2)
                    {
                        break;
                    }
                }
            }
            // Figure out which clip is incoming
            bool incomingIsB = clipB.weight >= 1 || clipB.localTime < clipB.duration / 2;

            if (activeInputs == 2)
            {
                if (clipB.localTime > clipA.localTime)
                {
                    incomingIsB = true;
                }
                else if (clipB.localTime < clipA.localTime)
                {
                    incomingIsB = false;
                }
                else
                {
                    incomingIsB = clipB.duration >= clipA.duration;
                }
            }

            shakeIntensity = incomingIsB ? clipB.shakeIntensity : clipA.shakeIntensity;

            _Camera cameraA    = incomingIsB ? clipA.camera : clipB.camera;
            _Camera cameraB    = incomingIsB ? clipB.camera : clipA.camera;
            float   camWeightB = incomingIsB ? clipB.weight : 1 - clipB.weight;

            if (cameraB == null)
            {
                cameraB    = cameraA;
                cameraA    = null;
                camWeightB = 1f - camWeightB;
            }

            if (incomingIsB)
            {
                shakeIntensity = (clipA.shakeIntensity * (1f - camWeightB)) + (clipB.shakeIntensity * camWeightB);
            }
            else
            {
                shakeIntensity = (clipB.shakeIntensity * (1f - camWeightB)) + (clipA.shakeIntensity * camWeightB);
            }

            MainCamera.SetTimelineOverride(cameraA, cameraB, camWeightB, shakeIntensity);

            if (callCustomEvents)
            {
                _Camera thisFrameCamera = (incomingIsB) ? cameraB : cameraA;
                if (thisFrameCamera != lastFrameCamera)
                {
                    KickStarter.eventManager.Call_OnSwitchCamera(lastFrameCamera, thisFrameCamera, 0f);
                    lastFrameCamera = thisFrameCamera;
                }
            }
        }
Exemple #9
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                MainCamera mainCam = KickStarter.mainCamera;

                if (mainCam)
                {
                    _Camera cam = linkedCamera;

                    if (returnToLast)
                    {
                        cam = mainCam.GetLastGameplayCamera();
                    }

                    if (cam)
                    {
                        if (mainCam.attachedCamera != cam)
                        {
                            if (cam is GameCameraThirdPerson)
                            {
                                GameCameraThirdPerson tpCam = (GameCameraThirdPerson)cam;
                                tpCam.ResetRotation();
                            }
                            else if (cam is GameCameraAnimated)
                            {
                                GameCameraAnimated animCam = (GameCameraAnimated)cam;
                                animCam.PlayClip();
                            }

                            if (transitionTime > 0f && linkedCamera is GameCamera25D)
                            {
                                mainCam.SetGameCamera(cam, 0f);
                                ACDebug.LogWarning("Switching to a 2.5D camera (" + linkedCamera.name + ") must be instantaneous.", linkedCamera);
                            }
                            else
                            {
                                mainCam.SetGameCamera(cam, transitionTime, moveMethod, timeCurve, retainPreviousSpeed);

                                if (willWait)
                                {
                                    if (transitionTime > 0f)
                                    {
                                        return(transitionTime);
                                    }
                                    else if (linkedCamera is GameCameraAnimated)
                                    {
                                        return(defaultPauseTime);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (linkedCamera is GameCameraAnimated && willWait)
                {
                    GameCameraAnimated animatedCamera = (GameCameraAnimated)linkedCamera;
                    if (animatedCamera.isPlaying())
                    {
                        return(defaultPauseTime);
                    }
                    else
                    {
                        isRunning = false;
                        return(0f);
                    }
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }

            return(0f);
        }
Exemple #10
0
        private void DoShake(MainCamera mainCam, float _intensity, float _duration)
        {
            if (mainCam.attachedCamera is GameCamera)
            {
                mainCam.Shake (_intensity / 67f, _duration, true);
            }

            else if (mainCam.attachedCamera is GameCamera25D)
            {
                mainCam.Shake (_intensity / 67f, _duration, true);

                GameCamera25D gameCamera = (GameCamera25D) mainCam.attachedCamera;
                if (gameCamera.backgroundImage)
                {
                    gameCamera.backgroundImage.Shake (_intensity / 0.67f, _duration);
                }
            }

            else if (mainCam.attachedCamera is GameCamera2D)
            {
                mainCam.Shake (_intensity / 33f, _duration, false);
            }

            else
            {
                mainCam.Shake (_intensity / 67f, _duration, false);
            }
        }
Exemple #11
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                MainCamera mainCam = KickStarter.mainCamera;

                if (mainCam)
                {
                    _Camera cam = linkedCamera;

                    if (returnToLast && mainCam.lastNavCamera)
                    {
                        if (mainCam.lastNavCamera != null && mainCam.attachedCamera == mainCam.lastNavCamera)
                        {
                            cam = (_Camera)mainCam.lastNavCamera2;
                        }
                        else
                        {
                            cam = (_Camera)mainCam.lastNavCamera;
                        }
                    }

                    if (cam)
                    {
                        if (mainCam.attachedCamera != cam)
                        {
                            if (cam is GameCameraThirdPerson)
                            {
                                GameCameraThirdPerson tpCam = (GameCameraThirdPerson)cam;
                                tpCam.ResetRotation();
                            }
                            else if (cam is GameCameraAnimated)
                            {
                                GameCameraAnimated animCam = (GameCameraAnimated)cam;
                                animCam.PlayClip();
                            }

                            mainCam.SetGameCamera(cam);
                            if (transitionTime > 0f)
                            {
                                if (linkedCamera is GameCamera25D)
                                {
                                    mainCam.SnapToAttached();
                                    Debug.LogWarning("Switching to a 2.5D camera (" + linkedCamera.name + ") must be instantaneous.");
                                }
                                else
                                {
                                    mainCam.SmoothChange(transitionTime, moveMethod, timeCurve);

                                    if (willWait)
                                    {
                                        return(transitionTime);
                                    }
                                }
                            }
                            else
                            {
                                cam.MoveCameraInstant();
                                mainCam.SnapToAttached();

                                if (linkedCamera is GameCameraAnimated && willWait)
                                {
                                    return(defaultPauseTime);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (linkedCamera is GameCameraAnimated && willWait)
                {
                    GameCameraAnimated animatedCamera = (GameCameraAnimated)linkedCamera;
                    if (animatedCamera.isPlaying())
                    {
                        return(defaultPauseTime);
                    }
                    else
                    {
                        isRunning = false;
                        return(0f);
                    }
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }

            return(0f);
        }
Exemple #12
0
        /**
         * <summary>Unsets the values of all script variables, so that they can be re-assigned to the correct scene if multiple scenes are open.</summary>
         */
        public void ClearVariables()
        {
            playerPrefab = null;
            mainCameraPrefab = null;
            persistentEnginePrefab = null;
            gameEnginePrefab = null;

            // Managers
            sceneManagerPrefab = null;
            settingsManagerPrefab = null;
            actionsManagerPrefab = null;
            variablesManagerPrefab = null;
            inventoryManagerPrefab = null;
            speechManagerPrefab = null;
            cursorManagerPrefab = null;
            menuManagerPrefab = null;

            // PersistentEngine components
            optionsComponent = null;
            runtimeInventoryComponent = null;
            runtimeVariablesComponent = null;
            playerMenusComponent = null;
            stateHandlerComponent = null;
            sceneChangerComponent = null;
            saveSystemComponent = null;
            levelStorageComponent = null;
            runtimeLanguagesComponent = null;

            // GameEngine components
            menuSystemComponent = null;
            dialogComponent = null;
            playerInputComponent = null;
            playerInteractionComponent = null;
            playerMovementComponent = null;
            playerCursorComponent = null;
            playerQTEComponent = null;
            sceneSettingsComponent = null;
            navigationManagerComponent = null;
            actionListManagerComponent = null;
            localVariablesComponent = null;
            menuPreviewComponent = null;

            SetGameEngine ();
        }
Exemple #13
0
        public static Rect _LimitMenuToAspect(Rect rect)
        {
            if (mainCam == null)
            {
                mainCam = KickStarter.mainCamera;
            }

            if (mainCam != null)
            {
                return mainCam.LimitMenuToAspect (rect);
            }

            return rect;
        }
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            base.ProcessFrame(playable, info, playerData);

            if (MainCamera == null)
            {
                return;
            }

            int      activeInputs = 0;
            ClipInfo clipA        = new ClipInfo();
            ClipInfo clipB        = new ClipInfo();

            for (int i = 0; i < playable.GetInputCount(); ++i)
            {
                float weight = playable.GetInputWeight(i);
                ScriptPlayable <MainCameraPlayableBehaviour> clip = (ScriptPlayable <MainCameraPlayableBehaviour>)playable.GetInput(i);

                MainCameraPlayableBehaviour shot = clip.GetBehaviour();
                if (shot != null &&
                    shot.IsValid &&
                    playable.GetPlayState() == PlayState.Playing &&
                    weight > 0.0001f)
                {
                    clipA           = clipB;
                    clipB.camera    = shot.gameCamera;
                    clipB.weight    = weight;
                    clipB.localTime = clip.GetTime();
                    clipB.duration  = clip.GetDuration();

                    if (++activeInputs == 2)
                    {
                        break;
                    }
                }
            }

            // Figure out which clip is incoming
            bool incomingIsB = clipB.weight >= 1 || clipB.localTime < clipB.duration / 2;

            if (activeInputs == 2)
            {
                if (clipB.localTime > clipA.localTime)
                {
                    incomingIsB = true;
                }
                else if (clipB.localTime < clipA.localTime)
                {
                    incomingIsB = false;
                }
                else
                {
                    incomingIsB = clipB.duration >= clipA.duration;
                }
            }

            _Camera cameraA    = incomingIsB ? clipA.camera : clipB.camera;
            _Camera cameraB    = incomingIsB ? clipB.camera : clipA.camera;
            float   camWeightB = incomingIsB ? clipB.weight : 1 - clipB.weight;

            if (cameraB == null)
            {
                cameraB    = cameraA;
                cameraA    = null;
                camWeightB = 1f - camWeightB;
            }

            MainCamera.SetTimelineOverride(cameraA, cameraB, camWeightB);
        }