Beispiel #1
0
        public TrainSpeed(SpeedStepSetting speedStepSetting, DrivingDirection drivingDirection, Speed speed)
        {
            if (speed > MaxSpeeds[speedStepSetting])
            {
                throw new ArgumentOutOfRangeException(nameof(speed), $"Max speed with setting {speedStepSetting} is {MaxSpeeds[speedStepSetting]}, actual {speed}");
            }
            if (speed < Speed.Stop)
            {
                throw new ArgumentOutOfRangeException(nameof(speed), $"Min speed is -1 as {Speed.Stop}, to change direction, use {nameof(drivingDirection)}.");
            }

            this.speedStepSetting = speedStepSetting;
            this.drivingDirection = drivingDirection;
            this.speed            = speed;
        }
Beispiel #2
0
 internal TrainSpeed(SpeedStepSetting speedStepSetting, byte speedByte)
 {
     this.speedStepSetting = speedStepSetting;
     this.drivingDirection = (speedByte & DirectionMask) == 0 ? DrivingDirection.Backward : DrivingDirection.Forward;
     if (speedStepSetting == SpeedStepSetting.Step128)
     {
         this.speed = (Speed)((Speed128Mask & speedByte) - 1);
     }
     else
     {
         this.speed = (Speed)((Speed14Mask & speedByte) - 1);
         if (speed > 0 && speedStepSetting == SpeedStepSetting.Step28)
         {
             this.speed = (Speed)(((sbyte)speed << 1) - ((speedByte & ExtraBitSpeed28Mask) == 0 ? 1 : 0));
         }
     }
 }
 public PoopyMacgoopyTrack WithCarsDriving(DrivingDirection drivingDirection)
 {
     Direction = drivingDirection;
     return this;
 }
 public PoopyMacgoopyTrack()
 {
     Direction = new DrivingDirection();
     Walls = new List<Point>();
     WithStartingLineAtPoints(0, 0, 0, 0);
 }