示例#1
0
        public void MovementTest_PointToPoint_3VerticalTracks(int startingColumn, int startingRow, float angle, int expectedColumn, int expectedRow)
        {
            _trackLayout.AddTrack(1, 1);
            _trackLayout.AddTrack(1, 2);
            _trackLayout.AddTrack(1, 3);

            _gameBoard.AddTrain(startingColumn, startingRow);

            float distance = (float)(HalfStraightTrackDistance + StraightTrackDistance + HalfStraightTrackDistance);

            var train = (Train)_gameBoard.GetMovables().Single();

            train.ForceSpeed(distance / _movementSteps / Train.SpeedScaleModifier);
            train.Angle = angle;
            // We have an edge coming up, disable lookahead
            train.LookaheadDistance = 0.0f;

            Assert.Equal(startingColumn, train.Column);
            Assert.Equal(startingRow, train.Row);
            Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision);
            Assert.Equal(0.5f, train.RelativeTop, MovementPrecision);
            Assert.Equal(angle, train.Angle, MovementPrecision);



            // Move it!
            for (int i = 0; i < _movementSteps; i++)
            {
                _gameBoard.GameLoopStep();
            }

            Assert.Equal(expectedColumn, train.Column);
            Assert.Equal(expectedRow, train.Row);
            Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision);
            Assert.Equal(0.5f, train.RelativeTop, MovementPrecision);
            Assert.Equal(angle, train.Angle, MovementPrecision);
        }
示例#2
0
 public void Execute(int column, int row)
 {
     _trackLayout.AddTrack(column, row);
 }