Exemple #1
0
        private void Test_L_RepositonDirection()
        {
            ShapeCollection rectangles = new ShapeCollection();

            // This tests the following bug:

            // https://trello.com/c/twwOTKFz/411-l-shaped-corners-can-cause-entities-to-teleport-through-despite-using-proper-reposition-directions

            // make corner first so it is tested first
            var corner = new AxisAlignedRectangle();

            corner.X      = 0;
            corner.Y      = 0;
            corner.Width  = 32;
            corner.Height = 32;
            corner.RepositionDirections = RepositionDirections.Left | RepositionDirections.Down;
            rectangles.AxisAlignedRectangles.Add(corner);

            var top = new AxisAlignedRectangle();

            top.X      = 0;
            top.Y      = 32;
            top.Width  = 32;
            top.Height = 32;
            top.RepositionDirections = RepositionDirections.Left | RepositionDirections.Right;
            rectangles.AxisAlignedRectangles.Add(top);

            var right = new AxisAlignedRectangle();

            right.X      = 32;
            right.Y      = 0;
            right.Width  = 32;
            right.Height = 32;
            right.RepositionDirections = RepositionDirections.Up | RepositionDirections.Down;
            rectangles.AxisAlignedRectangles.Add(right);

            var movable = new AxisAlignedRectangle();

            movable.X      = 32 - 1;
            movable.Y      = 32 - 1;
            movable.Width  = 32;
            movable.Height = 32;

            movable.CollideAgainstMove(rectangles, 0, 1);

            movable.X.ShouldBeGreaterThan(31);
            movable.Y.ShouldBeGreaterThan(31);
        }