예제 #1
0
 public void Crossfade(float _changeTime, _Camera _linkedCamera)
 {
     object[] parms = new object[2] {
         _changeTime, _linkedCamera
     };
     StartCoroutine("StartCrossfade", parms);
 }
예제 #2
0
        protected void Start()
        {
            if (KickStarter.stateHandler)
            {
                KickStarter.stateHandler.Register(this);
            }

            Upgrade();

            if (limitToCameras.Count == 0 || KickStarter.mainCamera == null)
            {
                return;
            }

            activeCamera = KickStarter.mainCamera.attachedCamera;

            if (activeCamera != null && !isLockedOff)
            {
                if (limitToCameras.Contains(activeCamera))
                {
                    SetVisibility(true);
                }
                else
                {
                    SetVisibility(false);
                }
            }
            else
            {
                SetVisibility(false);
            }
        }
예제 #3
0
        /**
         * <summary>Upgrades the component to make use of the limitToCameras List, rather than the singular limitToCamera variable.</summary>
         */
        public void Upgrade()
        {
            if (limitToCameras == null)
            {
                limitToCameras = new List <_Camera>();
            }

            if (limitToCamera != null)
            {
                if (!limitToCameras.Contains(limitToCamera))
                {
                    limitToCameras.Add(limitToCamera);
                }
                limitToCamera = null;

                                #if UNITY_EDITOR
                if (Application.isPlaying)
                {
                    ACDebug.Log("LimitVisibility component on '" + gameObject.name + "' has been temporarily upgraded - please view its Inspector when the game ends and save the scene.");
                }
                else
                {
                    UnityVersionHandler.CustomSetDirty(this, true);
                    ACDebug.Log("Upgraded LimitVisibility on '" + gameObject.name + "', please save the scene.");
                }
                                #endif
            }
        }
예제 #4
0
 /**
  * <summary>Triggers the OnSwitchCamera event.</summary>
  * <param name = "dragBase">The object being picked up</param>
  */
 public void Call_OnSwitchCamera(_Camera fromCamera, _Camera toCamera, float transitionTime)
 {
     if (OnSwitchCamera != null)
     {
         OnSwitchCamera(fromCamera, toCamera, transitionTime);
     }
 }
예제 #5
0
 /**
  * <summary>Registers a _Camera, so that it can be updated</summary>
  * <param name = "_object">The _Camera to register</param>
  */
 public void Register(_Camera _object)
 {
     if (!cameras.Contains(_object))
     {
         cameras.Add(_object);
     }
 }
예제 #6
0
        override public void Skip()
        {
            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 (cam is GameCameraThirdPerson)
                    {
                        GameCameraThirdPerson tpCam = (GameCameraThirdPerson)cam;
                        tpCam.ResetRotation();
                    }

                    mainCam.SetGameCamera(cam);

                    cam.MoveCameraInstant();
                    mainCam.SnapToAttached();
                }
            }
        }
예제 #7
0
 /**
  * <summary>Unregisters a _Camera, so that it is no longer updated</summary>
  * <param name = "_object">The _Camera to unregister</param>
  */
 public void Unregister(_Camera _object)
 {
     if (cameras.Contains(_object))
     {
         cameras.Remove(_object);
     }
 }
예제 #8
0
        public override void ShowGUI(List <ActionParameter> parameters)
        {
            returnToLast = EditorGUILayout.Toggle("Return to last gameplay?", returnToLast);
            if (!returnToLast)
            {
                parameterID = Action.ChooseParameterGUI("New camera:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID   = 0;
                    linkedCamera = null;
                }
                else
                {
                    linkedCamera = (_Camera)EditorGUILayout.ObjectField("New camera:", linkedCamera, typeof(_Camera), true);

                    constantID   = FieldToID <_Camera> (linkedCamera, constantID);
                    linkedCamera = IDToField <_Camera> (linkedCamera, constantID, true);
                }
            }

            transitionTimeParameterID = Action.ChooseParameterGUI("Transition time (s):", parameters, transitionTimeParameterID, ParameterType.Float);
            if (transitionTimeParameterID < 0)
            {
                transitionTime = EditorGUILayout.FloatField("Transition time (s):", transitionTime);
            }

            fadeCurve = (AnimationCurve)EditorGUILayout.CurveField("Transition curve:", fadeCurve);
            willWait  = EditorGUILayout.Toggle("Wait until finish?", willWait);

            AfterRunningOption();
        }
예제 #9
0
        /**
         * Updates the visibility based on the attached camera. This is public so that it can be called by StateHandler.
         */
        public void _Update()
        {
            if (limitToCameras.Count == 0 || KickStarter.mainCamera == null)
            {
                return;
            }

            activeCamera     = KickStarter.mainCamera.attachedCamera;
            transitionCamera = KickStarter.mainCamera.GetTransitionFromCamera();

            if (isLockedOff)
            {
                if (isVisible)
                {
                    SetVisibility(false);
                }
                return;
            }

            if (activeCamera != null && limitToCameras.Contains(activeCamera))
            {
                SetVisibility(!negateEffect);
            }
            else if (transitionCamera != null && limitToCameras.Contains(transitionCamera))
            {
                SetVisibility(!negateEffect);
            }
            else
            {
                SetVisibility(negateEffect);
            }
        }
예제 #10
0
        /**
         * <summary>Custom (MG): Runs the Actions from a set point. Refers to a given camera.</summary>
         * <param name = "i">The index number of actions to start from</param>
         * <param name = "addToSkipQueue">If True, then the ActionList will be skipped when the user presses the 'EndCutscene' Input button</param>
         */
        public void InteractWithActionCamera(_Camera linkedCamera)
        {
            if (actions.Count > 0)
            {
                if (triggerTime > 0f)
                {
                    StartCoroutine("PauseUntilStart", true);
                }
                else
                {
                    isSkipping = false;
                    StopCoroutine("PauseUntilStart");
                    StopCoroutine("RunAction");
                    StopCoroutine("EndCutscene");

                    foreach (Action action in actions)
                    {
                        var actionCamera = action as ActionCamera;

                        if (actionCamera != null)
                        {
                            actionCamera.linkedCamera = linkedCamera;
                        }
                        action.isRunning = false;
                    }
                    ResetSkips();
                    BeginActionList(0, true);
                }
            }
            else
            {
                Kill();
            }
        }
예제 #11
0
        override public void Skip()
        {
            MainCamera mainCam = KickStarter.mainCamera;

            if (mainCam)
            {
                _Camera cam = linkedCamera;

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

                if (cam)
                {
                    if (cam is GameCameraThirdPerson)
                    {
                        GameCameraThirdPerson tpCam = (GameCameraThirdPerson)cam;
                        tpCam.ResetRotation();
                    }

                    cam.MoveCameraInstant();
                    mainCam.SetGameCamera(cam);
                }
            }
        }
예제 #12
0
        private void Start()
        {
            Upgrade();

            if (limitToCameras.Count == 0 || KickStarter.mainCamera == null)
            {
                return;
            }

            activeCamera = KickStarter.mainCamera.attachedCamera;

            if (activeCamera != null && !isLockedOff)
            {
                if (limitToCameras.Contains(activeCamera))
                {
                    SetVisibility(true);
                }
                else
                {
                    SetVisibility(false);
                }
            }
            else
            {
                SetVisibility(false);
            }
        }
예제 #13
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            bool showWaitOption = false;

            returnToLast = EditorGUILayout.Toggle("Return to last gameplay?", returnToLast);

            if (!returnToLast)
            {
                parameterID = Action.ChooseParameterGUI("New camera:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID   = 0;
                    linkedCamera = null;
                }
                else
                {
                    linkedCamera = (_Camera)EditorGUILayout.ObjectField("New camera:", linkedCamera, typeof(_Camera), true);

                    constantID   = FieldToID <_Camera> (linkedCamera, constantID);
                    linkedCamera = IDToField <_Camera> (linkedCamera, constantID, true);
                }

                if (linkedCamera && linkedCamera is GameCameraAnimated)
                {
                    GameCameraAnimated animatedCamera = (GameCameraAnimated)linkedCamera;
                    if (animatedCamera.animatedCameraType == AnimatedCameraType.PlayWhenActive && transitionTime <= 0f)
                    {
                        showWaitOption = true;
                    }
                }
            }

            if (linkedCamera is GameCamera25D && !returnToLast)
            {
                transitionTime = 0f;
            }
            else
            {
                transitionTime = EditorGUILayout.FloatField("Transition time (s):", transitionTime);

                if (transitionTime > 0f)
                {
                    moveMethod     = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod);
                    showWaitOption = true;

                    if (moveMethod == MoveMethod.CustomCurve)
                    {
                        timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve);
                    }
                }
            }

            if (showWaitOption)
            {
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            AfterRunningOption();
        }
예제 #14
0
 public override void OnGraphStop(Playable playable)
 {
     if (MainCamera != null)
     {
         lastFrameCamera = null;
         MainCamera.ReleaseTimelineOverride();
     }
 }
예제 #15
0
 protected void OnSwitchCamera(_Camera oldCamera, _Camera newCamera, float transitionTime)
 {
     if (limitToCamera == null)
     {
         return;
     }
     LimitToActiveCamera(newCamera);
 }
        override public void AssignValues(List <ActionParameter> parameters)
        {
            linkedCamera = AssignFile <_Camera> (parameters, parameterID, constantID, linkedCamera);

            if (returnToLast)
            {
                linkedCamera = KickStarter.mainCamera.GetLastGameplayCamera();
            }
        }
예제 #17
0
        /**
         * <summary>Creates a new instance of the 'Camera: Crossfade' Action with key variables already set.</summary>
         * <param name = "newCamera">The camera to crossfade to</param>
         * <param name = "transitionTime">The time, in seconds, to take while transitioning to the new camera</param>
         * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete<param>
         * <returns>The generated Action</returns>
         */
        public static ActionCameraCrossfade CreateNew(_Camera newCamera, float transitionTime = 1f, bool waitUntilFinish = false)
        {
            ActionCameraCrossfade newAction = (ActionCameraCrossfade)CreateInstance <ActionCameraCrossfade>();

            newAction.linkedCamera   = newCamera;
            newAction.transitionTime = transitionTime;
            newAction.willWait       = waitUntilFinish;
            return(newAction);
        }
예제 #18
0
        public override void AssignValues(List<ActionParameter> parameters)
        {
            linkedCamera = AssignFile <_Camera> (parameters, parameterID, constantID, linkedCamera);

            if (returnToLast)
            {
                linkedCamera = KickStarter.mainCamera.GetLastGameplayCamera ();
            }
        }
예제 #19
0
 /**
  * <summary>Goes through all Hotspots in the scene, and limits their enabed state based on a specific _Camera, if appropriate.</summary>
  * <param name = "_camera">The _Camera to attempt to limit all Hotspots to</param>
  */
 public void LimitHotspotsToCamera(_Camera _camera)
 {
     if (_camera != null)
     {
         for (_i = 0; _i < hotspots.Count; _i++)
         {
             hotspots[_i].LimitToCamera(_camera);
         }
     }
 }
예제 #20
0
        /**
         * <summary>Creates a new instance of the 'Camera: Split-screen' Action, set to overlay one camera over another</summary>
         * <param name = "underlayCamera">The camera to display full-screen underneath</param>
         * <param name = "overlayCamera">The camera to display on top</param>
         * <param name = "overlayRect">The portion of the screen that the overlay camera is drawn in</param>
         * <returns>The generated Action</returns>
         */
        public static ActionCameraSplit CreateNew_Overlay(_Camera underlayCamera, _Camera overlayCamera, Rect overlayRect)
        {
            ActionCameraSplit newAction = (ActionCameraSplit)CreateInstance <ActionCameraSplit>();

            newAction.orientation = CameraSplitOrientation.Overlay;
            newAction.cam1        = underlayCamera;
            newAction.cam2        = overlayCamera;
            newAction.overlayRect = overlayRect;
            return(newAction);
        }
        /**
         * <summary>Creates a new instance of the 'Camera: Switch' Action with key variables already set.</summary>
         * <param name = "newCamera">The camera to switch to</param>
         * <param name = "duration">The time, in seconds, to take while transitioning to the new camera</param>
         * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete<param>
         * <param name = "moveMethod">The method of moving from the current camera to the new camera, if transitionTime > 0</param>
         * <returns>The generated Action</returns>
         */
        public static ActionCamera CreateNew(_Camera newCamera, float duration = 0f, bool waitUntilFinish = true, MoveMethod moveMethod = MoveMethod.Smooth)
        {
            ActionCamera newAction = (ActionCamera)CreateInstance <ActionCamera>();

            newAction.linkedCamera   = newCamera;
            newAction.transitionTime = duration;
            newAction.moveMethod     = moveMethod;
            newAction.willWait       = waitUntilFinish;
            return(newAction);
        }
예제 #22
0
 /**
  * <summary>Goes through all Hotspots in the scene, and limits their enabed state based on a specific _Camera, if appropriate.</summary>
  * <param name = "_camera">The _Camera to attempt to limit all Hotspots to</param>
  */
 public void LimitHotspotsToCamera(_Camera _camera)
 {
     if (_camera != null)
     {
         foreach (Hotspot hotspot in hotspots)
         {
             hotspot.LimitToCamera(_camera);
         }
     }
 }
예제 #23
0
        public override void AssignValues(List <ActionParameter> parameters)
        {
            runtimeLinkedCamera = AssignFile <_Camera> (parameters, parameterID, constantID, linkedCamera);
            transitionTime      = AssignFloat(parameters, transitionTimeParameterID, transitionTime);

            if (returnToLast)
            {
                runtimeLinkedCamera = KickStarter.mainCamera.GetLastGameplayCamera();
            }
        }
예제 #24
0
        public void RemoveSplitScreen()
        {
            isSplitScreen = false;
            SetCameraRect();

            if (splitCamera)
            {
                splitCamera.RemoveSplitScreen();
                splitCamera = null;
            }
        }
예제 #25
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            turnOff = EditorGUILayout.Toggle("Disable previous split?", turnOff);
            if (!turnOff)
            {
                string label1 = "Top";
                string label2 = "Bottom";

                orientation = (MenuOrientation)EditorGUILayout.EnumPopup("Divider:", orientation);
                if (orientation == MenuOrientation.Vertical)
                {
                    label1 = "Left";
                    label2 = "Right";
                }

                parameterID1 = Action.ChooseParameterGUI(label1 + " camera:", parameters, parameterID1, ParameterType.GameObject);
                if (parameterID1 >= 0)
                {
                    constantID1 = 0;
                    cam1        = null;
                }
                else
                {
                    cam1 = (_Camera)EditorGUILayout.ObjectField(label1 + " camera:", cam1, typeof(_Camera), true);

                    constantID1 = FieldToID <_Camera> (cam1, constantID1);
                    cam1        = IDToField <_Camera> (cam1, constantID1, false);
                }

                splitAmount1 = EditorGUILayout.Slider(label1 + " camera space:", splitAmount1, 0f, 1f);

                parameterID2 = Action.ChooseParameterGUI(label2 + " camera:", parameters, parameterID2, ParameterType.GameObject);
                if (parameterID2 >= 0)
                {
                    constantID2 = 0;
                    cam2        = null;
                }
                else
                {
                    cam2 = (_Camera)EditorGUILayout.ObjectField(label2 + " camera:", cam2, typeof(_Camera), true);

                    constantID2 = FieldToID <_Camera> (cam2, constantID2);
                    cam2        = IDToField <_Camera> (cam2, constantID2, false);
                }

                splitAmount2 = Mathf.Min(splitAmount2, 1f - splitAmount1);
                splitAmount2 = EditorGUILayout.Slider(label2 + " camera space:", splitAmount2, 0f, 1f);
                splitAmount1 = Mathf.Min(splitAmount1, 1f - splitAmount2);

                mainIsTopLeft = EditorGUILayout.Toggle("Main Camera is " + label1.ToLower() + "?", mainIsTopLeft);
            }

            AfterRunningOption();
        }
예제 #26
0
        /**
         * <summary>Creates a new instance of the 'Camera: Split-screen' Action, set to arrange two cameras side by side</summary>
         * <param name = "leftCamera">The camera to on the left</param>
         * <param name = "rightCamera">The camera to display on the right</param>
         * <param name = "leftIsActive">If True, the left camera will be interactive. Otherwise, the right camera will be</param>
         * <param name = "leftCameraSpace">The proportion of the screen's width that the left camera takes up</param>
         * <param name = "rightCameraSpace">The proportion of the screen's width that the right camera takes up</param>
         * <returns>The generated Action</returns>
         */
        public static ActionCameraSplit CreateNew_SideBySide(_Camera leftCamera, _Camera rightCamera, bool leftIsActive = true, float leftCameraSpace = 0.49f, float rightCameraSpace = 0.49f)
        {
            ActionCameraSplit newAction = (ActionCameraSplit)CreateInstance <ActionCameraSplit>();

            newAction.orientation   = CameraSplitOrientation.Vertical;
            newAction.cam1          = leftCamera;
            newAction.cam2          = rightCamera;
            newAction.mainIsTopLeft = leftIsActive;
            newAction.splitAmount1  = leftCameraSpace;
            newAction.splitAmount2  = rightCameraSpace;
            return(newAction);
        }
예제 #27
0
        public void SetSplitScreen(_Camera _camera1, _Camera _camera2, MenuOrientation _splitOrientation, bool _isTopLeft, float splitAmountMain, float splitAmountOther)
        {
            splitCamera      = _camera2;
            isSplitScreen    = true;
            splitOrientation = _splitOrientation;
            isTopLeftSplit   = _isTopLeft;

            SetGameCamera(_camera1);
            SnapToAttached();

            StartSplitScreen(splitAmountMain, splitAmountOther);
        }
예제 #28
0
        /**
         * <summary>Creates a new instance of the 'Camera: Split-screen' Action, set to arrange two cameras above and below each other</summary>
         * <param name = "topCamera">The camera to at the top</param>
         * <param name = "bottomCamera">The camera to display at the bottom</param>
         * <param name = "topIsActive">If True, the top camera will be interactive. Otherwise, the bottom camera will be</param>
         * <param name = "topCameraSpace">The proportion of the screen's height that the top camera takes up</param>
         * <param name = "bottomCameraSpace">The proportion of the screen's height that the bottom camera takes up</param>
         * <returns>The generated Action</returns>
         */
        public static ActionCameraSplit CreateNew_AboveAndBelow(_Camera topCamera, _Camera bottomCamera, bool topIsActive = true, float topCameraSpace = 0.49f, float bottomCameraSpace = 0.49f)
        {
            ActionCameraSplit newAction = (ActionCameraSplit)CreateInstance <ActionCameraSplit>();

            newAction.orientation   = CameraSplitOrientation.Horizontal;
            newAction.cam1          = topCamera;
            newAction.cam2          = bottomCamera;
            newAction.mainIsTopLeft = topIsActive;
            newAction.splitAmount1  = topCameraSpace;
            newAction.splitAmount2  = bottomCameraSpace;
            return(newAction);
        }
예제 #29
0
        public override void OnGraphStop(Playable playable)
        {
            if (MainCamera)
            {
                lastFrameCamera = null;
                MainCamera.ReleaseTimelineOverride();

                if (callCustomEvents && lastFrameCamera != KickStarter.mainCamera.attachedCamera)
                {
                    KickStarter.eventManager.Call_OnSwitchCamera(lastFrameCamera, KickStarter.mainCamera.attachedCamera, 0f);
                }
            }
        }
예제 #30
0
        private void Start()
        {
            activeCamera = KickStarter.mainCamera.attachedCamera;

            if (activeCamera == limitToCamera)
            {
                SetVisibility (true);
            }
            else if (activeCamera != limitToCamera)
            {
                SetVisibility (false);
            }
        }
예제 #31
0
        private void Update()
        {
            activeCamera = KickStarter.mainCamera.attachedCamera;

            if (activeCamera == limitToCamera && !isVisible)
            {
                SetVisibility(true);
            }
            else if (activeCamera != limitToCamera && isVisible)
            {
                SetVisibility(false);
            }
        }
예제 #32
0
        public override void OnInspectorGUI()
        {
            _Camera _target = (_Camera)target;

            EditorGUILayout.HelpBox("Attach this script to a custom Camera type to integrate it with Adventure Creator.", MessageType.Info);

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Depth of field", EditorStyles.boldLabel);
            _target.focalDistance = EditorGUILayout.FloatField("Focal distance", _target.focalDistance);
            EditorGUILayout.EndVertical();

            UnityVersionHandler.CustomSetDirty(_target);
        }
예제 #33
0
        /**
         * Updates the visibility based on the attached camera. This is public so that it can be called by StateHandler.
         */
        public void _Update()
        {
            activeCamera = KickStarter.mainCamera.attachedCamera;

            if (!isLockedOff)
            {
                if (activeCamera == limitToCamera && !isVisible)
                {
                    SetVisibility (true);
                }
                else if (activeCamera != limitToCamera && isVisible)
                {
                    SetVisibility (false);
                }
            }
            else if (isVisible)
            {
                SetVisibility (false);
            }
        }
예제 #34
0
 public override void AssignValues(List<ActionParameter> parameters)
 {
     linkedCamera = AssignFile <_Camera> (parameters, parameterID, constantID, linkedCamera);
     transitionTime = AssignFloat (parameters, transitionTimeParameterID, transitionTime);
 }
		override public void ShowGUI (List<ActionParameter> parameters)
		{
			parameterID = Action.ChooseParameterGUI ("New camera:", parameters, parameterID, ParameterType.GameObject);
			if (parameterID >= 0)
			{
				constantID = 0;
				linkedCamera = null;
			}
			else
			{
				linkedCamera = (_Camera) EditorGUILayout.ObjectField ("New camera:", linkedCamera, typeof(_Camera), true);
				
				constantID = FieldToID <_Camera> (linkedCamera, constantID);
				linkedCamera = IDToField <_Camera> (linkedCamera, constantID, true);
			}

			transitionTime = EditorGUILayout.FloatField ("Transition time (s):", transitionTime);
			willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait);

			AfterRunningOption ();
		}
		override public void AssignValues (List<ActionParameter> parameters)
		{
			linkedCamera = AssignFile <_Camera> (parameters, parameterID, constantID, linkedCamera);
		}
예제 #37
0
        /**
         * <summary>Creates a new split-screen effect.</summary>
         * <param name = "_camera1">The first _Camera to use in the effect</param>
         * <param name = "_camera2">The second _Camera to use in the effect</param>
         * <param name = "_splitOrientation">How the two _Cameras are arranged (Horizontal, Vertical)</param>
         * <param name = "_isTopLeft">If True, the MainCamera will take the position of _camera1</param>
         * <param name = "_splitAmountMain">The proportion of the screen taken up by this Camera</param>
         * <param name = "_splitAmountOther">The proportion of the screen take up by the other _Camera</param>
         */
        public void SetSplitScreen(_Camera _camera1, _Camera _camera2, MenuOrientation _splitOrientation, bool _isTopLeft, float _splitAmountMain, float _splitAmountOther)
        {
            splitCamera = _camera2;
            isSplitScreen = true;
            splitOrientation = _splitOrientation;
            isTopLeftSplit = _isTopLeft;

            SetGameCamera (_camera1);
            StartSplitScreen (_splitAmountMain, _splitAmountOther);
        }
예제 #38
0
        /**
         * <summary>Sets a _Camera as the new attachedCamera to follow.</summary>
         * <param name = "newCamera">The new _Camera to follow</param>
         * <param name = "transitionTime">The time, in seconds, that it will take to move towards the new _Camera</param>
         * <param name = "_moveMethod">How the Camera should move towards the new _Camera, if transitionTime > 0f (Linear, Smooth, Curved, EaseIn, EaseOut, CustomCurve)</param>
         * <param name = "_animationCurve">The AnimationCurve that dictates movement over time, if _moveMethod = MoveMethod.CustomCurve</param>
         */
        public void SetGameCamera(_Camera newCamera, float transitionTime = 0f, MoveMethod _moveMethod = MoveMethod.Linear, AnimationCurve _animationCurve = null)
        {
            if (newCamera == null)
            {
                return;
            }

            if (attachedCamera != null && attachedCamera is GameCamera25D)
            {
                if (newCamera is GameCamera25D)
                { }
                else
                {
                    RemoveBackground ();
                }
            }

            AssignOwnCamera ();
            _camera.ResetProjectionMatrix ();
            attachedCamera = newCamera;
            attachedCamera.SetCameraComponent ();

            if (attachedCamera && attachedCamera._camera)
            {
                _camera.farClipPlane = attachedCamera._camera.farClipPlane;
                _camera.nearClipPlane = attachedCamera._camera.nearClipPlane;
                _camera.orthographic = attachedCamera._camera.orthographic;
            }

            // Set LookAt
            if (attachedCamera is GameCamera)
            {
                GameCamera gameCam = (GameCamera) attachedCamera;
                cursorAffectsRotation = gameCam.followCursor;
                lookAtAmount = gameCam.cursorInfluence;
            }
            else if (attachedCamera is GameCameraAnimated)
            {
                GameCameraAnimated gameCam = (GameCameraAnimated) attachedCamera;
                if (gameCam.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
                {
                    cursorAffectsRotation = gameCam.followCursor;
                    lookAtAmount = gameCam.cursorInfluence;
                }
                else
                {
                    cursorAffectsRotation = false;
                }
            }
            else
            {
                cursorAffectsRotation = false;
            }

            // Set background
            if (attachedCamera is GameCamera25D)
            {
                GameCamera25D cam25D = (GameCamera25D) attachedCamera;
                cam25D.SetActiveBackground ();
            }

            // TransparencySortMode
            if (attachedCamera is GameCamera2D)
            {
                _camera.transparencySortMode = TransparencySortMode.Orthographic;
            }
            else if (attachedCamera)
            {
                if (attachedCamera._camera.orthographic)
                {
                    _camera.transparencySortMode = TransparencySortMode.Orthographic;
                }
                else
                {
                    _camera.transparencySortMode = TransparencySortMode.Perspective;
                }
            }

            // UFPS
            if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
            {
                UltimateFPSIntegration._Update (KickStarter.stateHandler.gameState);
            }

            KickStarter.stateHandler.LimitHotspotsToCamera (attachedCamera);

            if (transitionTime > 0f)
            {
                SmoothChange (transitionTime, _moveMethod, _animationCurve);
            }
            else if (attachedCamera != null)
            {
                attachedCamera.MoveCameraInstant ();
                SnapToAttached ();
            }
        }
예제 #39
0
        /**
         * Activates the FirstPersonCamera found in the Player prefab.
         */
        public void SetFirstPerson()
        {
            FirstPersonCamera firstPersonCamera = KickStarter.player.GetComponentInChildren<FirstPersonCamera>();
            if (firstPersonCamera)
            {
                SetGameCamera (firstPersonCamera);
            }

            if (attachedCamera)
            {
                if (lastNavCamera != attachedCamera)
                {
                    lastNavCamera2 = lastNavCamera;
                }

                lastNavCamera = attachedCamera;
            }
        }
예제 #40
0
        /**
         * Ends any active split-screen effect.
         */
        public void RemoveSplitScreen()
        {
            isSplitScreen = false;
            SetCameraRect ();

            if (splitCamera)
            {
                splitCamera.RemoveSplitScreen ();
                splitCamera = null;
            }
        }
예제 #41
0
 /**
  * <summary>Crossfades to a new _Camera over time.</summary>
  * <param name = "_changeTime">The duration, in seconds, of the crossfade</param>
  * <param name = "_linkedCamera">The _Camera to crossfade to</param>
  */
 public void Crossfade(float _changeTime, _Camera _linkedCamera)
 {
     object[] parms = new object[2] { _changeTime, _linkedCamera};
     StartCoroutine ("StartCrossfade", parms);
 }
예제 #42
0
        /**
         * Updates the Camera's position.
         * This is called every frame by StateHandler.
         */
        public void _LateUpdate()
        {
            if (KickStarter.settingsManager && KickStarter.settingsManager.IsInLoadingScene ())
            {
                return;
            }

            if (KickStarter.stateHandler.gameState == GameState.Normal)
            {
                if (attachedCamera)
                {
                    if (lastNavCamera != attachedCamera)
                    {
                        lastNavCamera2 = lastNavCamera;
                    }

                    lastNavCamera = attachedCamera;
                }
            }

            if (attachedCamera && (!(attachedCamera is GameCamera25D)))
            {
                if (!isSmoothChanging)
                {
                    transform.rotation = attachedCamera.transform.rotation;
                    transform.position = attachedCamera.transform.position;
                    focalDistance = attachedCamera.focalDistance;

                    if (attachedCamera is GameCamera2D)
                    {
                        GameCamera2D cam2D = (GameCamera2D) attachedCamera;
                        perspectiveOffset = cam2D.GetPerspectiveOffset ();
                        if (!_camera.orthographic)
                        {
                            _camera.projectionMatrix = AdvGame.SetVanishingPoint (_camera, perspectiveOffset);
                        }
                        else
                        {
                            _camera.orthographicSize = attachedCamera._camera.orthographicSize;
                        }
                    }

                    else
                    {
                        _camera.fieldOfView = attachedCamera._camera.fieldOfView;
                        if (cursorAffectsRotation)
                        {
                            SetlookAtTransformation ();
                            transform.LookAt (lookAtTransform, attachedCamera.transform.up);
                        }
                    }
                }
                else
                {
                    // Move from one GameCamera to another
                    if (Time.time < startTime + changeTime)
                    {
                        if (attachedCamera is GameCamera2D)
                        {
                            GameCamera2D cam2D = (GameCamera2D) attachedCamera;

                            perspectiveOffset.x = AdvGame.Lerp (startPerspectiveOffset.x, cam2D.GetPerspectiveOffset ().x, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));
                            perspectiveOffset.y = AdvGame.Lerp (startPerspectiveOffset.y, cam2D.GetPerspectiveOffset ().y, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));

                            _camera.ResetProjectionMatrix ();
                        }

                        if (moveMethod == MoveMethod.Curved)
                        {
                            // Don't slerp y position as this will create a "bump" effect
                            Vector3 newPosition = Vector3.Slerp (startPosition, attachedCamera.transform.position, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));
                            newPosition.y = Mathf.Lerp (startPosition.y, attachedCamera.transform.position.y, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));
                            transform.position = newPosition;

                            transform.rotation = Quaternion.Slerp (startRotation, attachedCamera.transform.rotation, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));
                        }
                        else
                        {
                            transform.position = AdvGame.Lerp (startPosition, attachedCamera.transform.position, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));
                            transform.rotation = AdvGame.Lerp (startRotation, attachedCamera.transform.rotation, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));
                        }

                        focalDistance = AdvGame.Lerp (startFocalDistance, attachedCamera.focalDistance, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));
                        _camera.fieldOfView = AdvGame.Lerp (startFOV, attachedCamera._camera.fieldOfView, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));
                        _camera.orthographicSize = AdvGame.Lerp (startOrtho, attachedCamera._camera.orthographicSize, AdvGame.Interpolate (startTime, changeTime, moveMethod, timeCurve));

                        if (attachedCamera is GameCamera2D && !_camera.orthographic)
                        {
                            _camera.projectionMatrix = AdvGame.SetVanishingPoint (_camera, perspectiveOffset);
                        }
                    }
                    else
                    {
                        LookAtCentre ();
                        isSmoothChanging = false;
                    }
                }

                if (cursorAffectsRotation && lookAtTransform != null)
                {
                    lookAtTransform.localPosition = Vector3.Lerp (lookAtTransform.localPosition, lookAtTarget, Time.deltaTime * 3f);
                }
            }

            else if (attachedCamera && (attachedCamera is GameCamera25D))
            {
                transform.position = attachedCamera.transform.position;
                transform.rotation = attachedCamera.transform.rotation;
            }

            // Shake
            if (shakeIntensity > 0f)
            {
                if (shakeMove)
                {
                    shakePosition = Random.insideUnitSphere * shakeIntensity * 0.5f;
                }

                shakeRotation = new Vector3
                    (
                        Random.Range (-shakeIntensity, shakeIntensity) * 0.2f,
                        Random.Range (-shakeIntensity, shakeIntensity) * 0.2f,
                        Random.Range (-shakeIntensity, shakeIntensity) * 0.2f
                        );

                shakeIntensity = Mathf.Lerp (shakeStartIntensity, 0f, AdvGame.Interpolate (shakeStartTime, shakeDuration, MoveMethod.Linear, null));

                transform.position += shakePosition;
                transform.localEulerAngles += shakeRotation;
            }
            else if (shakeIntensity < 0f)
            {
                StopShaking ();
            }
        }
예제 #43
0
 public void LimitToCamera(_Camera _limitToCamera)
 {
     if (limitToCamera != null && _limitToCamera != null)
     {
         if (_limitToCamera == limitToCamera && isOn)
         {
             TurnOn (false);
         }
         else
         {
             TurnOff (false);
         }
     }
 }
예제 #44
0
        /**
         * <summary>Custom (MG): Runs the Actions from a set point. Refers to a given camera.</summary>
         * <param name = "i">The index number of actions to start from</param>
         * <param name = "addToSkipQueue">If True, then the ActionList will be skipped when the user presses the 'EndCutscene' Input button</param>
         */
        public void InteractWithActionCamera(_Camera linkedCamera)
        {
            if (actions.Count > 0)
            {
                if (triggerTime > 0f)
                {
                    StartCoroutine("PauseUntilStart", true);
                }
                else
                {
                    isSkipping = false;
                    StopCoroutine("PauseUntilStart");
                    StopCoroutine("RunAction");
                    StopCoroutine("EndCutscene");

                    foreach (Action action in actions)
                    {
                        var actionCamera = action as ActionCamera;

                        if (actionCamera != null)
                        {
                            actionCamera.linkedCamera = linkedCamera;
                        }
                        action.isRunning = false;
                    }
                    ResetSkips();
                    BeginActionList(0, true);
                }
            }
            else
            {
                Kill();
            }
        }
예제 #45
0
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            bool showWaitOption = false;
            returnToLast = EditorGUILayout.Toggle ("Return to last gameplay?", returnToLast);

            if (!returnToLast)
            {
                parameterID = Action.ChooseParameterGUI ("New camera:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID = 0;
                    linkedCamera = null;
                }
                else
                {
                    linkedCamera = (_Camera) EditorGUILayout.ObjectField ("New camera:", linkedCamera, typeof (_Camera), true);

                    constantID = FieldToID <_Camera> (linkedCamera, constantID);
                    linkedCamera = IDToField <_Camera> (linkedCamera, constantID, true);
                }

                if (linkedCamera && linkedCamera is GameCameraAnimated)
                {
                    GameCameraAnimated animatedCamera = (GameCameraAnimated) linkedCamera;
                    if (animatedCamera.animatedCameraType == AnimatedCameraType.PlayWhenActive && transitionTime <= 0f)
                    {
                        showWaitOption = true;
                    }
                }
            }

            if (linkedCamera is GameCamera25D && !returnToLast)
            {
                transitionTime = 0f;
            }
            else
            {
                transitionTimeParameterID = Action.ChooseParameterGUI ("Transition time (s):", parameters, transitionTimeParameterID, ParameterType.Float);
                if (transitionTimeParameterID < 0)
                {
                    transitionTime = EditorGUILayout.FloatField ("Transition time (s):", transitionTime);
                }

                if (transitionTime > 0f)
                {
                    moveMethod = (MoveMethod) EditorGUILayout.EnumPopup ("Move method:", moveMethod);
                    showWaitOption = true;

                    if (moveMethod == MoveMethod.CustomCurve)
                    {
                        timeCurve = EditorGUILayout.CurveField ("Time curve:", timeCurve);
                    }
                }
            }

            if (showWaitOption)
            {
                willWait = EditorGUILayout.Toggle ("Wait until finish?", willWait);
            }

            AfterRunningOption ();
        }
		override public void AssignValues (List<ActionParameter> parameters)
		{
			cam1 = AssignFile <_Camera> (parameters, parameterID1, constantID1, cam1);
			cam2 = AssignFile <_Camera> (parameters, parameterID2, constantID2, cam2);
		}
		override public void ShowGUI (List<ActionParameter> parameters)
		{
			turnOff = EditorGUILayout.Toggle ("Disable previous split?", turnOff);
			if (!turnOff)
			{
				string label1 = "Top";
				string label2 = "Bottom";

				orientation = (MenuOrientation) EditorGUILayout.EnumPopup ("Divider:", orientation);
				if (orientation == MenuOrientation.Vertical)
				{
					label1 = "Left";
					label2 = "Right";
				}

				parameterID1 = Action.ChooseParameterGUI (label1 + " camera:", parameters, parameterID1, ParameterType.GameObject);
				if (parameterID1 >= 0)
				{
					constantID1 = 0;
					cam1 = null;
				}
				else
				{
					cam1 = (_Camera) EditorGUILayout.ObjectField (label1 + " camera:", cam1, typeof (_Camera), true);
					
					constantID1 = FieldToID <_Camera> (cam1, constantID1);
					cam1 = IDToField <_Camera> (cam1, constantID1, false);
				}

				splitAmount1 = EditorGUILayout.Slider (label1 + " camera space:", splitAmount1, 0f, 1f);

				parameterID2 = Action.ChooseParameterGUI (label2 + " camera:", parameters, parameterID2, ParameterType.GameObject);
				if (parameterID2 >= 0)
				{
					constantID2 = 0;
					cam2 = null;
				}
				else
				{
					cam2 = (_Camera) EditorGUILayout.ObjectField (label2 + " camera:", cam2, typeof (_Camera), true);
					
					constantID2 = FieldToID <_Camera> (cam2, constantID2);
					cam2 = IDToField <_Camera> (cam2, constantID2, false);
				}

				splitAmount2 = Mathf.Min (splitAmount2, 1f-splitAmount1);
				splitAmount2 = EditorGUILayout.Slider (label2 + " camera space:", splitAmount2, 0f, 1f);
				splitAmount1 = Mathf.Min (splitAmount1, 1f-splitAmount2);

				mainIsTopLeft = EditorGUILayout.Toggle ("Main Camera is " + label1.ToLower () + "?", mainIsTopLeft);
			}
			
			AfterRunningOption ();
		}
예제 #48
0
 public void LimitHotspotsToCamera(_Camera _camera)
 {
     if (_camera != null)
     {
         foreach (Hotspot hotspot in hotspots)
         {
             hotspot.LimitToCamera (_camera);
         }
     }
 }