예제 #1
0
        protected virtual void StartFading(float initialAlpha, float endAlpha, float duration, MMTweenType curve, int id,
                                           bool ignoreTimeScale, Vector3 worldPosition)
        {
            if (id != ID)
            {
                return;
            }

            if (TargetCamera == null)
            {
                Debug.LogWarning(this.name + " : You're using a fader round but its TargetCamera hasn't been setup in its inspector. It can't fade.");
                return;
            }

            FaderMask.anchoredPosition = Vector3.zero;

            Vector3 viewportPosition = TargetCamera.WorldToViewportPoint(worldPosition);

            viewportPosition.x = Mathf.Clamp01(viewportPosition.x);
            viewportPosition.y = Mathf.Clamp01(viewportPosition.y);
            viewportPosition.z = Mathf.Clamp01(viewportPosition.z);

            FaderMask.anchorMin = viewportPosition;
            FaderMask.anchorMax = viewportPosition;

            IgnoreTimescale = ignoreTimeScale;
            EnableFader();
            _fading             = true;
            _initialScale       = initialAlpha;
            _currentTargetScale = endAlpha;
            _fadeStartedAt      = IgnoreTimescale ? Time.unscaledTime : Time.time;
            _currentCurve       = curve;
            _currentDuration    = duration;
        }
 public MMSoundManagerSoundFadeEvent(int soundID, float fadeDuration, float finalVolume, MMTweenType fadeTween)
 {
     SoundID      = soundID;
     FadeDuration = fadeDuration;
     FinalVolume  = finalVolume;
     FadeTween    = fadeTween;
 }
 public MMSoundManagerTrackFadeEvent(MMSoundManager.MMSoundManagerTracks track, float fadeDuration, float finalVolume, MMTweenType fadeTween)
 {
     Track        = track;
     FadeDuration = fadeDuration;
     FinalVolume  = finalVolume;
     FadeTween    = fadeTween;
 }
        /// <summary>
        /// if we get a PostProcessingTriggerEvent
        /// </summary>
        /// <param name="curve"></param>
        /// <param name="active"></param>
        /// <param name="duration"></param>
        /// <param name="channel"></param>
        public virtual void OnMMPostProcessingMovingFilterEvent(MMTweenType curve, bool active, bool toggle, float duration, int channel = 0, bool stop = false)
        {
            if ((channel != Channel) && (channel != -1) && (Channel != -1))
            {
                return;
            }

            if (stop)
            {
                _lastReachedState = Active;
                return;
            }

            Curve     = curve;
            _duration = duration;

            if (toggle)
            {
                Active = !Active;
            }
            else
            {
                Active = active;
            }

            float currentTime = (TimeScale == TimeScales.Unscaled) ? Time.unscaledTime : Time.time;

            _lastMovementStartedAt = currentTime;
        }
        /// <summary>
        /// Renders the specified grid on the specified tilemap, with optional slow mode (only works at runtime)
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="tilemap"></param>
        /// <param name="tile"></param>
        /// <param name="slowRender"></param>
        /// <param name="slowRenderDuration"></param>
        /// <param name="slowRenderTweenType"></param>
        /// <param name="slowRenderSupport"></param>
        public static void RenderGrid(int[,] grid, MMTilemapGeneratorLayer layer, bool slowRender = false, float slowRenderDuration = 1f,
                                      MMTweenType slowRenderTweenType = null, MonoBehaviour slowRenderSupport = null)
        {
            if (layer.FusionMode == MMTilemapGeneratorLayer.FusionModes.Normal)
            {
                ClearTilemap(layer.TargetTilemap);
            }
            TileBase tile = layer.Tile;

            if (layer.FusionMode == MMTilemapGeneratorLayer.FusionModes.Combine)
            {
                grid = MMGridGenerator.InvertGrid(grid);
                tile = null;
            }
            if (layer.FusionMode == MMTilemapGeneratorLayer.FusionModes.Subtract)
            {
                grid = MMGridGenerator.InvertGrid(grid);
            }

            if (!slowRender || !Application.isPlaying)
            {
                DrawGrid(grid, layer.TargetTilemap, tile, 0, TotalFilledBlocks(grid));
            }
            else
            {
                slowRenderSupport.StartCoroutine(SlowRenderGrid(grid, layer.TargetTilemap, tile, slowRenderDuration, slowRenderTweenType, 60));
            }

            if (!Application.isPlaying && slowRender)
            {
                Debug.LogWarning("Rendering maps in SlowRender mode is only supported at runtime.");
            }
        }
예제 #6
0
        /// <summary>
        /// Starts fading this fader from the specified initial alpha to the target
        /// </summary>
        /// <param name="initialAlpha"></param>
        /// <param name="endAlpha"></param>
        /// <param name="duration"></param>
        /// <param name="curve"></param>
        /// <param name="id"></param>
        /// <param name="ignoreTimeScale"></param>
        protected virtual void StartFading(float initialAlpha, float endAlpha, float duration, MMTweenType curve, int id, bool ignoreTimeScale)
        {
            if (id != ID)
            {
                return;
            }

            if ((!CanFadeToCurrentAlpha) && (_canvasGroup.alpha == endAlpha))
            {
                return;
            }

            IgnoreTimescale = ignoreTimeScale;
            EnableFader();
            _fading             = true;
            _initialAlpha       = initialAlpha;
            _currentTargetAlpha = endAlpha;
            _fadeStartedAt      = IgnoreTimescale ? Time.unscaledTime : Time.time;
            _currentCurve       = curve;
            _currentDuration    = duration;
            if (Time.frameCount == 1)
            {
                _frameCountOne = true;
            }
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MoreMountains.MMInterface.MMFadeInEvent"/> struct.
 /// </summary>
 /// <param name="duration">Duration.</param>
 public MMFadeInEvent(float duration, MMTweenType tween, int id = 0,
                      bool ignoreTimeScale = true, Vector3 worldPosition = new Vector3())
 {
     ID              = id;
     Duration        = duration;
     Curve           = tween;
     IgnoreTimeScale = ignoreTimeScale;
     WorldPosition   = worldPosition;
 }
예제 #8
0
 /// <summary>
 /// On Start(), we start loading the new level asynchronously
 /// </summary>
 protected virtual void Start()
 {
     _tween            = new MMTweenType(MMTween.MMTweenCurve.EaseOutCubic);
     _loadingTextValue = LoadingText.text;
     if (!string.IsNullOrEmpty(_sceneToLoad))
     {
         StartCoroutine(LoadAsynchronously());
     }
 }
예제 #9
0
 public static void Trigger(float duration, MMTweenType tween, int id = 0,
                            bool ignoreTimeScale = true, Vector3 worldPosition = new Vector3())
 {
     e.ID              = id;
     e.Duration        = duration;
     e.Curve           = tween;
     e.IgnoreTimeScale = ignoreTimeScale;
     e.WorldPosition   = worldPosition;
     MMEventManager.TriggerEvent(e);
 }
예제 #10
0
 protected virtual void StartFading(float initialAlpha, float endAlpha, float duration, MMTweenType curve, int id, bool ignoreTimeScale)
 {
     if (id != ID)
     {
         return;
     }
     IgnoreTimescale = ignoreTimeScale;
     EnableFader();
     _fading             = true;
     _initialAlpha       = initialAlpha;
     _currentTargetAlpha = endAlpha;
     _fadeStartedAt      = IgnoreTimescale ? Time.unscaledTime : Time.time;
     _currentCurve       = curve;
     _currentDuration    = duration;
 }
예제 #11
0
        /// <summary>
        /// Fades an entire track over time
        /// </summary>
        /// <param name="track"></param>
        /// <param name="duration"></param>
        /// <param name="initialVolume"></param>
        /// <param name="finalVolume"></param>
        /// <param name="tweenType"></param>
        /// <returns></returns>
        protected virtual IEnumerator FadeTrackCoroutine(MMSoundManagerTracks track, float duration, float initialVolume, float finalVolume, MMTweenType tweenType)
        {
            float startedAt = Time.unscaledTime;

            if (tweenType == null)
            {
                tweenType = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic);
            }
            while (Time.unscaledTime - startedAt <= duration)
            {
                float elapsedTime = Time.unscaledTime - startedAt;
                float newVolume   = MMTween.Tween(elapsedTime, 0f, duration, initialVolume, finalVolume, tweenType);
                settingsSo.SetTrackVolume(track, newVolume);
                yield return(null);
            }
            settingsSo.SetTrackVolume(track, finalVolume);
        }
예제 #12
0
        /// <summary>
        /// Fades an audiosource's volume over time
        /// </summary>
        /// <param name="source"></param>
        /// <param name="duration"></param>
        /// <param name="initialVolume"></param>
        /// <param name="finalVolume"></param>
        /// <param name="tweenType"></param>
        /// <returns></returns>
        protected virtual IEnumerator FadeCoroutine(AudioSource source, float duration, float initialVolume, float finalVolume, MMTweenType tweenType)
        {
            float startedAt = Time.unscaledTime;

            if (tweenType == null)
            {
                tweenType = new MMTweenType(MMTween.MMTweenCurve.EaseInOutQuartic);
            }
            while (Time.unscaledTime - startedAt <= duration)
            {
                float elapsedTime = Time.unscaledTime - startedAt;
                float newVolume   = MMTween.Tween(elapsedTime, 0f, duration, initialVolume, finalVolume, tweenType);
                source.volume = newVolume;
                yield return(null);
            }
            source.volume = finalVolume;
        }
예제 #13
0
        /// <summary>
        /// Starts a fade
        /// </summary>
        /// <param name="fadingIn"></param>
        /// <param name="duration"></param>
        /// <param name="curve"></param>
        /// <param name="id"></param>
        /// <param name="ignoreTimeScale"></param>
        /// <param name="worldPosition"></param>
        protected virtual IEnumerator StartFading(bool fadingIn, float duration, MMTweenType curve, int id,
                                                  bool ignoreTimeScale, Vector3 worldPosition)
        {
            if (id != ID)
            {
                yield break;
            }

            if (InitialDelay > 0f)
            {
                yield return(MMCoroutine.WaitFor(InitialDelay));
            }

            if (!_initialized)
            {
                Initialization();
            }

            if (curve == null)
            {
                curve = DefaultTween;
            }

            IgnoreTimescale = ignoreTimeScale;
            EnableFader();
            _fading = true;

            _fadeStartedAt   = IgnoreTimescale ? Time.unscaledTime : Time.time;
            _currentCurve    = curve;
            _currentDuration = duration;

            _fromPosition = _rectTransform.anchoredPosition;
            _toPosition   = fadingIn ? _initialPosition : ExitPosition();

            _newPosition = MMTween.Tween(0f, 0f, duration, _fromPosition, _toPosition, _currentCurve);
            _rectTransform.anchoredPosition = _newPosition;
        }
예제 #14
0
 /// <summary>
 /// Fades a target sound towards a final volume over time
 /// </summary>
 /// <param name="source"></param>
 /// <param name="duration"></param>
 /// <param name="initialVolume"></param>
 /// <param name="finalVolume"></param>
 /// <param name="tweenType"></param>
 public virtual void FadeSound(AudioSource source, float duration, float initialVolume, float finalVolume, MMTweenType tweenType)
 {
     StartCoroutine(FadeCoroutine(source, duration, initialVolume, finalVolume, tweenType));
 }
예제 #15
0
 /// <summary>
 /// Fades an entire track over the specified duration towards the desired finalVolume
 /// </summary>
 /// <param name="track"></param>
 /// <param name="duration"></param>
 /// <param name="initialVolume"></param>
 /// <param name="finalVolume"></param>
 /// <param name="tweenType"></param>
 public virtual void FadeTrack(MMSoundManagerTracks track, float duration, float initialVolume = 0f, float finalVolume = 1f, MMTweenType tweenType = null)
 {
     StartCoroutine(FadeTrackCoroutine(track, duration, initialVolume, finalVolume, tweenType));
 }
예제 #16
0
        /// <summary>
        /// Plays a sound, signature with all options
        /// </summary>
        /// <param name="audioClip"></param>
        /// <param name="mmSoundManagerTrack"></param>
        /// <param name="location"></param>
        /// <param name="loop"></param>
        /// <param name="volume"></param>
        /// <param name="ID"></param>
        /// <param name="fade"></param>
        /// <param name="fadeInitialVolume"></param>
        /// <param name="fadeDuration"></param>
        /// <param name="fadeTween"></param>
        /// <param name="persistent"></param>
        /// <param name="recycleAudioSource"></param>
        /// <param name="audioGroup"></param>
        /// <param name="pitch"></param>
        /// <param name="panStereo"></param>
        /// <param name="spatialBlend"></param>
        /// <param name="soloSingleTrack"></param>
        /// <param name="soloAllTracks"></param>
        /// <param name="autoUnSoloOnEnd"></param>
        /// <param name="bypassEffects"></param>
        /// <param name="bypassListenerEffects"></param>
        /// <param name="bypassReverbZones"></param>
        /// <param name="priority"></param>
        /// <param name="reverbZoneMix"></param>
        /// <param name="dopplerLevel"></param>
        /// <param name="spread"></param>
        /// <param name="rolloffMode"></param>
        /// <param name="minDistance"></param>
        /// <param name="maxDistance"></param>
        /// <returns></returns>
        public virtual AudioSource PlaySound(AudioClip audioClip, MMSoundManagerTracks mmSoundManagerTrack, Vector3 location,
                                             bool loop       = false, float volume            = 1.0f, int ID = 0,
                                             bool fade       = false, float fadeInitialVolume = 0f, float fadeDuration = 1f, MMTweenType fadeTween = null,
                                             bool persistent = false,
                                             AudioSource recycleAudioSource = null, AudioMixerGroup audioGroup = null,
                                             float pitch          = 1f, float panStereo = 0f, float spatialBlend = 0.0f,
                                             bool soloSingleTrack = false, bool soloAllTracks         = false, bool autoUnSoloOnEnd   = false,
                                             bool bypassEffects   = false, bool bypassListenerEffects = false, bool bypassReverbZones = false, int priority            = 128, float reverbZoneMix = 1f,
                                             float dopplerLevel   = 1f, int spread = 0, AudioRolloffMode rolloffMode = AudioRolloffMode.Logarithmic, float minDistance = 1f, float maxDistance    = 500f
                                             )
        {
            if (!audioClip)
            {
                return(null);
            }

            // audio source setup ---------------------------------------------------------------------------------

            // we reuse an audiosource if one is passed in parameters
            AudioSource audioSource = recycleAudioSource;

            if (audioSource == null)
            {
                // we pick an idle audio source from the pool if possible
                audioSource = _pool.GetAvailableAudioSource(PoolCanExpand, this.transform);
                if ((audioSource != null) && (!loop))
                {
                    recycleAudioSource = audioSource;
                    // we destroy the host after the clip has played (if it not tag for reusability.
                    StartCoroutine(_pool.AutoDisableAudioSource(audioClip.length, audioSource.gameObject));
                }
            }

            // we create an audio source if needed
            if (audioSource == null)
            {
                _tempAudioSourceGameObject = new GameObject("MMAudio_" + audioClip.name);
                audioSource = _tempAudioSourceGameObject.AddComponent <AudioSource>();
            }

            // audio source settings ---------------------------------------------------------------------------------

            audioSource.transform.position = location;
            audioSource.time                  = 0.0f;
            audioSource.clip                  = audioClip;
            audioSource.pitch                 = pitch;
            audioSource.spatialBlend          = spatialBlend;
            audioSource.panStereo             = panStereo;
            audioSource.loop                  = loop;
            audioSource.bypassEffects         = bypassEffects;
            audioSource.bypassListenerEffects = bypassListenerEffects;
            audioSource.bypassReverbZones     = bypassReverbZones;
            audioSource.priority              = priority;
            audioSource.reverbZoneMix         = reverbZoneMix;
            audioSource.dopplerLevel          = dopplerLevel;
            audioSource.spread                = spread;
            audioSource.rolloffMode           = rolloffMode;
            audioSource.minDistance           = minDistance;
            audioSource.maxDistance           = maxDistance;

            // track and volume ---------------------------------------------------------------------------------

            if (settingsSo != null)
            {
                audioSource.outputAudioMixerGroup = settingsSo.MasterAudioMixerGroup;
                switch (mmSoundManagerTrack)
                {
                case MMSoundManagerTracks.Master:
                    audioSource.outputAudioMixerGroup = settingsSo.MasterAudioMixerGroup;
                    break;

                case MMSoundManagerTracks.Music:
                    audioSource.outputAudioMixerGroup = settingsSo.MusicAudioMixerGroup;
                    break;

                case MMSoundManagerTracks.Sfx:
                    audioSource.outputAudioMixerGroup = settingsSo.SfxAudioMixerGroup;
                    break;

                case MMSoundManagerTracks.UI:
                    audioSource.outputAudioMixerGroup = settingsSo.UIAudioMixerGroup;
                    break;
                }
            }
            if (audioGroup)
            {
                audioSource.outputAudioMixerGroup = audioGroup;
            }
            audioSource.volume = volume;

            // we start playing the sound
            audioSource.Play();

            // we destroy the host after the clip has played if it was a one time AS.
            if (!loop && !recycleAudioSource)
            {
                Destroy(_tempAudioSourceGameObject, audioClip.length);
            }

            // we fade the sound in if needed
            if (fade)
            {
                FadeSound(audioSource, fadeDuration, fadeInitialVolume, volume, fadeTween);
            }

            // we handle soloing
            if (soloSingleTrack)
            {
                MuteSoundsOnTrack(mmSoundManagerTrack, true, 0f);
                audioSource.mute = false;
                if (autoUnSoloOnEnd)
                {
                    MuteSoundsOnTrack(mmSoundManagerTrack, false, audioClip.length);
                }
            }
            else if (soloAllTracks)
            {
                MuteAllSounds();
                audioSource.mute = false;
                if (autoUnSoloOnEnd)
                {
                    StartCoroutine(MuteAllSoundsCoroutine(audioClip.length, false));
                }
            }

            // we prepare for storage
            _sound.ID         = ID;
            _sound.Track      = mmSoundManagerTrack;
            _sound.Source     = audioSource;
            _sound.Persistent = persistent;

            // we check if that audiosource is already being tracked in _sounds
            bool alreadyIn = false;

            for (int i = 0; i < _sounds.Count; i++)
            {
                if (_sounds[i].Source == audioSource)
                {
                    _sounds[i] = _sound;
                    alreadyIn  = true;
                }
            }

            if (!alreadyIn)
            {
                _sounds.Add(_sound);
            }

            // we return the audiosource reference
            return(audioSource);
        }
 public static void Trigger(MMSoundManager.MMSoundManagerTracks track, float fadeDuration, float finalVolume, MMTweenType fadeTween)
 {
     e.Track        = track;
     e.FadeDuration = fadeDuration;
     e.FinalVolume  = finalVolume;
     e.FadeTween    = fadeTween;
     MMEventManager.TriggerEvent(e);
 }
        /// <summary>
        /// Call this static method to load a scene from anywhere
        /// </summary>
        /// <param name="sceneToLoadName">Level name.</param>
        public static void LoadScene(string sceneToLoadName, string loadingSceneName = "MMAdditiveLoadingScreen",
                                     ThreadPriority threadPriority = ThreadPriority.High, bool secureLoad = true,
                                     bool interpolateProgress      = true,
                                     float beforeEntryFadeDelay    = 0f,
                                     float entryFadeDuration       = 0.25f,
                                     float afterEntryFadeDelay     = 0.1f,
                                     float beforeExitFadeDelay     = 0.25f,
                                     float exitFadeDuration        = 0.2f,
                                     MMTweenType entryFadeTween    = null, MMTweenType exitFadeTween = null,
                                     float progressBarSpeed        = 5f,
                                     FadeModes fadeMode            = FadeModes.FadeInThenOut,
                                     MMAdditiveSceneLoadingManagerSettings.UnloadMethods unloadMethod = MMAdditiveSceneLoadingManagerSettings.UnloadMethods.AllScenes)
        {
            if (_loadingInProgress)
            {
                Debug.LogError("MMLoadingSceneManagerAdditive : a request to load a new scene was emitted while a scene load was already in progress");
                return;
            }

            if (entryFadeTween == null)
            {
                entryFadeTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutCubic);
            }

            if (exitFadeTween == null)
            {
                exitFadeTween = new MMTweenType(MMTween.MMTweenCurve.EaseInOutCubic);
            }

            if (secureLoad)
            {
                _scenesInBuild = MMScene.GetScenesInBuild();

                if (!_scenesInBuild.Contains(sceneToLoadName))
                {
                    Debug.LogError("MMLoadingSceneManagerAdditive : impossible to load the '" + sceneToLoadName + "' scene, " +
                                   "there is no such scene in the project's build settings.");
                    return;
                }
                if (!_scenesInBuild.Contains(loadingSceneName))
                {
                    Debug.LogError("MMLoadingSceneManagerAdditive : impossible to load the '" + loadingSceneName + "' scene, " +
                                   "there is no such scene in the project's build settings.");
                    return;
                }
            }

            _loadingInProgress = true;
            _initialScenes     = GetScenesToUnload(unloadMethod);

            Application.backgroundLoadingPriority = threadPriority;
            _sceneToLoadName            = sceneToLoadName;
            _loadingScreenSceneName     = loadingSceneName;
            _beforeEntryFadeDelay       = beforeEntryFadeDelay;
            _entryFadeDuration          = entryFadeDuration;
            _entryFadeTween             = entryFadeTween;
            _afterEntryFadeDelay        = afterEntryFadeDelay;
            _progressInterpolationSpeed = progressBarSpeed;
            _beforeExitFadeDelay        = beforeExitFadeDelay;
            _exitFadeDuration           = exitFadeDuration;
            _exitFadeTween       = exitFadeTween;
            _fadeMode            = fadeMode;
            _interpolateProgress = interpolateProgress;

            SceneManager.LoadScene(_loadingScreenSceneName, LoadSceneMode.Additive);
        }
예제 #19
0
 static public void Trigger(MMTweenType curve, bool active, bool toggle, float duration, int channel = 0)
 {
     OnEvent?.Invoke(curve, active, toggle, duration, channel);
 }
예제 #20
0
 public static Quaternion Tween(float currentTime, float initialTime, float endTime, Quaternion startValue, Quaternion endValue, MMTweenType tweenType)
 {
     if (tweenType.MMTweenDefinitionType == MMTweenDefinitionTypes.MMTween)
     {
         return(Tween(currentTime, initialTime, endTime, startValue, endValue, tweenType.MMTweenCurve));
     }
     if (tweenType.MMTweenDefinitionType == MMTweenDefinitionTypes.AnimationCurve)
     {
         return(Tween(currentTime, initialTime, endTime, startValue, endValue, tweenType.Curve));
     }
     return(Quaternion.identity);
 }
예제 #21
0
 public static Vector3 Tween(float currentTime, float initialTime, float endTime, Vector3 startValue, Vector3 endValue, MMTweenType tweenType)
 {
     if (tweenType.MMTweenDefinitionType == MMTweenDefinitionTypes.MMTween)
     {
         return(Tween(currentTime, initialTime, endTime, startValue, endValue, tweenType.MMTweenCurve));
     }
     if (tweenType.MMTweenDefinitionType == MMTweenDefinitionTypes.AnimationCurve)
     {
         return(Tween(currentTime, initialTime, endTime, startValue, endValue, tweenType.Curve));
     }
     return(Vector3.zero);
 }
        /// <summary>
        /// Renders a grid chunk by chunk - runtime only
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="tilemap"></param>
        /// <param name="tile"></param>
        /// <param name="slowRenderDuration"></param>
        /// <param name="slowRenderTweenType"></param>
        /// <param name="frameRate"></param>
        /// <returns></returns>
        public static IEnumerator SlowRenderGrid(int[,] grid, Tilemap tilemap, TileBase tile, float slowRenderDuration, MMTweenType slowRenderTweenType, int frameRate)
        {
            int totalBlocks = TotalFilledBlocks(grid);

            totalBlocks = (totalBlocks == 0) ? 1 : totalBlocks;
            frameRate   = (frameRate == 0) ? 1 : frameRate;
            float refreshFrequency = 1f / frameRate;
            float startedAt        = Time.unscaledTime;
            float lastWaitAt       = startedAt;
            int   drawnBlocks      = 0;
            int   lastIndex        = 0;

            while (Time.unscaledTime - startedAt < slowRenderDuration)
            {
                while (Time.unscaledTime - lastWaitAt < refreshFrequency)
                {
                    yield return(null);
                }

                int   remainingBlocks    = totalBlocks - drawnBlocks;
                float elapsedTime        = Time.unscaledTime - startedAt;
                float remainingTime      = slowRenderDuration - elapsedTime;
                float normalizedProgress = MMMaths.Remap(elapsedTime, 0f, slowRenderDuration, 0f, 1f);
                float curveProgress      = MMTween.Tween(normalizedProgress, 0f, 1f, 0f, 1f, slowRenderTweenType);
                float ratio = 1 - (normalizedProgress - curveProgress);

                int blocksToDraw = Mathf.RoundToInt((remainingBlocks / remainingTime) * refreshFrequency * ratio);

                lastIndex    = DrawGrid(grid, tilemap, tile, lastIndex, blocksToDraw);
                drawnBlocks += blocksToDraw;
                lastWaitAt   = Time.unscaledTime;
            }
            DrawGrid(grid, tilemap, tile, lastIndex, totalBlocks - lastIndex);
        }
 public static void Trigger(int soundID, float fadeDuration, float finalVolume, MMTweenType fadeTween)
 {
     e.SoundID      = soundID;
     e.FadeDuration = fadeDuration;
     e.FinalVolume  = finalVolume;
     e.FadeTween    = fadeTween;
     MMEventManager.TriggerEvent(e);
 }
예제 #24
0
        static public AudioSource Trigger(AudioClip audioClip, MMSoundManager.MMSoundManagerTracks mmSoundManagerTrack, Vector3 location,
                                          bool loop       = false, float volume            = 1.0f, int ID = 0,
                                          bool fade       = false, float fadeInitialVolume = 0f, float fadeDuration = 1f, MMTweenType fadeTween = null,
                                          bool persistent = false,
                                          AudioSource recycleAudioSource = null, AudioMixerGroup audioGroup = null,
                                          float pitch          = 1f, float panStereo = 0f, float spatialBlend = 0.0f,
                                          bool soloSingleTrack = false, bool soloAllTracks         = false, bool autoUnSoloOnEnd   = false,
                                          bool bypassEffects   = false, bool bypassListenerEffects = false, bool bypassReverbZones = false, int priority            = 128, float reverbZoneMix = 1f,
                                          float dopplerLevel   = 1f, int spread = 0, AudioRolloffMode rolloffMode = AudioRolloffMode.Logarithmic, float minDistance = 1f, float maxDistance    = 500f)
        {
            MMSoundManagerPlayOptions options = MMSoundManagerPlayOptions.Default;

            options.MmSoundManagerTrack = mmSoundManagerTrack;
            options.Location            = location;
            options.Loop                  = loop;
            options.Volume                = volume;
            options.ID                    = ID;
            options.Fade                  = fade;
            options.FadeInitialVolume     = fadeInitialVolume;
            options.FadeDuration          = fadeDuration;
            options.FadeTween             = fadeTween;
            options.Persistent            = persistent;
            options.RecycleAudioSource    = recycleAudioSource;
            options.AudioGroup            = audioGroup;
            options.Pitch                 = pitch;
            options.PanStereo             = panStereo;
            options.SpatialBlend          = spatialBlend;
            options.SoloSingleTrack       = soloSingleTrack;
            options.SoloAllTracks         = soloAllTracks;
            options.AutoUnSoloOnEnd       = autoUnSoloOnEnd;
            options.BypassEffects         = bypassEffects;
            options.BypassListenerEffects = bypassListenerEffects;
            options.BypassReverbZones     = bypassReverbZones;
            options.Priority              = priority;
            options.ReverbZoneMix         = reverbZoneMix;
            options.DopplerLevel          = dopplerLevel;
            options.Spread                = spread;
            options.RolloffMode           = rolloffMode;
            options.MinDistance           = minDistance;
            options.MaxDistance           = maxDistance;

            return(OnEvent?.Invoke(audioClip, options));
        }
예제 #25
0
        // Tween type methods ------------------------------------------------------------------------------------------------------------------------

        public static float Tween(float currentTime, float initialTime, float endTime, float startValue, float endValue, MMTweenType tweenType)
        {
            if (tweenType.MMTweenDefinitionType == MMTweenDefinitionTypes.MMTween)
            {
                return(Tween(currentTime, initialTime, endTime, startValue, endValue, tweenType.MMTweenCurve));
            }
            if (tweenType.MMTweenDefinitionType == MMTweenDefinitionTypes.AnimationCurve)
            {
                return(Tween(currentTime, initialTime, endTime, startValue, endValue, tweenType.Curve));
            }
            return(0f);
        }