예제 #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;
 }
예제 #2
0
파일: Track.cs 프로젝트: vidstige/URT
 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;
 }
예제 #3
0
 private void CarOnPositionUpdated(Car car)
 {
     RaisePropertyChanged("X");
     RaisePropertyChanged("Y");
     RaisePropertyChanged("Angle");
 }
예제 #4
0
파일: Car.cs 프로젝트: vidstige/URT
 public void Drive(Car next, ITrack track)
 {
     double a = _driver.GetAcceleration(this, next, track);
     _velocity += a;
 }
예제 #5
0
 public CarViewModel(Track track, Car car)
 {
     _track = track;
     _car = car;
     _car.PositionUpdated += CarOnPositionUpdated;
 }