コード例 #1
0
        public void TestVMFImportExport()
        {
            // Create a new JSON adapter
            VMFAdapter adapter = new VMFAdapter("testinput.vmf", 64, 64);

            // Setup: Create a NailsMap
            NailsMap map = adapter.Import();

            // Export the map
            adapter.Export(map);

            // Import the map
            var newMap = adapter.Import();

            // Compare
            Assert.IsNotNull(newMap);
            NailsCube cube = newMap.GetCube(0, 0, 0);

            Assert.IsNotNull(cube);
            Assert.AreEqual("TestStyle", cube.StyleName);
            cube = newMap.GetCube(0, 1, 0);
            Assert.IsNotNull(cube);
            Assert.AreEqual("TestStyle", cube.StyleName);
            cube = newMap.GetCube(1, 1, 0);
            Assert.IsNotNull(cube);
            Assert.AreEqual("TestStyle", cube.StyleName);
        }
コード例 #2
0
ファイル: TestNailsMap.cs プロジェクト: 1upD/Nails
        public void TestGetTwoCubes_OtherLocation()
        {
            // Setup: Create a NailsMap
            NailsMap map = new NailsMap();

            // Mark a location
            map.MarkLocation("TestStyle", 0, 0, 0);
            map.MarkLocation("TestStyle", 0, 1, 0);

            // If there is no cube at the location
            NailsCube cube = map.GetCube(0, -1, 0);

            Assert.IsNull(cube);

            cube = map.GetCube(1, 0, 0);
            Assert.IsNull(cube);

            cube = map.GetCube(-1, 0, 0);
            Assert.IsNull(cube);

            cube = map.GetCube(0, -1, 0);
            Assert.IsNull(cube);

            cube = map.GetCube(0, 0, -1);
            Assert.IsNull(cube);

            cube = map.GetCube(0, 0, 1);
            Assert.IsNull(cube);
        }
コード例 #3
0
ファイル: TestNailsMap.cs プロジェクト: 1upD/Nails
        public void TestGetCube_NothingAtLocation()
        {
            // Setup: Create a NailsMap
            NailsMap map = new NailsMap();

            // If there is no cube at the location
            NailsCube cube = map.GetCube(0, 0, 0);

            Assert.IsNull(cube);
        }
コード例 #4
0
ファイル: TestNailsMap.cs プロジェクト: 1upD/Nails
        public void TestGetCube()
        {
            // Setup: Create a NailsMap
            NailsMap map = new NailsMap();

            // Mark a location
            map.MarkLocation("TestStyle", 0, 0, 0);

            // If there is no cube at the location
            NailsCube cube = map.GetCube(0, 0, 0);

            Assert.IsNotNull(cube);
            Assert.AreEqual(cube.StyleName, "TestStyle");
        }
コード例 #5
0
ファイル: TestNailsMap.cs プロジェクト: 1upD/Nails
        public void TestCubeMarkedMultipleTimes()
        {
            // Setup: Create a NailsMap
            NailsMap map = new NailsMap();

            // Mark a location
            map.MarkLocation("TestStyle", 0, 0, 0);
            map.MarkLocation("TestStyle", 0, 0, 0);

            // Get the cube
            NailsCube cube = map.GetCube(0, 0, 0);

            // Should act as though there is only one cube
            Assert.IsNotNull(cube);
            Assert.AreEqual(cube.StyleName, "TestStyle");
        }
コード例 #6
0
ファイル: NailsAlifeMap.cs プロジェクト: 1upD/Nails
        public string GetLocation(int x, int y, int z)
        {
            NailsCube cube = null;

            try
            {
                cube = this.map.GetCube(x, y, z);
            } catch (Exception e)
            {
                log.Error("NailsAlifeMap.GetLocation(): Caught exception: ", e);
            }

            if (cube == null)
            {
                return(null);
            }

            return(cube.StyleName);
        }
コード例 #7
0
ファイル: TestNailsMap.cs プロジェクト: 1upD/Nails
        public void TestFacesTwoCubes_FrontBack()
        {
            // Setup: Create a NailsMap
            NailsMap map = new NailsMap();

            // Mark a location
            map.MarkLocation("TestStyle", 0, 0, 0);
            map.MarkLocation("TestStyle", 1, 0, 0);

            // If there is no cube at the location
            NailsCube cube = map.GetCube(0, 0, 0);

            Assert.IsNotNull(cube);
            Assert.AreEqual(cube.StyleName, "TestStyle");

            // Check the second cube
            cube = map.GetCube(1, 0, 0);

            // Look at faces
            var faces = cube.GetFaces();

            Assert.IsTrue(faces.Contains(NailsCubeFace.Floor));
            Assert.IsTrue(faces.Contains(NailsCubeFace.Front));
            Assert.IsTrue(faces.Contains(NailsCubeFace.Left));
            Assert.IsFalse(faces.Contains(NailsCubeFace.Back));
            Assert.IsTrue(faces.Contains(NailsCubeFace.Right));
            Assert.IsTrue(faces.Contains(NailsCubeFace.Ceiling));

            // Check the first cube
            cube = map.GetCube(0, 0, 0);

            // Look at faces
            faces = cube.GetFaces();
            Assert.IsTrue(faces.Contains(NailsCubeFace.Floor));
            Assert.IsFalse(faces.Contains(NailsCubeFace.Front));
            Assert.IsTrue(faces.Contains(NailsCubeFace.Left));
            Assert.IsTrue(faces.Contains(NailsCubeFace.Back));
            Assert.IsTrue(faces.Contains(NailsCubeFace.Right));
            Assert.IsTrue(faces.Contains(NailsCubeFace.Ceiling));
        }
コード例 #8
0
ファイル: JSONAdapterTest.cs プロジェクト: 1upD/Nails
        public void TestImportExport()
        {
            // Setup: Create a NailsMap
            NailsMap map = new NailsMap();

            // Mark a location
            map.MarkLocation("TestStyle", 0, 1, 0);

            // Create a new JSON adapter
            JSONAdapter adapter = new JSONAdapter("testoutput.json");

            // Export the map
            adapter.Export(map);

            // Import the map
            var newMap = adapter.Import();

            // Compare
            Assert.IsNotNull(newMap);
            NailsCube cube = newMap.GetCube(0, 1, 0);

            Assert.IsNotNull(cube);
            Assert.AreEqual("TestStyle", cube.StyleName);
        }