Beispiel #1
0
        void This_HorseGotUpSpeed(Horse horse, int prev_randDuration)
        {
            int             randDuration  = prev_randDuration + random.Next(-2, 2);
            DoubleAnimation uniformMotion = new DoubleAnimation(Canvas.GetLeft(horse), finishLine.X1, TimeSpan.FromSeconds(randDuration), FillBehavior.HoldEnd);

            horse.changeSpeed(randDuration);
            uniformMotion.Completed += (s, _) => This_HorseFinishing(horse, randDuration);
            horse.BeginAnimation(Canvas.LeftProperty, uniformMotion);
        }
Beispiel #2
0
        void This_HorseFinishing(Horse horse, int prev_randDuration)
        {
            DoubleAnimation finishing = new DoubleAnimation(Canvas.GetLeft(horse), finishLine.X1 + 144 - 12 * prev_randDuration, TimeSpan.FromSeconds((14 - prev_randDuration) / 2), FillBehavior.HoldEnd);

            horse.changeSpeed(prev_randDuration + 2);
            finishing.Completed += (s, _) => horse.stopMoving();
            EasingFunctionBase easingFunction = new RunningEase();

            easingFunction.EasingMode = EasingMode.EaseOut;
            finishing.EasingFunction  = easingFunction;
            horse.BeginAnimation(Canvas.LeftProperty, finishing);
        }
Beispiel #3
0
        void Move(Horse horse)
        {
            int                randDuration   = random.Next(6, 10);
            DoubleAnimation    starting       = new DoubleAnimation(Canvas.GetLeft(horse), middleLine.X1, TimeSpan.FromSeconds(randDuration), FillBehavior.HoldEnd);
            EasingFunctionBase easingFunction = new RunningEase();

            easingFunction.EasingMode = EasingMode.EaseIn;
            starting.EasingFunction   = easingFunction;
            starting.Completed       += (s, _) => This_HorseGotUpSpeed(horse, randDuration);
            horse.changeSpeed(randDuration);
            horse.BeginAnimation(Canvas.LeftProperty, starting);
        }