Пример #1
0
    public void BlendTo(CinemachineVirtualCamera blendToCamera, bool alertGlobally = true, bool doHardBlend = false)
    {
        // This can fail when we first start the game, so lets check for it
        if (!IsActiveCameraValid())
        {
            return;
        }

        CinemachineVirtualCamera fromCamera = GetActiveVirtualCamera();

        // early exit, because we cannot blend between the same cameras??
        if (!fromCamera || blendToCamera == fromCamera)
        {
            return;
        }

        UpdateDefaultCameraDistance(blendToCamera);

        canZoom = false;

        // alert all listeners that we started blending some camera
        OnBlendingStart_Internal?.Invoke(fromCamera, blendToCamera);
        if (alertGlobally)
        {
            OnBlendingStart?.Invoke(fromCamera, blendToCamera);
        }

        CinemachineBlenderSettings.CustomBlend[] currentBlendSettings = brain.m_CustomBlends.m_CustomBlends.Clone() as CinemachineBlenderSettings.CustomBlend[];
        if (doHardBlend)
        {
            CinemachineBlenderSettings.CustomBlend hardBlend = new CinemachineBlenderSettings.CustomBlend
            {
                m_From  = CinemachineBlenderSettings.kBlendFromAnyCameraLabel,
                m_To    = blendToCamera.name,
                m_Blend = new CinemachineBlendDefinition(CinemachineBlendDefinition.Style.Cut, 0f)
            };
            brain.m_CustomBlends.m_CustomBlends = brain.m_CustomBlends.m_CustomBlends.Append(hardBlend).ToArray();
        }

        // Set the camera for this zone to active
        blendToCamera.gameObject.SetActive(true);

        // Whatever the current active camera is, deactivate it
        fromCamera.gameObject.SetActive(false);

        // The CinemachineBrain in the scene handles blending between the cameras
        // - (if we set up a custom blend already)

        StartCoroutine(WaitForBlendFinish(fromCamera, blendToCamera, alertGlobally, currentBlendSettings));
    }
        void SetupBlendList()
        {
            mBlendList = new ReorderableList(serializedObject,
                                             serializedObject.FindProperty(() => Target.m_CustomBlends),
                                             true, true, true, true);

            // Needed for accessing string names of fields
            CinemachineBlenderSettings.CustomBlend def  = new CinemachineBlenderSettings.CustomBlend();
            CinemachineBlendDefinition             def2 = new CinemachineBlendDefinition();

            float vSpace          = 2;
            float hSpace          = 3;
            float floatFieldWidth = EditorGUIUtility.singleLineHeight * 2.5f;

            mBlendList.drawHeaderCallback = (Rect rect) =>
            {
                rect.width -= (EditorGUIUtility.singleLineHeight + 2 * hSpace);
                rect.width /= 3;
                rect.x     += EditorGUIUtility.singleLineHeight;
                EditorGUI.LabelField(rect, "From");

                rect.x += rect.width + hSpace;
                EditorGUI.LabelField(rect, "To");

                rect.x += rect.width + hSpace; rect.width -= floatFieldWidth + hSpace;
                EditorGUI.LabelField(rect, "Style");

                rect.x += rect.width + hSpace; rect.width = floatFieldWidth;
                EditorGUI.LabelField(rect, "Time");
            };

            mBlendList.drawElementCallback
                = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                SerializedProperty element
                    = mBlendList.serializedProperty.GetArrayElementAtIndex(index);

                rect.y     += vSpace;
                rect.height = EditorGUIUtility.singleLineHeight;
                rect.width -= 2 * hSpace; rect.width /= 3;
                DrawVcamSelector(rect, element.FindPropertyRelative(() => def.m_From));

                rect.x += rect.width + hSpace;
                DrawVcamSelector(rect, element.FindPropertyRelative(() => def.m_To));

                SerializedProperty blendProp = element.FindPropertyRelative(() => def.m_Blend);
                rect.x += rect.width + hSpace;
                EditorGUI.PropertyField(rect, blendProp, GUIContent.none);
                };

            mBlendList.onAddCallback = (ReorderableList l) =>
            {
                var index = l.serializedProperty.arraySize;
                ++l.serializedProperty.arraySize;
                SerializedProperty blendProp = l.serializedProperty.GetArrayElementAtIndex(
                    index).FindPropertyRelative(() => def.m_Blend);

                blendProp.FindPropertyRelative(() => def2.m_Style).enumValueIndex
                    = (int)CinemachineBlendDefinition.Style.EaseInOut;
                blendProp.FindPropertyRelative(() => def2.m_Time).floatValue = 2f;
            };
        }
Пример #3
0
        void SetupBlendList()
        {
            mBlendList = new ReorderableList(serializedObject,
                                             serializedObject.FindProperty(() => Target.m_CustomBlends),
                                             true, true, true, true);

            // Needed for accessing string names of fields
            CinemachineBlenderSettings.CustomBlend def  = new CinemachineBlenderSettings.CustomBlend();
            CinemachineBlendDefinition             def2 = new CinemachineBlendDefinition();

            float vSpace          = 2;
            float hSpace          = 3;
            float floatFieldWidth = EditorGUIUtility.singleLineHeight * 2.5f;

            mBlendList.drawHeaderCallback = (Rect rect) =>
            {
                rect.width -= (EditorGUIUtility.singleLineHeight + 2 * hSpace);
                rect.width /= 3;
                Vector2 pos = rect.position; pos.x += EditorGUIUtility.singleLineHeight;
                rect.position = pos;
                EditorGUI.LabelField(rect, "From");

                pos.x += rect.width + hSpace; rect.position = pos;
                EditorGUI.LabelField(rect, "To");

                pos.x += rect.width + hSpace; rect.width -= floatFieldWidth + hSpace; rect.position = pos;
                EditorGUI.LabelField(rect, "Style");

                pos.x += rect.width + hSpace; rect.width = floatFieldWidth; rect.position = pos;
                EditorGUI.LabelField(rect, "Time");
            };

            mBlendList.drawElementCallback
                = (Rect rect, int index, bool isActive, bool isFocused) =>
                {
                SerializedProperty element
                    = mBlendList.serializedProperty.GetArrayElementAtIndex(index);

                rect.y     += vSpace;
                rect.height = EditorGUIUtility.singleLineHeight;
                Vector2 pos = rect.position;
                rect.width -= 2 * hSpace; rect.width /= 3;
                SerializedProperty fromProp = element.FindPropertyRelative(() => def.m_From);
                int current = GetCameraIndex(fromProp.stringValue);
                int sel     = EditorGUI.Popup(rect, current, mCameraCandidates);
                if (current != sel)
                {
                    fromProp.stringValue = mCameraCandidates[sel];
                }

                pos.x += rect.width + hSpace; rect.position = pos;
                SerializedProperty toProp = element.FindPropertyRelative(() => def.m_To);
                current = GetCameraIndex(toProp.stringValue);
                sel     = EditorGUI.Popup(rect, current, mCameraCandidates);
                if (current != sel)
                {
                    toProp.stringValue = mCameraCandidates[sel];
                }

                SerializedProperty blendProp = element.FindPropertyRelative(() => def.m_Blend);
                pos.x += rect.width + hSpace; rect.width -= floatFieldWidth; rect.position = pos;
                SerializedProperty styleProp = blendProp.FindPropertyRelative(() => def2.m_Style);
                EditorGUI.PropertyField(rect, styleProp, GUIContent.none);

                if (styleProp.intValue != (int)CinemachineBlendDefinition.Style.Cut)
                {
                    pos.x += rect.width + hSpace; rect.width = floatFieldWidth; rect.position = pos;
                    SerializedProperty timeProp = blendProp.FindPropertyRelative(() => def2.m_Time);
                    EditorGUI.PropertyField(rect, timeProp, GUIContent.none);
                }
                };

            mBlendList.onAddCallback = (ReorderableList l) =>
            {
                var index = l.serializedProperty.arraySize;
                ++l.serializedProperty.arraySize;
                SerializedProperty blendProp = l.serializedProperty.GetArrayElementAtIndex(
                    index).FindPropertyRelative(() => def.m_Blend);

                blendProp.FindPropertyRelative(() => def2.m_Style).enumValueIndex
                    = (int)CinemachineBlendDefinition.Style.EaseInOut;
                blendProp.FindPropertyRelative(() => def2.m_Time).floatValue = 2f;
            };
        }
Пример #4
0
    /// <summary>
    /// Passes to the next sequence. Does nothing is no sequence is left
    /// </summary>
    public void NextSequence()
    {
        if (currentSequence.cutsSlowMoOnEnd)
        {
            C_TimeScale.Instance.ForceStopSlowMo();
        }

        GameObject.FindObjectOfType <C_CameraRail>().bFeedbckActivated = currentSequence.bEnableCamFeedback;
        GameObject.FindObjectOfType <C_CameraRail>().FeedbackTransition(currentSequence.bEnableCamTransition, currentSequence.fSpeedTransition);

        if (currentSequence.hasEventOnEnd)
        {
            switch (currentSequence.seqEvent)
            {
            case M_Sequence.SequenceEndEventType.SlowMo:

                TriggerUtil.TriggerSlowMo(currentSequence.tTimeBeforeEvent, currentSequence.slowMoDuration, currentSequence.slowMoPower);

                break;

            case M_Sequence.SequenceEndEventType.Activation:

                TriggerUtil.TriggerActivation(currentSequence.tTimeBeforeEvent, currentSequence.affected, currentSequence.isActivation);

                break;

            case M_Sequence.SequenceEndEventType.Sound:

                TriggerUtil.TriggerSound(currentSequence.tTimeBeforeEvent, currentSequence.soundPlayed, currentSequence.volume);

                break;

            case M_Sequence.SequenceEndEventType.Animation:

                TriggerUtil.TriggerAnimationsFromTags(currentSequence.tTimeBeforeEvent, currentSequence.tagsAnimated);

                break;

            default:
                break;
            }
        }

        if (sequenceIndex < sequences.Count - 1)
        {
            sequenceIndex++;
            isWaitingTimer = false;

            currentSequence = sequences[sequenceIndex];

            //Debug.Log(currentVirtualCamera);

            //CREATION DU NOUVEAU BLEND
            CinemachineBlendDefinition blendDef = new CinemachineBlendDefinition
            {
                m_Style = currentSequence.animationStyle,
                m_Time  = currentSequence.fAnimationTime
            };

            //SETUP BLEND
            CinemachineBlenderSettings.CustomBlend blend = new CinemachineBlenderSettings.CustomBlend
            {
                m_From  = currentVirtualCamera.Name,
                m_To    = currentSequence.vCamTargetName,
                m_Blend = blendDef
            };

            blenderSettings.m_CustomBlends[0] = blend;

            cameraBrain.m_CustomBlends = blenderSettings;


            //CHANGEMENT DE CAM
            currentVirtualCamera.Priority = 10;
            PastCamPos                    = currentVirtualCamera.transform.position;
            currentVirtualCamera          = GameObject.Find(currentSequence.vCamTargetName).GetComponent <CinemachineVirtualCamera>();
            currentVirtualCamera.Priority = 11;
            NewCamPos = currentVirtualCamera.transform.position;

            //APPEL DE FONCTIONS DANS LES CHARGEURS
            C_Charger[] _Chargeurs = GameObject.FindObjectsOfType <C_Charger>();
            for (int i = 0; i < _Chargeurs.Length; i++)
            {
                _Chargeurs[i].PlayerChangePosition();
            }
            C_Shooter[] _Shooter = GameObject.FindObjectsOfType <C_Shooter>();
            for (int i = 0; i < _Shooter.Length; i++)
            {
                _Shooter[i].PlayerChangePosition();
            }

            fDelayOnBlendSequence = currentSequence.fAnimationTime + (currentSequence.sequenceType == M_Sequence.SequenceType.Timer ? currentSequence.fTimeSequenceDuration : 0);
            enemiesKilled         = 0;


            //DECLENCHEMENT DU FEEDBACK DE CAM
            if (GameObject.FindObjectOfType <C_CameraRail>())
            {
                GameObject.FindObjectOfType <C_CameraRail>().ChangeSpeedMoving(Vector3.Distance(PastCamPos, NewCamPos) / 5 / fDelayOnBlendSequence, 50);
            }

            if (currentSequence.sequenceType == M_Sequence.SequenceType.KillEnnemies)
            {
                if (currentSequence.bAcceptsBufferKill)
                {
                    enemiesKilled = bufferedKills;
                }
                bufferedKills = 0;
            }
        }
        else
        {
            Debug.Log("No sequence left");

            readSequences = false;
        }
    }