Example #1
0
        public override void Start(Timeline t, Vector2 origin, Vector2 impulse)
        {
            base.Start(t, origin, impulse);

            var size = (Rand.Between(.05f, .1f) * Force).Clamp(0, 5);
            var l = (Rand.Between(-Radius, Radius) * Force / 50).Clamp(0, 2f);
            var d = impulse.Rotate(MathKit.HalfPi, Vector2.Zero);
            d.Normalize();

            Velocity *= 2;
            Alpha = 0;
            Size = 0;
            Color = BaseColor;
            Width = 1;
            Height = (Force / 20).Clamp(.1f, 2);
            Position = origin + l * d;
            Scale = Vector2.Zero;

            var fadeOutTime = (size * .01f * Force).Clamp(0.1f, 1f);

            t.RunInParallel(
                new Tween(v => Scale = new Vector2(v, v), 0, size, .1f, Sine.EaseOut),
                new Tween(v => Alpha = v, 0, 1, .1f, Sine.EaseOut))
                .RunInParallel(
                    new Tween(v => Alpha = v, 1, 0, fadeOutTime, Sine.EaseOut),
                    new Tween(v => Scale = new Vector2(v, v), size, 0, fadeOutTime, Sine.EaseOut))
                .Then(Dispose);
        }
Example #2
0
        public JumpController(Body body, Keys key)
        {
            _body = body;

            _timeline = Create<Timeline>();

            Add(new KeyBinding(key, PrepareJump, Jump));
            Add(new GamePadButtonBinding(Buttons.A, PrepareJump, Jump));
        }
Example #3
0
        public override void Start(Timeline t, Vector2 origin, Vector2 impulse)
        {
            base.Start(t, origin, impulse);
            var close = Far + _distanceInterpolation.From(Rand.Between(0, 1f));

            Width = close * W * Rand.Between(.8f, 1f);
            Height = H * close * Rand.Between(.8f, 1.5f);
            Alpha = (A * close).Clamp(.01f, 1f);
            Y += Rand.Float() * Spread * Rand.Sign();

            var speed = Speed * close * close;

            t.Tween(v => Velocity = new Vector2(v, 0), 0, -speed, 2, Sine.EaseIn);
            t.Tween(v => Width = v, 1f, close * W * Rand.Between(.8f, 1f), 1, Sine.EaseIn);
            t.Tween(v => Y = v, Y, Y + close * Rand.Between(-SpreadRange, SpreadRange), 10f / close, Sine.EaseIn);
        }
Example #4
0
        public override void Start(Timeline t, Vector2 origin, Vector2 impulse)
        {
            base.Start(t, origin, impulse);

            Height = 1;
            HorizontalAlignment = HorizontalAlignment.Left;
            VerticalAlignment = VerticalAlignment.Top;

            var screen = Render.Camera.ScreenArea;
            Position = new Vector2(Rand.Between(screen.Left, screen.Right),
                                   Rand.Between(screen.Top, screen.Bottom));

            var alpha = Rand.Between(.2f, .9f);
            t.Tween(v => Alpha = v, 0, alpha, 5, Sine.EaseInOut);

            _length = Rand.Between(.1f, .3f);
        }
Example #5
0
        public override void Start(Timeline t, Vector2 origin, Vector2 impulse)
        {
            base.Start(t, origin, impulse);
            Width = Height = 0;
            var pos = origin + Rand.Between(-Range, Range);
            var size = Radius * (.2f + Rand.Float() * .8f);
            var alpha = .05f + .1f * Rand.Float();

            t.RunInParallel( // expand phase
                //new Tween(v => Position = (origin + (pos - origin) * v), 0, 1, FadeInDuration, Quad.EaseInOut),
                new Tween(v => Width = Height = v, 0, size, FadeInDuration / 5, Cubic.EaseOut),
                new Tween(v => Alpha = v, alpha, alpha, FadeInDuration, Cubic.EaseOut))
                .RunInParallel( // collapse phase
                    //new Tween(v => Position = (origin + (pos - origin) * v), 1, 1.5f, FadeOutDuration, Quad.EaseOut),
                    new Tween(v => Width = Height = v, size, size / 5, alpha * FadeOutDuration * 2f, Sine.EaseIn),
                    new Tween(v => Alpha = v, alpha, 0, FadeOutDuration * (.5f + Rand.Float() * .5f)))
                .Then(Kill);
        }
Example #6
0
        public FlyController(Body body, float force = .5f, float max = 3, float linearDamping = 0)
        {
            Force = force;
            Body = body;
            _engine = Add(new BodyController(body, max));

            Add(new KeyBinding(Keys.W, () => _engine.ApplyForce(0, -Force), true));
            Add(new KeyBinding(Keys.S, () => _engine.ApplyForce(0, Force), true));
            Add(new KeyBinding(Keys.A, () => _engine.ApplyForce(-Force, 0), true));
            Add(new KeyBinding(Keys.D, () => _engine.ApplyForce(Force, 0), true));

            Add(new KeyBinding(Keys.LeftShift, StartBreak, StopBreaking, Break));
            Add(new KeyBinding(Keys.Space, PrepareBoost, StartBoost, Break));

            Add(new GamePadStickBinding(Side.Left, v => _engine.ApplyForce(0, -force * v.Y / 10)));
            Add(new GamePadStickBinding(Side.Left, v => _engine.ApplyForce(0, -force * v.Y)));
            Add(new GamePadStickBinding(Side.Left, v => _engine.ApplyForce(force * v.X, 0)));
            Add(new GamePadStickBinding(Side.Left, v => _engine.ApplyForce(force * v.X, 0)));

            _boostTimer = Create<Timeline>();
        }
Example #7
0
 public TweenTest()
 {
     _shape = Add(new VectoShape());
     _timer = Create<Timeline>();
 }
Example #8
0
 public TailSegment(Body body, Body previous, Timeline timeline)
 {
     _timeline = timeline;
     _previous = previous;
     _body = body;
 }
Example #9
0
 private void SetupAnimation()
 {
     _timeline = Create<Timeline>();
 }
Example #10
0
 public BoostController(Body body)
 {
     _body = body;
     _boostTimer = Create<Timeline>();
 }