Esempio n. 1
0
        public void PathedMapLayer_ClearedTile()
        {
            // Arrange
            var layer = new PathedMapLayer <bool>();
            var hex   = new Hex(4, 2);

            // Act
            layer[hex] = null;

            // Assert
            Assert.IsTrue(!layer.PathingSnapshot.ContainsKey(hex));
        }
Esempio n. 2
0
        public void PathedMapLayer_PathingSnapshot()
        {
            // Arrange
            var layer = new PathedMapLayer <bool>();
            var hex   = new Hex(4, 2);

            // Act
            layer[hex] = new PathedTile <bool>(true, 5, true);

            // Assert
            Assert.AreEqual(5, layer.PathingSnapshot[hex]);
        }
Esempio n. 3
0
        public void PositionToHex()
        {
            // Arrange
            var mapLayer = new PathedMapLayer <int>();

            var map = new LayeredMap(LayoutOrientation.Flat, new Vector2(10, 10), new Vector2(100, 100), mapLayer);

            // Act
            Hex coords = map.PositionToHex(new Vector2(115, 215));

            // Assert
            Assert.Multiple(() =>
            {
                Assert.AreEqual(1, coords.Q);
                Assert.AreEqual(6, coords.R);
            });
        }
Esempio n. 4
0
        public void HexToPosition()
        {
            // Arrange
            var mapLayer = new PathedMapLayer <int>();

            var map = new LayeredMap(LayoutOrientation.Pointy, new Vector2(32, 32), new Vector2(100, 100), mapLayer);

            // Act
            Vector2 position = map.HexToPosition(new Hex(3, 2));

            // Assert
            Assert.Multiple(() =>
            {
                Assert.AreEqual(321.702515f, position.X);
                Assert.AreEqual(196.0f, position.Y);
            });
        }
Esempio n. 5
0
        public void AddMapLayer()
        {
            // Arrange
            var mapLayer  = new PathedMapLayer <int>();
            var mapLayer2 = new MapLayer <bool>();

            var map = new LayeredMap(LayoutOrientation.Flat, new Vector2(1, 1), new Vector2(0, 0), mapLayer);

            // Act
            map.AddLayer(mapLayer2);

            // Assert
            Assert.Multiple(() =>
            {
                Assert.IsTrue(map[0] is PathedMapLayer <int>);
                Assert.IsTrue(map[1] is MapLayer <bool>);
            });
        }
Esempio n. 6
0
        public void Navigate_UnpathableHexProvided_HexUnpathableInCalculation()
        {
            // Arrange
            var pathedMapLayer = new PathedMapLayer <bool>();

            pathedMapLayer[new Hex(0, 0)] = new PathedTile <bool>(true, 3, true);
            pathedMapLayer[new Hex(0, 1)] = new PathedTile <bool>(true, 3, true);

            var map = BuildTerrainMap(pathedMapLayer);

            // Act
            var pathingInfo = map.Navigate(new Hex(0, 0), new Hex(0, 1), new List <Hex>()
            {
                new Hex(0, 1)
            });

            // Assert
            Assert.IsNull(pathingInfo);
        }
Esempio n. 7
0
        public void CalculatedTileWeights_PathedAndUnpathedLayer_UnpathedLayerEmpty()
        {
            // Arrange
            var testHex        = new Hex(2, 3);
            var pathedMapLayer = new PathedMapLayer <bool>();

            pathedMapLayer[testHex] = new PathedTile <bool>(true, 3, true);

            var unpathedMapLayer = new MapLayer <bool>();

            var map = new LayeredMap(LayoutOrientation.Flat, new Vector2(10, 10), new Vector2(100, 100), pathedMapLayer);

            map.AddLayer(unpathedMapLayer);

            // Act
            var pathingInfo = map.CalculatedTileWeights();

            // Assert
            Assert.AreEqual(3, pathingInfo[testHex]);
        }
Esempio n. 8
0
        public void CalculatedTileWeights_PathedAndUnpathedLayer_UnpathedLayerOccupied_ClearsPathing()
        {
            // Arrange
            var testHex        = new Hex(2, 3);
            var pathedMapLayer = new PathedMapLayer <bool>();

            pathedMapLayer[testHex] = new PathedTile <bool>(true, 3, true);

            var unpathedMapLayer = new MapLayer <bool>();

            unpathedMapLayer[testHex] = true;

            var map = new LayeredMap(LayoutOrientation.Flat, new Vector2(10, 10), new Vector2(100, 100), pathedMapLayer);

            map.AddLayer(unpathedMapLayer);

            // Act
            var pathingInfo = map.CalculatedTileWeights();

            // Assert
            Assert.IsTrue(!pathingInfo.ContainsKey(testHex));
        }