예제 #1
0
        private void AddPaths()
        {
            var testPath = new PathModel();
            {
                testPath.PathName = nameof(testPath);

                var hex = Tiles.GetHex(HexCoords.CreateFromAxial(0, 0));
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.NorthEast);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.NorthEast);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.North);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.North);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.NorthEast);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.SouthEast);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.SouthEast);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.NorthEast);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.North);
                testPath.PathSteps.Add(new PathStepModel(hex));

                hex = Tiles.GetNeighbour(hex.Coords, HexDirection.SouthEast);
                testPath.PathSteps.Add(new PathStepModel(hex));

                Paths.Add(testPath);
            }
        }
예제 #2
0
        public void TestAxialOffset()
        {
            // origin case
            var hc1 = HexCoords.CreateFromAxial(0, 0);

            Assert.AreEqual(0, hc1.Column);
            Assert.AreEqual(0, hc1.Row);

            // +ve cases
            var hc2 = HexCoords.CreateFromAxial(1, 1);

            Assert.AreEqual(1, hc2.Column);
            Assert.AreEqual(2, hc2.Row);

            var hc3 = HexCoords.CreateFromAxial(2, 1);

            Assert.AreEqual(2, hc3.Column);
            Assert.AreEqual(2, hc3.Row);

            var hc4 = HexCoords.CreateFromAxial(1, 2);

            Assert.AreEqual(1, hc4.Column);
            Assert.AreEqual(3, hc4.Row);

            // +ve, -ve cases
            var hc5 = HexCoords.CreateFromAxial(-1, 2);

            Assert.AreEqual(-1, hc5.Column);
            Assert.AreEqual(2, hc5.Row);

            var hc6 = HexCoords.CreateFromAxial(3, -1);

            Assert.AreEqual(3, hc6.Column);
            Assert.AreEqual(1, hc6.Row);

            // -ve cases
            var hc7 = HexCoords.CreateFromAxial(-1, -2);

            Assert.AreEqual(-1, hc7.Column);
            Assert.AreEqual(-2, hc7.Row);
        }