Example #1
0
 /// <summary>
 /// Toggles the timescale modification
 /// </summary>
 protected virtual void ToggleSlowMotion()
 {
     TimeAltered = !TimeAltered;
     if (TimeAltered)
     {
         MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, TimescaleModifier, 1f, true, 5f, true);
     }
     else
     {
         MMTimeScaleEvent.Trigger(MMTimeScaleMethods.Unfreeze, 1f, 0f, false, 0f, false);
     }
 }
Example #2
0
        /// <summary>
        /// Catches CorgiEngineTimeScaleEvents and acts on them
        /// </summary>
        /// <param name="timeScaleEvent">CorgiEngineTimeScaleEvent event.</param>
        public virtual void OnMMEvent(MMTimeScaleEvent timeScaleEvent)
        {
            switch (timeScaleEvent.TimeScaleMethod)
            {
            case MMTimeScaleMethods.Reset:
                ResetTimeScale();
                break;

            case MMTimeScaleMethods.Set:
                SetTimeScale(timeScaleEvent.TimeScaleProperty.TimeScale);
                break;

            case MMTimeScaleMethods.For:
                SetTimeScale(timeScaleEvent.TimeScaleProperty);
                break;

            case MMTimeScaleMethods.Unfreeze:
                Unfreeze();
                break;
            }
        }
Example #3
0
 /// <summary>
 /// A method used from the inspector to test the system
 /// </summary>
 protected virtual void TestButtonToSlowDownTime()
 {
     MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, 0.5f, 3f, true, 1f, false);
 }
Example #4
0
        /// <summary>
        /// Plays all the feedbacks that were enabled for this
        /// </summary>
        /// <param name="position"></param>
        public virtual void Play(Vector3 position)
        {
            // Camera shake
            if (ShakeCamera)
            {
                MMCameraShakeEvent.Trigger(CameraShakeProperties.Duration, CameraShakeProperties.Amplitude, CameraShakeProperties.Frequency);
            }

            if (UpdateAnimator)
            {
                if (AnimatorTriggerParameterName != null)
                {
                    FeedbackAnimator.SetTrigger(AnimatorTriggerParameterName);
                }

                if (AnimatorBoolParameterName != null)
                {
                    FeedbackAnimator.SetBool(AnimatorBoolParameterName, true);
                }
            }

            // instantiated particles
            if (InstantiateVFX && VfxToInstantiate != null)
            {
                if (_objectPool != null)
                {
                    _newGameObject = _objectPool.GetPooledGameObject();
                    if (_newGameObject != null)
                    {
                        _newGameObject.transform.position = position + VfxPositionOffset;
                        _newGameObject.SetActive(true);
                    }
                }
                else
                {
                    _newGameObject = GameObject.Instantiate(VfxToInstantiate) as GameObject;
                    _newGameObject.transform.position = position + VfxPositionOffset;
                }
            }

            if (ZoomCamera)
            {
                MMCameraZoomEvent.Trigger(ZoomMode, ZoomFieldOfView, ZoomTransitionDuration, ZoomDuration);
            }

            // Freeze Frame
            if (FreezeFrame)
            {
                MMFreezeFrameEvent.Trigger(FreezeFrameDuration);
            }

            // Time Scale
            if (ModifyTimescale)
            {
                MMTimeScaleEvent.Trigger(MMTimeScaleMethods.For, TimeScale, TimeScaleDuration, TimeScaleLerp, TimeScaleLerpSpeed, false);
            }

            // Particles
            if (Particles != null)
            {
                Particles.Play();
            }

            // Chromatic Aberration
            if (ChromaticAberration)
            {
                MMChromaticAberrationShakeEvent.Trigger(ChromaticAberrationDuration);
            }

            // Sounds
            if (Sfx != null)
            {
                MMSfxEvent.Trigger(Sfx);
            }

            // Flash
            if (TriggerFlash)
            {
                MMFlashEvent.Trigger(FlashColor, FlashDuration, FlashAlpha, FlashID);
            }
        }