コード例 #1
0
        public void FindShortestPath()
        {
            var shortest = new ShortestPath();
            var map      = new TerrainMap(shortest);

            map.InitializeBoard(10, 10);

            //mountains 4,1 - 4,8
            for (var i = 1; i < 9; i++)
            {
                var cube = HexGridMath.OffsetToCube(4, i);
                map[4, i] = new TerrainCell(cube.X, cube.Y, cube.Z, 30);
            }

            // 1,3 to 8,4
            shortest.ComputeShortestPath(map, 1, 3, 8, 4, 0);

            Assert.Equal(new Offset(2, 3), shortest.WayPoint[0]);
            Assert.Equal(new Offset(3, 2), shortest.WayPoint[1]);
            Assert.Equal(new Offset(3, 1), shortest.WayPoint[2]);
            Assert.Equal(new Offset(3, 0), shortest.WayPoint[3]);
            Assert.Equal(new Offset(4, 0), shortest.WayPoint[4]);
            Assert.Equal(new Offset(5, 0), shortest.WayPoint[5]);
            Assert.Equal(new Offset(6, 1), shortest.WayPoint[6]);
            Assert.Equal(new Offset(7, 1), shortest.WayPoint[7]);
            Assert.Equal(new Offset(8, 2), shortest.WayPoint[8]);
            Assert.Equal(new Offset(8, 3), shortest.WayPoint[9]);
            Assert.Equal(new Offset(8, 4), shortest.WayPoint[10]);
        }
コード例 #2
0
        public void HasherTest()
        {
            var terrainMap = new TerrainMap(new ShortestPath());

            terrainMap[2, 2] = new TerrainCell(0, 0, 0, 2);
            var cube = HexGridMath.OffsetToCube(2, 2);
            var hash = terrainMap.FindMapHash(cube.X, cube.Y, cube.Z);

            var terrain = terrainMap[hash];

            Assert.Equal(2, terrain.BackgroundType);
        }