Exemple #1
0
        /// <summary>
        /// 平六边形排列按指定偏移cube转pixel
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="offsetCoord"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static Vector2 GetQPixelFromOffsetCoord(int offset, OffsetCoord offsetCoord, float size)
        {
            float px = size * 1.5f * offsetCoord.x;
            float py = size * SQRT_3 * (offsetCoord.y - offset * (offsetCoord.x & 1) / 2f);

            return(new Vector2(px, py));
        }
Exemple #2
0
        /// <summary>
        /// 平六边形排列按指定偏移offset转cube
        /// </summary>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <param name=""></param>
        /// <returns></returns>
        public static Hex GetCubeFromQOffsetCoord(int offset, OffsetCoord offsetCoord)
        {
            int x = offsetCoord.x;
            int z = offsetCoord.y - (offsetCoord.x + offset * (offsetCoord.x & 1)) / 2;
            int y = -x - z;

            return(new Hex(x, y, z));
        }
Exemple #3
0
        /// <summary>
        /// 平六边形排列按指定偏移Pixel转cube
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="point"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static Hex GetCubeFromQPixel(int offset, Vector2 point, float size)
        {
            OffsetCoord offsetCoord = GetQOffsetCoordFromPixel(offset, point, size);

            return(GetCubeFromQOffsetCoord(offset, offsetCoord));
        }
Exemple #4
0
        /// <summary>
        /// 平六边形排列按指定偏移cube转pixel
        /// </summary>
        /// <param name="offset"></param>
        /// <param name="hex"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static Vector2 GetQPixelFromCube(int offset, Hex hex, float size)
        {
            OffsetCoord offsetCoord = GetQOffsetCoordFromCube(offset, hex);

            return(GetQPixelFromOffsetCoord(offset, offsetCoord, size));
        }