Example #1
0
 public double GetAcceleration(Car car, Car next, ITrack track)
 {
     var distance = track.Distance(car, next);
     if (distance < ComfortDistance)
     {
         _targetVelocity = next.Velocity / 2;
     }
     if (distance > ComfortDistance * 5)
     {
         _targetVelocity = _comfortVelocity;
     }
     var a = (_targetVelocity - car.Velocity);
     if (a > MaxAceleration) a = MaxAceleration;
     if (a < -MaxAceleration) a = -MaxAceleration;
     return a;
 }
Example #2
0
 public static double Distance(this ITrack track, Car a, Car b)
 {
     if (a.Position < b.Position) return b.Position - a.Position;
     return track.Length + b.Position - a.Position;
 }
Example #3
0
 private void CarOnPositionUpdated(Car car)
 {
     RaisePropertyChanged("X");
     RaisePropertyChanged("Y");
     RaisePropertyChanged("Angle");
 }
Example #4
0
File: Car.cs Project: vidstige/URT
 public void Drive(Car next, ITrack track)
 {
     double a = _driver.GetAcceleration(this, next, track);
     _velocity += a;
 }
Example #5
0
 public CarViewModel(Track track, Car car)
 {
     _track = track;
     _car = car;
     _car.PositionUpdated += CarOnPositionUpdated;
 }