protected override void UpdateLocal(ElapsedTime elapsedTime)
        {
            if (!Playing)
            {
                Direction = Vector2.Zero;
                return;
            }

            float deltaTime = elapsedTime.GetDelta(this);

            Time     += deltaTime;
            Distance += Speed * deltaTime;

            Position = StartPosition + Trajectory.GetPositionAtDistance(Distance, out float newProgress);
            Progress = newProgress;

            Vector2 move = Position - LastPosition;

            Direction = move.Normalized();

            if (Progress >= 1f)
            {
                Position = Trajectory.Destination;
                Time    -= (Distance - Trajectory.Length) / Speed;
                Distance = Trajectory.Length;
                Progress = 1;
                End();
            }

            LastPosition = Position;
        }
        protected override void UpdateLocal(ElapsedTime elapsedTime)
        {
            if (!Playing)
            {
                Direction    = Vector2.Zero;
                CurrentSpeed = 0;
                return;
            }

            float deltaTime = elapsedTime.GetDelta(this);

            Time += deltaTime;

            Position = StartPosition + Trajectory.GetPositionAtTime(Time, out float newProgress);
            Progress = newProgress;

            Vector2 move = Position - LastPosition;

            Direction = move.Normalized();

            Distance    += move.Length();
            CurrentSpeed = Distance / deltaTime;

            if (Progress >= 1f)
            {
                Position  = Trajectory.Destination;
                Distance -= (Time - Trajectory.Duration) * Speed;
                Time      = Trajectory.Duration;
                Progress  = 1;
                End();
            }

            LastPosition = Position;
        }
Exemple #3
0
        protected override Vector2 UpdateVelocity(ElapsedTime elapsedTime)
        {
            if (Trajectory == null)
            {
                return(Vector2.Zero);
            }

            float distance = Distance;

            distance += Speed * elapsedTime.GetDelta(Motion);
            Vector2 newPosition = Trajectory.GetPositionAtDistance(distance, out float progress);

            Progress = progress;
            return(newPosition - Motion.SceneNode.Position);
        }
Exemple #4
0
 protected override Vector2 UpdateVelocity(ElapsedTime elapsedTime)
 {
     return(Direction * Speed * elapsedTime.GetDelta(Motion));
 }