private IEnumerator ScrollSpeedFader(float to, float duration, FadingType type)
        {
            float start = _scrollingSpeed;
            float t     = 0;

            while (t < duration)
            {
                float tn = t / duration;
                switch (type)
                {
                case FadingType.LINEAR:
                    _scrollingSpeed = Maths.Lerp(start, to, tn);
                    break;

                case FadingType.SMOOTH_STEP:
                    _scrollingSpeed = Maths.Lerp(start, to, Maths.SmoothStep(0, 1, tn));
                    break;

                case FadingType.FADE_IN:
                    _scrollingSpeed = Maths.Lerp(start, to, Maths.EaseIn(tn));
                    break;

                case FadingType.FADE_OUT:
                    _scrollingSpeed = Maths.Lerp(start, to, Maths.EaseOut(tn));
                    break;
                }

                t += Program.UpdateTime.DeltaTime;
                yield return(null);
            }

            _scrollingSpeed = to;
            _fade           = null;
        }
示例#2
0
        protected override IEnumerator DyingSequence()
        {
            for (int i = 0; i < _lasers.Length; i++)
            {
                _lasers[i].Despawn(true);
            }

            StopCoroutine(_bulletPatterns);
            CanCollide   = false;
            Player.MAX_X = 77;

            int   maxExplosions        = 48;
            int   explosionsPerTickMin = 4;
            int   explosionsPerTickMax = 16;
            float explosionInterval    = 0.125f;
            float explosionIntervalTo  = 0.0015f;

            Vector2 min = Collider.bounds.min - Vector2.one * 10f;
            Vector2 max = Collider.bounds.max + Vector2.one * 10f;

            Random rng = new Random();

            for (int i = 0; i < maxExplosions; i++)
            {
                for (int j = 0; j < rng.Next(explosionsPerTickMin, explosionsPerTickMax + 1); j++)
                {
                    Effect fx = _deathFX.Get() as Effect;
                    fx.Spawn(new Vector2(Maths.Lerp(min.x, max.x, (float)rng.NextDouble()), Maths.Lerp(min.y, max.y, (float)rng.NextDouble())), Vector2.zero);
                    fx.Setup(0, 1000 + i + j, 1.5f, true);
                }
                yield return(Program.UpdateTime.WaitForSeconds(Maths.Lerp(explosionInterval, explosionIntervalTo, Maths.EaseIn(i / (maxExplosions - 1.0f)))));
            }

            for (int j = 0; j < 48; j++)
            {
                Effect fx = _deathFX.Get() as Effect;
                fx.Spawn(new Vector2(Maths.Lerp(min.x, max.x, (float)rng.NextDouble()), Maths.Lerp(min.y, max.y, (float)rng.NextDouble())), Vector2.zero);
                fx.Setup(0, 1500 + j, 1.25f, true);
            }

            _isVisible = false;
            yield return(Program.UpdateTime.WaitForSeconds(2.0f));

            bool newHigh = Player.ValidateScore(Program.Difficulty, Program.Player.Score);

            yield return(WarningScreen(newHigh ? _animWonHI : _animWon));

            yield return(Program.UpdateTime.WaitForSeconds(2.0f));

            Despawn(true);
        }