Пример #1
0
        private void ValidateCoordToPosition(int x, int y)
        {
            float expectedX = -mapSize.X / 2f + 0.5f * tileSize + x * tileSize;
            float expectedY = -mapSize.Y / 2f + 0.5f * tileSize + y * tileSize;

            Vector3 v1 = TileUtil.CoordToPosition(new Coord(x, y));
            Vector3 v2 = TileUtil.CoordToPosition(x, y);

            Assert.IsTrue(v1.Equals(v2));
            Assert.AreEqual(new Vector3(expectedX, 0, expectedY), v1);
        }
Пример #2
0
 private static void ValidateCoord(int x, int y)
 {
     try
     {
         TileUtil.CoordToPosition(new Coord(x, y));
     }
     catch (CoordinateTranslationException)
     {
         // this exception is being expected
         return;
     }
     Assert.Fail();
 }
Пример #3
0
        public void RandomPositionTest()
        {
            Coord pos    = TileUtil.RandomPosition();
            int   length = 1000;

            for (int i = 0; i < length; i++)
            {
                Coord c = TileUtil.RandomPosition();
                if (!c.Equals(pos))
                {
                    // random generation works at least a bit
                    return;
                }
            }
            Assert.Fail();
        }