Esempio n. 1
0
        public void ReduceMapToReachableTilesStartInMiddle()
        {
            byte[] input = new byte[] {
                0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
                0x55, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x55, 0x00, 0x55, 0x00, 0x55, 0x55,
                0x55, 0x00, 0x55, 0x00, 0x55, 0x55,
                0x55, 0x00, 0x55, 0x55, 0x00, 0x55,
                0x55, 0x00, 0x55, 0x00, 0x55, 0x55,
                0x55, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
            };
            int bytesPerRow = 6;

            (int x, int y)startPosition = (7, 4);

            var result = ExtractMap.ReduceMapToReachableTiles(input, bytesPerRow, startPosition);

            byte[] expectedResult = new byte[] {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x55, 0x00, 0x55, 0x55,
                0x00, 0x00, 0x55, 0x00, 0x55, 0x55,
                0x00, 0x00, 0x55, 0x55, 0x00, 0x55,
                0x00, 0x00, 0x55, 0x00, 0x55, 0x55,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            };
            CollectionAssert.AreEqual(expectedResult, result);
        }
Esempio n. 2
0
        public void IsWalkableHalfByteLast()
        {
            byte[] fullMap = new byte[] {
                0x05,
            };
            int bytesPerRow = 1;

            Assert.AreEqual(false, ExtractMap.IsWalkable(fullMap, bytesPerRow, 0, 0));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 1, 0));
        }
Esempio n. 3
0
        public void IsWalkableFalse()
        {
            byte[] fullMap = new byte[] {
                0x00,
            };
            int bytesPerRow = 1;

            Assert.AreEqual(false, ExtractMap.IsWalkable(fullMap, bytesPerRow, 0, 0));
            Assert.AreEqual(false, ExtractMap.IsWalkable(fullMap, bytesPerRow, 1, 0));
        }
Esempio n. 4
0
        public void IsWalkableTrue()
        {
            byte[] fullMap = new byte[] {
                0x55,
            };
            int bytesPerRow = 1;

            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 0, 0));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 1, 0));
        }
Esempio n. 5
0
        public override Stream OpenEntry(ArcFile arc, Entry entry)
        {
            var       swent = (SwfEntry)entry;
            Extractor extract;

            if (!ExtractMap.TryGetValue(swent.Chunk.Type, out extract))
            {
                extract = ExtractChunk;
            }
            return(extract(swent));
        }
Esempio n. 6
0
        public void ChangeHalfByteToZeroUnchanged()
        {
            byte byteToChange = 0x00;
            bool firstHalf    = true;

            var result = ExtractMap.ChangeHalfByteToZero(byteToChange, firstHalf);

            byte expectedResult = 0x00;

            Assert.AreEqual(expectedResult, result);
        }
Esempio n. 7
0
        public void ChangeHalfByteToZeroSecondHalf()
        {
            byte byteToChange = 0x55;
            bool firstHalf    = false;

            var result = ExtractMap.ChangeHalfByteToZero(byteToChange, firstHalf);

            byte expectedResult = 0x50;

            Assert.AreEqual(expectedResult, result);
        }
Esempio n. 8
0
        public void ReduceMapToReachableTilesDifferentStartHalfByteConnected()
        {
            byte[] input = new byte[] {
                0x55, 0x55,
                0x50, 0x00,
                0x55, 0x55
            };
            int bytesPerRow = 2;

            (int x, int y)startPosition = (3, 2);

            var result = ExtractMap.ReduceMapToReachableTiles(input, bytesPerRow, startPosition);

            byte[] expectedResult = new byte[] {
                0x55, 0x55,
                0x50, 0x00,
                0x55, 0x55
            };
            CollectionAssert.AreEqual(expectedResult, result);
        }
Esempio n. 9
0
        public void IsWalkableBigger()
        {
            byte[] fullMap = new byte[] {
                0x15, 0x11, 0x15,
                0x51, 0x55, 0x55,
            };
            int bytesPerRow = 3;

            Assert.AreEqual(false, ExtractMap.IsWalkable(fullMap, bytesPerRow, 0, 0));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 1, 0));
            Assert.AreEqual(false, ExtractMap.IsWalkable(fullMap, bytesPerRow, 2, 0));
            Assert.AreEqual(false, ExtractMap.IsWalkable(fullMap, bytesPerRow, 3, 0));
            Assert.AreEqual(false, ExtractMap.IsWalkable(fullMap, bytesPerRow, 4, 0));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 5, 0));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 0, 1));
            Assert.AreEqual(false, ExtractMap.IsWalkable(fullMap, bytesPerRow, 1, 1));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 2, 1));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 3, 1));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 4, 1));
            Assert.AreEqual(true, ExtractMap.IsWalkable(fullMap, bytesPerRow, 5, 1));
        }