Example #1
0
        internal void Move(TrainPosition position)
        {
            switch (this.Direction)
            {
            case TrackDirection.Horizontal: TrainMovement.MoveHorizontal(position); break;

            case TrackDirection.Vertical: TrainMovement.MoveVertical(position); break;

            case TrackDirection.LeftUp: TrainMovement.MoveLeftUp(position); break;

            case TrackDirection.RightUp: TrainMovement.MoveRightUp(position); break;

            case TrackDirection.RightDown: TrainMovement.MoveRightDown(position); break;

            case TrackDirection.LeftDown: TrainMovement.MoveLeftDown(position); break;

            case TrackDirection.RightUp_RightDown: MoveRightUpDown(position); break;

            case TrackDirection.RightDown_LeftDown: MoveLeftRightDown(position); break;

            case TrackDirection.LeftDown_LeftUp: MoveLeftUpDown(position); break;

            case TrackDirection.LeftUp_RightUp: MoveLeftRightUp(position); break;

            case TrackDirection.Cross: MoveCross(position); break;

            default: throw new InvalidOperationException("I don't know what that track is!");
            }
        }
Example #2
0
 private void MoveLeftRightDown(TrainPosition position)
 {
     // Check single track extremes, as there are 2 places where the
     //  train angle could be at 0 degrees
     if (position.RelativeLeft < 0.4f)
     {
         TrainMovement.MoveLeftDown(position);
     }
     else if (position.RelativeLeft > 0.6f)
     {
         TrainMovement.MoveRightDown(position);
     }
     else if (position.Angle <= 90.0)
     {
         TrainMovement.MoveLeftDown(position);
     }
     else
     {
         if (this.AlternateState)
         {
             TrainMovement.MoveLeftDown(position);
         }
         else
         {
             TrainMovement.MoveRightDown(position);
         }
     }
 }
Example #3
0
 private void MoveRightUpDown(TrainPosition position)
 {
     // Right -> Up, Enters 180, Leaves 270
     // Up -> Right, Enters 90, Leaves 0
     // Down -> Right, Enters 270, Leaves 0
     if (position.RelativeTop < 0.4f)
     {
         TrainMovement.MoveRightUp(position);
     }
     else if (position.RelativeTop > 0.6f)
     {
         TrainMovement.MoveRightDown(position);
     }
     else if (position.Angle >= 270.0)
     {
         TrainMovement.MoveRightDown(position);
     }
     else
     {
         if (this.AlternateState)
         {
             TrainMovement.MoveRightDown(position);
         }
         else
         {
             TrainMovement.MoveRightUp(position);
         }
     }
 }
Example #4
0
 private static void MoveLeftRightDown(TrainPosition position)
 {
     if (position.Angle <= 90.0)
     {
         TrainMovement.MoveLeftDown(position);
     }
     else
     {
         TrainMovement.MoveRightDown(position);
     }
 }
Example #5
0
 private static void MoveRightUpDown(TrainPosition position)
 {
     if ((position.Angle >= 180 && position.Angle <= 90.0) ||
         (position.Angle >= 270 && position.Angle <= 360))
     {
         TrainMovement.MoveRightDown(position);
     }
     else
     {
         TrainMovement.MoveRightUp(position);
     }
 }