コード例 #1
0
        public void TestBlockNullVector()
        {
            GameMapBlock<long> testBlock = new GameMapBlock<long>(new Vector2(0, 0));
            Vector2 expectedDimensions = new Vector2(1, 1);

            Assert.AreEqual(expectedDimensions, testBlock.Dimensions);
        }
コード例 #2
0
        public void TestBlockBase()
        {
            GameMapBlock<long> testBlock = new GameMapBlock<long>(new Vector2(2, 2));
            Vector2 expectedDimensions = new Vector2(2, 2);

            Assert.AreEqual(expectedDimensions, testBlock.Dimensions);
            CollectionAssert.AreEqual(new List<long>(), (List<long>)testBlock.Contents);
        }
コード例 #3
0
        public void TestCropNullRectangle()
        {
            GameMapBlock<long> testBlock = new GameMapBlock<long>(new Vector2(0, 0));
            testBlock.AddContentElement(-1);
            long[] expectedResult = new long[] { -1 };

            long[] testCrop = (testBlock.Crop(new Rectangle(0, 0, 0, 0)) as List<long>).ToArray();

            CollectionAssert.AreEqual(expectedResult, testCrop);
        }
コード例 #4
0
        public void TestCropBase()
        {
            GameMapBlock<long> testBlock = new GameMapBlock<long>(new Vector2(2,2));
            for (int i = 0; i < 4; i++)
                testBlock.AddContentElement(-1);

            object croppedResults = testBlock.Crop(new Rectangle(0,0,2,2));

            CollectionAssert.AreEqual((ICollection)testBlock.Contents, (croppedResults as List<long>));
        }
コード例 #5
0
        public void TestCropNegativeRectangle()
        {
            GameMapBlock<long> testBlock = new GameMapBlock<long>(new Vector2(2, 2));
            for (int i = 0; i < testBlock.Dimensions.X * testBlock.Dimensions.Y; i++)
                testBlock.AddContentElement(-1);

            List<long> croppedContents = (List<long>)testBlock.Crop(new Rectangle(0, 0, -2, -2));

            long[] expectedResult = new long[] { -1, -1, -1, -1 };

            CollectionAssert.AreEqual(expectedResult, croppedContents.ToArray());
        }
コード例 #6
0
        /*
         * The factory constructs a quadratic GameMap, using the methods specified below.
         * Map dimensions are a consequence of treeDepth as follows:
         * *    Depth -- MapWidth
         * *    0     -- 24 * width
         * *    1     -- 72 * width
         * *    2     -- 216 * width
         * *    3     -- 648 * width
         * *    etc.
         */
        public GameMapBlock<IGameMapBlock> ConstructGameBlock(int blockWidth, int blockHeight, int currentDepth, int treeDepth)
        {
            GameMapBlock<IGameMapBlock> currentBlock = new GameMapBlock<IGameMapBlock>(new Microsoft.Xna.Framework.Vector2(blockWidth, blockHeight));

            for (int i = 0; i < blockWidth * blockHeight; i++)
            {
                if (currentDepth == treeDepth)
                { currentBlock.AddContentElement(new GameMapSegment()); }
                else
                { currentBlock.AddContentElement(ConstructGameBlock(blockWidth, blockHeight, currentDepth + 1, treeDepth)); }
            }

            return currentBlock;
        }
コード例 #7
0
 public void TestBlockNegativeVector()
 {
     GameMapBlock<long> testBlock = new GameMapBlock<long>(new Vector2(-2, -2));
     Assert.AreEqual(new Vector2(2, 2), testBlock.Dimensions);
 }