Beispiel #1
0
        public void ConvertToMapPos_ConvertToWorldPos_Equals_OriginalInput_WithZoom()
        {
            int x            = random.Next();
            int y            = random.Next();
            var mapRectangle = new Data.Entities.Rectangle()
            {
                X = x, Y = y, Width = 100, Height = 100
            };

            x = random.Next();
            y = random.Next();
            var continentRectangle = new Data.Entities.Rectangle()
            {
                X = x, Y = y, Width = 100, Height = 100
            };

            int maxZoom = random.Next();

            Point inputPoint = new Point(
                random.Next((int)continentRectangle.X, (int)(continentRectangle.X + continentRectangle.Width)),
                random.Next((int)continentRectangle.Y, (int)(continentRectangle.Y + continentRectangle.Height)));

            Point mapPos   = MapsHelper.ConvertToMapPos(continentRectangle, mapRectangle, inputPoint, maxZoom / 2, maxZoom);
            Point worldPos = MapsHelper.ConvertToWorldPos(continentRectangle, mapRectangle, mapPos, maxZoom / 2, maxZoom);

            Assert.AreEqual(inputPoint.X, worldPos.X, 0.5);
            Assert.AreEqual(inputPoint.Y, worldPos.Y, 0.5);
            Assert.AreEqual(inputPoint.Z, worldPos.Z, 0.5);
        }
Beispiel #2
0
        public void ConvertToMapPos_ConvertToWorldPos_Equals_OriginalInput_WithZoom()
        {
            Map testMap = new Map();
            int x       = random.Next();
            int y       = random.Next();

            testMap.MapRectangle = new Rectangle(new Vector2D(x, y), new Vector2D(random.Next(x, int.MaxValue), random.Next(y, int.MaxValue)));
            x = random.Next();
            y = random.Next();
            testMap.ContinentRectangle = new Rectangle(new Vector2D(x, y), new Vector2D(random.Next(x, int.MaxValue), random.Next(y, int.MaxValue)));
            testMap.Continent          = new Continent();

            testMap.MaximumLevel = random.Next();

            Point inputPoint = new Point(
                random.Next((int)testMap.ContinentRectangle.X, (int)(testMap.ContinentRectangle.X + testMap.ContinentRectangle.Width)),
                random.Next((int)testMap.ContinentRectangle.Y, (int)(testMap.ContinentRectangle.Y + testMap.ContinentRectangle.Height)));

            Point mapPos   = MapsHelper.ConvertToMapPos(testMap, inputPoint, testMap.MaximumLevel / 2);
            Point worldPos = MapsHelper.ConvertToWorldPos(testMap, mapPos, testMap.MaximumLevel / 2);

            Assert.AreEqual(inputPoint.X, worldPos.X, 0.5);
            Assert.AreEqual(inputPoint.Y, worldPos.Y, 0.5);
            Assert.AreEqual(inputPoint.Z, worldPos.Z, 0.5);
        }