Esempio n. 1
0
        private static void test_layout()
        {
            var h    = new Hex(3, 4, -7);
            var flat = new Layout(HexagonFunction.LayoutFlat, new Point(10, 15), new Point(250, 259));

            EqualHex("LayoutFlat", h, HexagonFunction.HexagonRound(HexagonFunction.PixelToHexagon(flat, HexagonFunction.HexagonToPixel(flat, h))));

            var pointy = new Layout(HexagonFunction.LayoutPointy, new Point(10, 15), new Point(35, 71));

            EqualHex("LayoutPointy", h, HexagonFunction.HexagonRound(HexagonFunction.PixelToHexagon(pointy, HexagonFunction.HexagonToPixel(pointy, h))));
        }
Esempio n. 2
0
        private static void test_hex_round()
        {
            var a = new Hex(0.0m, 0.0m, 0.0m);
            var b = new Hex(1.0m, -1.0m, 0.0m);
            var c = new Hex(0.0m, -1.0m, 1.0m);

            EqualHex("hex_round 1", new Hex(5, -10, 5), HexagonFunction.HexagonRound(HexagonFunction.HexagonLerp(new Hex(0.0m, 0.0m, 0.0m), new Hex(10.0m, -20.0m, 10.0m), 0.5m)));
            EqualHex("hex_round 2", HexagonFunction.HexagonRound(a), HexagonFunction.HexagonRound(HexagonFunction.HexagonLerp(a, b, 0.499m)));
            EqualHex("hex_round 3", HexagonFunction.HexagonRound(b), HexagonFunction.HexagonRound(HexagonFunction.HexagonLerp(a, b, 0.501m)));
            EqualHex("hex_round 4", HexagonFunction.HexagonRound(a), HexagonFunction.HexagonRound(new Hex(a.Q * 0.4m + b.Q * 0.3m + c.Q * 0.3m, a.R * 0.4m + b.R * 0.3m + c.R * 0.3m, a.S * 0.4m + b.S * 0.3m + c.S * 0.3m)));
            EqualHex("hex_round 5", HexagonFunction.HexagonRound(c), HexagonFunction.HexagonRound(new Hex(a.Q * 0.3m + b.Q * 0.3m + c.Q * 0.4m, a.R * 0.3m + b.R * 0.3m + c.R * 0.4m, a.S * 0.3m + b.S * 0.3m + c.S * 0.4m)));
        }