コード例 #1
0
        public void MapPointCollisionTest1x1()
        {
            var point1 = new MapPoint(100, 100, 1, 1);
            var point2 = new MapPoint(100, 100, 1, 1); // Same location map point, will collide
            var pointR = new MapPoint(101, 100, 1, 1); // Map point one to the right
            var pointL = new MapPoint(99, 100, 1, 1);  // Map point one to the left
            var pointT = new MapPoint(100, 101, 1, 1); // Map point one tile above
            var pointB = new MapPoint(100, 99, 1, 1);  // Map point one tile above

            // Same X,Y and 1x1 dimension test
            Assert.IsTrue(point1.CollidesWith(point2), "Point1 does NOT collide with Point2");
            // Test for symmetry
            Assert.IsTrue(point2.CollidesWith(point1), "Point2 does NOT collide with Point1");

            // Test a point that is off by 1 for 1x1 area points don't collide
            Assert.IsFalse(point1.CollidesWith(pointR), "Point1 DOES collide with PointR");
            Assert.IsFalse(point2.CollidesWith(pointR), "Point2 DOES collide with PointR");
            // Symmetry test
            Assert.IsFalse(pointR.CollidesWith(point1), "PointR DOES collide with Point1");
            Assert.IsFalse(pointR.CollidesWith(point2), "PointR DOES collide with Point2");

            // More map point tests that are off by one in other directions
            Assert.IsFalse(point1.CollidesWith(pointL), "Point1 DOES collide with PointL");
            Assert.IsFalse(pointL.CollidesWith(point1), "PointL DOES collide with Point1");

            Assert.IsFalse(point1.CollidesWith(pointT), "Point1 DOES collide with PointT");
            Assert.IsFalse(pointT.CollidesWith(point1), "PointT DOES collide with Point1");

            Assert.IsFalse(point1.CollidesWith(pointB), "Point1 DOES collide with PointB");
            Assert.IsFalse(pointB.CollidesWith(point1), "PointB DOES collide with Point1");
        }