/// <summary>
        /// On Play we turn our sprite renderer on and start an over time coroutine if needed
        /// </summary>
        /// <param name="position"></param>
        /// <param name="attenuation"></param>
        protected override void CustomPlayFeedback(Vector3 position, float attenuation = 1.0f)
        {
            if (Active)
            {
                Turn(true);
                switch (Mode)
                {
                case Modes.Instant:
                    if (ModifyColor)
                    {
                        BoundSpriteRenderer.color = InstantColor;
                    }
                    Flip();
                    break;

                case Modes.OverTime:
                    StartCoroutine(SpriteRendererSequence());
                    break;

                case Modes.ShakerEvent:
                    MMSpriteRendererShakeEvent.Trigger(Duration, ModifyColor, ColorOverTime,
                                                       FlipX, FlipY,
                                                       attenuation,
                                                       Channel, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake,
                                                       UseRange, EventRange, EventOriginTransform.position);
                    break;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// On Play we turn our sprite renderer on and start an over time coroutine if needed
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
        {
            if (Active)
            {
                float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;
                Turn(true);
                switch (Mode)
                {
                case Modes.Instant:
                    if (ModifyColor)
                    {
                        BoundSpriteRenderer.color = InstantColor;
                    }
                    Flip();
                    break;

                case Modes.OverTime:
                    if (!AllowAdditivePlays && (_coroutine != null))
                    {
                        return;
                    }
                    _coroutine = StartCoroutine(SpriteRendererSequence());
                    break;

                case Modes.ShakerEvent:
                    MMSpriteRendererShakeEvent.Trigger(FeedbackDuration, ModifyColor, ColorOverTime,
                                                       FlipX, FlipY,
                                                       intensityMultiplier,
                                                       Channel, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake,
                                                       UseRange, EventRange, EventOriginTransform.position);
                    break;
                }
            }
        }
        /// <summary>
        /// On Play we turn our sprite renderer on and start an over time coroutine if needed
        /// </summary>
        /// <param name="position"></param>
        /// <param name="feedbacksIntensity"></param>
        protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
        {
            if (!Active || !FeedbackTypeAuthorized)
            {
                return;
            }

            if ((BoundSpriteRenderer != null) && (InitialColorMode == InitialColorModes.InitialColorOnPlay))
            {
                _initialColor = BoundSpriteRenderer.color;
            }

            float intensityMultiplier = Timing.ConstantIntensity ? 1f : feedbacksIntensity;

            Turn(true);
            switch (Mode)
            {
            case Modes.Instant:
                if (ModifyColor)
                {
                    BoundSpriteRenderer.color = InstantColor;
                }
                Flip();
                break;

            case Modes.OverTime:
                if (!AllowAdditivePlays && (_coroutine != null))
                {
                    return;
                }
                _coroutine = Owner.StartCoroutine(SpriteRendererSequence());
                break;

            case Modes.ShakerEvent:
                MMSpriteRendererShakeEvent.Trigger(FeedbackDuration, ModifyColor, ColorOverTime,
                                                   FlipX, FlipY,
                                                   intensityMultiplier,
                                                   Channel, ResetShakerValuesAfterShake, ResetTargetValuesAfterShake,
                                                   UseRange, EventRange, EventOriginTransform.position);
                break;

            case Modes.ToDestinationColor:
                if (!AllowAdditivePlays && (_coroutine != null))
                {
                    return;
                }
                _coroutine = Owner.StartCoroutine(SpriteRendererToDestinationSequence(false));
                break;

            case Modes.ToDestinationColorAndBack:
                if (!AllowAdditivePlays && (_coroutine != null))
                {
                    return;
                }
                _coroutine = Owner.StartCoroutine(SpriteRendererToDestinationSequence(true));
                break;
            }
        }
 /// <summary>
 /// Stops listening for events
 /// </summary>
 public override void StopListening()
 {
     base.StopListening();
     MMSpriteRendererShakeEvent.Unregister(OnMMSpriteRendererShakeEvent);
 }