Example #1
0
        public void ShouldJumpUpTransform()
        {
            HexCoordinate[] coords;


            coords = new HexCoordinate(0, 0).JumpUpTransform().ToArray();
            Assert.AreEqual(6, coords.Length);
            Assert.IsTrue(coords.Contains(new HexCoordinate(1, 0)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(1, 1)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(1, 2)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(1, 3)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(1, 4)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(1, 5)));

            coords = new HexCoordinate(2, 9).JumpUpTransform().ToArray();
            Assert.AreEqual(2, coords.Length);
            Assert.IsTrue(coords.Contains(new HexCoordinate(3, 13)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(3, 14)));

            coords = new HexCoordinate(3, 12).JumpUpTransform().ToArray();
            Assert.AreEqual(3, coords.Length);
            Assert.IsTrue(coords.Contains(new HexCoordinate(4, 15)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(4, 16)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(4, 17)));
        }
Example #2
0
        public void ShouldJumpDownTransform()
        {
            HexCoordinate[] coords;


            coords = new HexCoordinate(0, 0).JumpDownTransform().ToArray();
            Assert.AreEqual(0, coords.Length);

            coords = new HexCoordinate(1, 4).JumpDownTransform().ToArray();
            Assert.AreEqual(1, coords.Length);
            Assert.IsTrue(coords.Contains(new HexCoordinate(0, 0)));

            coords = new HexCoordinate(2, 9).JumpDownTransform().ToArray();
            Assert.AreEqual(2, coords.Length);
            Assert.IsTrue(coords.Contains(new HexCoordinate(1, 4)));
            Assert.IsTrue(coords.Contains(new HexCoordinate(1, 5)));

            coords = new HexCoordinate(3, 12).JumpDownTransform().ToArray();
            Assert.AreEqual(1, coords.Length);
            Assert.IsTrue(coords.Contains(new HexCoordinate(2, 8)));
        }
Example #3
0
        public void ShouldReturnNeighbours()
        {
            HexCoordinate[] ng;

            // Radius = 0
            ng = new HexCoordinate(0, 0).GetNeighbours().ToArray();
            Assert.AreEqual(6, ng.Length);
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 0)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 1)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 2)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 3)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 4)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 5)));

            // Axis Aligned cell
            ng = new HexCoordinate(2, 8).GetNeighbours().ToArray();
            Assert.AreEqual(6, ng.Length);
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(2, 7)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(2, 9)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 4)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(3, 12)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(3, 11)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(3, 13)));            //*/


            // Not aligned cell
            ng = new HexCoordinate(2, 9).GetNeighbours().ToArray();
            Assert.AreEqual(6, ng.Length);
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(2, 8)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(2, 10)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 4)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(1, 5)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(3, 13)));
            Assert.AreEqual(true, ng.Contains(new HexCoordinate(3, 14)));            //*/
        }