public void TestThatRenderingBlocksInOnePointOneChunkIsDoneProperly()
        {
            Island islandToRender = new Island(31);

            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(18, 2, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(19, 2, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(18, 2, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(19, 2, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(18, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(19, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(18, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(19, 1, 19));

            ChunkPresenter testCandidate = new ChunkPresenter();

            testCandidate.PresentChunk(islandToRender, 1, 1);

            VisualChunkData lastRenderedChunkData = ChunkRendererMock.GetLastRenderChunkCallData();

            Assert.That(lastRenderedChunkData, Is.Not.Null);
            Assert.That(lastRenderedChunkData.GetWorldX(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetWorldY(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetVertices().Length, Is.EqualTo(288));
            Assert.That(lastRenderedChunkData.GetIndices().Length, Is.EqualTo(144));
            Assert.That(lastRenderedChunkData.GetNormals().Length, Is.EqualTo(288));
            Assert.That(lastRenderedChunkData.GetUvCoordinates().Length, Is.EqualTo(192));
        }
Exemplo n.º 2
0
        private void CreateBlocksBasedOnHeightMap()
        {
            for (int i = 0; i < heightMap.GetLength(0); i++)
            {
                for (int j = 0; j < heightMap.GetLength(1); j++)
                {
                    int blockPillarHeight = heightMap[i, j];

                    for (int k = 0; k < blockPillarHeight; k++)
                    {
                        BlockPosition blockPosition = new BlockPosition(i, k, j);

                        if (k < blockPillarHeight - 2)
                        {
                            result.PlaceBlockAt(RockBlock.GetInstance(), blockPosition);
                        }
                        else if (k < blockPillarHeight - 1)
                        {
                            result.PlaceBlockAt(EarthBlock.GetInstance(), blockPosition);
                        }
                        else
                        {
                            result.PlaceBlockAt(GrassyEarthBlock.GetInstance(), blockPosition);
                        }
                    }
                }
            }
        }
        public IEnumerator BlockTypeIsGrassyEarth()
        {
            GrassyEarthBlock testCandidate = GrassyEarthBlock.GetInstance();

            yield return(null);

            Assert.That(testCandidate, Is.Not.Null);
            Assert.That(testCandidate.GetBlockType(), Is.EqualTo(BlockTypes.GRASSY_EARTH));
        }
        public static GrassyEarthBlock GetInstance()
        {
            if (null != instance)
            {
                return(instance);
            }

            instance = new GrassyEarthBlock();
            return(instance);
        }
Exemplo n.º 5
0
        public IEnumerator CannotPlaceBlockOutsideXDimension()
        {
            Island        testCandidate = new Island(64);
            Block         testBlock     = GrassyEarthBlock.GetInstance();
            BlockPosition blockPosition = new BlockPosition(64, 200, 24);

            yield return(null);

            Assert.Throws <BlockPositionOutOfBoundsException>(() => testCandidate.PlaceBlockAt(testBlock, blockPosition));
        }
        public IEnumerator AllBlockFacesAreCovering()
        {
            GrassyEarthBlock testCandidate = GrassyEarthBlock.GetInstance();

            yield return(null);

            Assert.IsTrue(testCandidate.GetFrontFaceIsCovering());
            Assert.IsTrue(testCandidate.GetRightFaceIsCovering());
            Assert.IsTrue(testCandidate.GetBackFaceIsCovering());
            Assert.IsTrue(testCandidate.GetLeftFaceIsCovering());
            Assert.IsTrue(testCandidate.GetBottomFaceIsCovering());
            Assert.IsTrue(testCandidate.GetTopFaceIsCovering());
        }
Exemplo n.º 7
0
        public IEnumerator RetrievesPreviouslyPlacedBlock()
        {
            Island        testCandidate = new Island(64);
            Block         testBlock     = GrassyEarthBlock.GetInstance();
            BlockPosition blockPosition = new BlockPosition(63, 0, 63);

            testCandidate.PlaceBlockAt(testBlock, blockPosition);

            Block blockAt = testCandidate.GetBlockAt(blockPosition);

            yield return(null);

            Assert.That(blockAt, Is.SameAs(testBlock));
        }
Exemplo n.º 8
0
        public IEnumerator TopFaceOfBlockIsVisibleWhenAtTopEdgeOfIsland()
        {
            Island        testCandidate = new Island(64);
            BlockPosition blockPosition = new BlockPosition(0, 255, 0);

            Block testBlock = GrassyEarthBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPosition);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.TOP, blockPosition);

            yield return(null);

            Assert.That(result, Is.EqualTo(false));
        }
        public void TestThatCoveredMiddleBlockIsNotRendered()
        {
            Island islandToRender = new Island(46);

            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 18));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 19));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(34, 3, 20));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(35, 3, 20));
            islandToRender.PlaceBlockAt(GrassyEarthBlock.GetInstance(), new BlockPosition(36, 3, 20));

            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 18));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 19));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(34, 2, 20));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(35, 2, 20));
            islandToRender.PlaceBlockAt(EarthBlock.GetInstance(), new BlockPosition(36, 2, 20));

            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 18));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 19));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(34, 1, 20));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(35, 1, 20));
            islandToRender.PlaceBlockAt(RockBlock.GetInstance(), new BlockPosition(36, 1, 20));

            ChunkPresenter testCandidate = new ChunkPresenter();

            testCandidate.PresentChunk(islandToRender, 2, 1);

            VisualChunkData lastRenderedChunkData = ChunkRendererMock.GetLastRenderChunkCallData();

            Assert.That(lastRenderedChunkData, Is.Not.Null);
            Assert.That(lastRenderedChunkData.GetWorldX(), Is.EqualTo(2));
            Assert.That(lastRenderedChunkData.GetWorldY(), Is.EqualTo(1));
            Assert.That(lastRenderedChunkData.GetVertices().Length, Is.EqualTo(648));
            Assert.That(lastRenderedChunkData.GetIndices().Length, Is.EqualTo(324));
            Assert.That(lastRenderedChunkData.GetNormals().Length, Is.EqualTo(648));
            Assert.That(lastRenderedChunkData.GetUvCoordinates().Length, Is.EqualTo(432));
        }
Exemplo n.º 10
0
        public IEnumerator TopFaceOfBlockIsVisibleWhenNotCovered()
        {
            Island        testCandidate    = new Island(64);
            BlockPosition blockPositionOne = new BlockPosition(0, 4, 0);
            BlockPosition blockPositionTwo = new BlockPosition(0, 5, 0);

            Block testBlock = GrassyEarthBlock.GetInstance();
            Block neighbor  = AirBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPositionOne);
            testCandidate.PlaceBlockAt(neighbor, blockPositionTwo);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.TOP, blockPositionOne);

            yield return(null);

            Assert.That(result, Is.EqualTo(false));
        }
Exemplo n.º 11
0
        public IEnumerator RightFaceOfBlockIsHiddenWhenCovered()
        {
            Island        testCandidate    = new Island(64);
            BlockPosition blockPositionOne = new BlockPosition(46, 0, 0);
            BlockPosition blockPositionTwo = new BlockPosition(45, 0, 0);

            Block testBlock = GrassyEarthBlock.GetInstance();
            Block neighbor  = RockBlock.GetInstance();

            testCandidate.PlaceBlockAt(testBlock, blockPositionOne);
            testCandidate.PlaceBlockAt(neighbor, blockPositionTwo);

            bool result = testCandidate.BlockFaceAtPositionIsHidden(BlockFaceDirections.RIGHT, blockPositionOne);

            yield return(null);

            Assert.That(result, Is.EqualTo(true));
        }