Example #1
0
        public void TwoCrosses()
        {
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(2, 2);
            TrackLayout.AddTrack(3, 2);
            TrackLayout.AddTrack(2, 1);

            TrackLayout.AddTrack(1, 4);
            TrackLayout.AddTrack(2, 4);
            TrackLayout.AddTrack(3, 4);
            TrackLayout.AddTrack(2, 5);

            TrackLayout.AddTrack(2, 3);

            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.Cross, TrackLayout.GetTrackAt(2, 2).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 2).Direction);

            Assert.Equal(TrackDirection.Cross, TrackLayout.GetTrackAt(2, 4).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 4).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 4).Direction);

            Assert.True(TrackLayout.GetTrackAt(2, 3).Happy);
        }
Example #2
0
        public void Three_Verticals()
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(1, 3);
            TrackLayout.AddTrack(1, 4);
            TrackLayout.AddTrack(1, 5);

            TrackLayout.AddTrack(2, 2);
            TrackLayout.AddTrack(2, 3);
            TrackLayout.AddTrack(2, 4);

            TrackLayout.AddTrack(3, 3);

            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 3).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 4).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 5).Direction);

            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 4).Direction);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 3).Direction);
        }
Example #3
0
        public void Horizontal()
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(2, 1);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction);
        }
Example #4
0
        public void Vertical_TrainMovement(float startAngle, int startColumn, int startRow, int endColumn, int endRow)
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(1, 3);

            AssertTrainMovement(startAngle, startColumn, startRow, endColumn, endRow);
        }
Example #5
0
        public void Horizontal_TrainMovement(float startAngle, int startColumn, int startRow, int endColumn, int endRow)
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(3, 1);

            AssertTrainMovement(startAngle, startColumn, startRow, endColumn, endRow);
        }
Example #6
0
        public void Vertical()
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(1, 2);

            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction);
        }
Example #7
0
        public void LeftDown_TrainMovement(float startAngle, int startColumn, int startRow, int endColumn, int endRow)
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(2, 2);

            AssertTrainMovement(startAngle, startColumn, startRow, endColumn, endRow);
        }
Example #8
0
        public void LeftUp()
        {
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(2, 2);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(2, 2).Direction);
        }
Example #9
0
        public void RightDown()
        {
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(1, 2);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction);
        }
Example #10
0
        public void SidewaysHairpin()
        {
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(2, 2);
            TrackLayout.AddTrack(3, 2);
            TrackLayout.AddTrack(3, 1);
            TrackLayout.AddTrack(2, 1);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 2).Direction);
            Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(3, 2).Direction);
            Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(3, 1).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction);
        }
Example #11
0
        public void VerticalHairpin()
        {
            TrackLayout.AddTrack(1, 3);
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(2, 2);

            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 3).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction);
        }
Example #12
0
        public void CrossMiddleLast()
        {
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(3, 2);
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(2, 3);
            TrackLayout.AddTrack(2, 2);

            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.Cross, TrackLayout.GetTrackAt(2, 2).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 2).Direction);
        }
Example #13
0
        public void Happiness()
        {
            TrackLayout.AddTrack(1, 1);

            Assert.False(TrackLayout.GetTrackAt(1, 1).Happy);

            TrackLayout.AddTrack(1, 2);

            Assert.False(TrackLayout.GetTrackAt(1, 1).Happy);
            Assert.False(TrackLayout.GetTrackAt(1, 2).Happy);

            TrackLayout.AddTrack(1, 3);

            Assert.False(TrackLayout.GetTrackAt(1, 1).Happy);
            Assert.True(TrackLayout.GetTrackAt(1, 2).Happy);
            Assert.False(TrackLayout.GetTrackAt(1, 3).Happy);
        }
Example #14
0
        public void MovementTest_FullTrackLoop_3x3Square(float initialTrainAngle)
        {
            var trackLayout = new TrackLayout();
            var board       = new GameBoard(trackLayout, null, null);

            trackLayout.AddTrack(1, 1);
            trackLayout.AddTrack(2, 1);
            trackLayout.AddTrack(3, 1);
            trackLayout.AddTrack(3, 2);
            trackLayout.AddTrack(3, 3);
            trackLayout.AddTrack(2, 3);
            trackLayout.AddTrack(1, 3);
            trackLayout.AddTrack(1, 2);

            board.AddTrain(2, 1);

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

            float distance = (float)(4 * StraightTrackDistance +
                                     4 * CornerTrackDistance);

            // Train speed & angle
            train.ForceSpeed(distance / _movementSteps / Train.SpeedScaleModifier);
            train.SetAngle(initialTrainAngle);

            Assert.Equal(2, train.Column);
            Assert.Equal(1, train.Row);
            Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision);
            Assert.Equal(0.5f, train.RelativeTop, MovementPrecision);
            Assert.Equal(initialTrainAngle, train.Angle, MovementPrecision);

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

            Assert.Equal(2, train.Column);
            Assert.Equal(1, train.Row);
            Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision);
            Assert.Equal(0.5f, train.RelativeTop, MovementPrecision);
            Assert.Equal(initialTrainAngle, train.Angle, MovementPrecision);
        }
Example #15
0
        public void LeftAngleWithCircleOnTop()
        {
            TrackLayout.AddTrack(1, 3);
            TrackLayout.AddTrack(2, 3);
            TrackLayout.AddTrack(2, 4);
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(2, 2);
            TrackLayout.AddTrack(1, 2);

            Assert.Equal(TrackDirection.RightUp, TrackLayout.GetTrackAt(1, 3).Direction);
            Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(2, 3).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 4).Direction);
            Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(2, 2).Direction);
            Assert.Equal(TrackDirection.RightUpDown, TrackLayout.GetTrackAt(1, 2).Direction);
        }
Example #16
0
        public void LeftRightDown_DrawOver()
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(3, 1);
            TrackLayout.AddTrack(2, 2);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 1).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 2).Direction);

            TrackLayout.AddTrack(2, 1);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.RightDown_LeftDown, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 1).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction);
        }
Example #17
0
        public void LeftRightUp_DrawOver()
        {
            TrackLayout.AddTrack(1, 3);
            TrackLayout.AddTrack(2, 3);
            TrackLayout.AddTrack(3, 3);
            TrackLayout.AddTrack(2, 2);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 3).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 3).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 3).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 2).Direction);

            TrackLayout.AddTrack(2, 3);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 3).Direction);
            Assert.Equal(TrackDirection.LeftRightUp, TrackLayout.GetTrackAt(2, 3).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 3).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction);
        }
Example #18
0
        public void Two_Verticals()
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(1, 3);
            TrackLayout.AddTrack(1, 4);

            TrackLayout.AddTrack(2, 2);
            TrackLayout.AddTrack(2, 3);


            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 3).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 4).Direction);

            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction);
        }
Example #19
0
        public void Trident()
        {
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(2, 2);
            TrackLayout.AddTrack(3, 2);
            TrackLayout.AddTrack(3, 1);
            TrackLayout.AddTrack(2, 3);
            TrackLayout.AddTrack(2, 2);

            TrackLayout.AddTrack(2, 1);

            Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.RightUp, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.Cross, TrackLayout.GetTrackAt(2, 2).Direction);
            Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(3, 2).Direction);
            Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(3, 1).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction);

            Assert.Equal(TrackDirection.LeftRightDown, TrackLayout.GetTrackAt(2, 1).Direction);
        }
Example #20
0
        public void FishHook()
        {
            TrackLayout.AddTrack(5, 2);
            TrackLayout.AddTrack(4, 2);
            TrackLayout.AddTrack(3, 2);
            TrackLayout.AddTrack(3, 3);
            TrackLayout.AddTrack(2, 3);
            TrackLayout.AddTrack(1, 3);
            TrackLayout.AddTrack(1, 2);
            TrackLayout.AddTrack(1, 1);
            TrackLayout.AddTrack(2, 1);
            TrackLayout.AddTrack(3, 1);

            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(5, 2).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(4, 2).Direction);
            Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(3, 2).Direction);
            Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(3, 3).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 3).Direction);
            Assert.Equal(TrackDirection.RightUp, TrackLayout.GetTrackAt(1, 3).Direction);
            Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction);
            Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction);
            Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 1).Direction);
        }
Example #21
0
        public void MovementTest_FullTrackLoop_FourLoopCorners(float initialTrainAngle)
        {
            var trackLayout = new TrackLayout();
            var board       = new GameBoard(trackLayout, null, null);

            trackLayout.AddTrack(3, 2);
            trackLayout.AddTrack(4, 2);
            trackLayout.AddTrack(5, 2);
            trackLayout.AddTrack(5, 1);
            trackLayout.AddTrack(4, 1);
            trackLayout.AddTrack(4, 3);
            trackLayout.AddTrack(4, 4);
            trackLayout.AddTrack(4, 5);
            trackLayout.AddTrack(5, 5);
            trackLayout.AddTrack(5, 4);
            trackLayout.AddTrack(3, 4);
            trackLayout.AddTrack(2, 4);
            trackLayout.AddTrack(1, 4);
            trackLayout.AddTrack(1, 5);
            trackLayout.AddTrack(2, 5);
            trackLayout.AddTrack(2, 3);
            // Skip until end!
            trackLayout.AddTrack(2, 1);
            trackLayout.AddTrack(1, 1);
            trackLayout.AddTrack(1, 2);
            // Finish it off
            trackLayout.AddTrack(2, 2);

            board.AddTrain(3, 2);

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

            float distance = (float)(12 * StraightTrackDistance +
                                     12 * CornerTrackDistance);

            train.Angle = initialTrainAngle;
            train.ForceSpeed(distance / _movementSteps / Train.SpeedScaleModifier);

            Assert.Equal(3, train.Column);
            Assert.Equal(2, train.Row);
            Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision);
            Assert.Equal(0.5f, train.RelativeTop, MovementPrecision);
            Assert.Equal(initialTrainAngle, train.Angle, MovementPrecision);

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

            Assert.Equal(3, train.Column);
            Assert.Equal(2, train.Row);
            Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision);
            Assert.Equal(0.5f, train.RelativeTop, MovementPrecision);
            Assert.Equal(initialTrainAngle, train.Angle, MovementPrecision);
        }