예제 #1
0
 public TestCase()
 {
     Tween1        = new TweenSleep(new TimeSpan(200), () => Tween1FinishCallbacks++);
     Tween2        = new TweenSleep(new TimeSpan(100), () => Tween2FinishCallbacks++);
     ParallelTween = new TweenParallel(() => TweenParallelFinishCallbacks++);
     ParallelTween.Add(Tween1);
     ParallelTween.Add(Tween2);
 }
예제 #2
0
        public void ShouldThrowExceptionWhenAddingTheSameTweenTwice_adding()
        {
            var tween    = new TweenSleep(new TimeSpan(100));
            var parallel = new TweenParallel();

            parallel.Add(tween);

            Assert.Throws <ArgumentException>(() => parallel.Add(tween));
        }
예제 #3
0
        public void ShouldNotTriggerFinishCallbackWhenThereWereNoTweens()
        {
            var tweenParallelFinishCallbacks = 0;
            var parallel = new TweenParallel(() => tweenParallelFinishCallbacks++);

            parallel.Advance(new TimeSpan(100));

            Assert.Equal(0, tweenParallelFinishCallbacks);
        }
        public override TweenBase CreateTween(ITweenAssetInjector injector)
        {
            var tween = new TweenParallel();

            foreach (var item in m_parallel)
            {
                tween.Add(item.CreateTween(injector));
            }
            return(tween);
        }
예제 #5
0
        public void ShouldAddTweensPassedInConstructor_arrayInit()
        {
            var tween1   = new TweenSleep(new TimeSpan(200));
            var tween2   = new TweenSleep(new TimeSpan(100));
            var parallel = new TweenParallel(null, new ITween[] { tween1, tween2 });

            Assert.Equal(2, parallel.TweenCount);
            Assert.False(parallel.IsFinished);
            Assert.Contains(tween1, parallel.Tweens);
            Assert.Contains(tween2, parallel.Tweens);
        }
예제 #6
0
        public void ShouldAddTween()
        {
            var tween    = new TweenSleep(new TimeSpan(100));
            var parallel = new TweenParallel();

            parallel.Add(tween);

            Assert.Equal(1, parallel.TweenCount);
            Assert.False(parallel.IsFinished);
            Assert.Contains(tween, parallel.Tweens);
        }
        public ParticleSmoke()
        {
            _tween = new TweenParallel(() => IsFinished = true);

            _position = new Vector2(_random.Next(0, S.ViewportWidth), -396);
            _rotation = (float)(2 * Math.PI * _random.NextDouble());
            _scale    = 1.5f + (float)_random.NextDouble() * 0.5f;
            _alpha    = 1f;
            _delay    = _random.Next(0, 5);

            var duration          = _random.Next(40, 60);
            var targetY           = 500 + (float)_random.NextDouble() * 400;
            var rotationDirection = _random.NextDouble() < 0.5 ? 1 : -1;

            _tween.AddTween(new TweenFloatEaseOut(_position.Y, targetY, duration * 5 / 6, y => _position.Y = y));
            _tween.AddTween(new TweenFloatEaseOut(_rotation, _rotation + (float)Math.PI * 0.5f * rotationDirection, duration, x => _rotation = x));
            _tween.AddTween(new TweenFloatEaseOut(1, 0, duration, x => _alpha = x));
        }
예제 #8
0
        public void ShouldStartEmpty()
        {
            var parallel = new TweenParallel();

            Assert.Equal(0, parallel.TweenCount);
        }
예제 #9
0
        public void ShouldThrowExceptionWhenAddingNullTween_adding()
        {
            var parallel = new TweenParallel();

            Assert.Throws <ArgumentNullException>(() => parallel.Add(null));
        }