示例#1
0
        // y *must* be positive down as the xy /iso conversion assumes this
        static void hex_xy(ref hex h)
        {
            if (!h.iso)
            {
                return;
            }
            if (h.x >= 0)
            {
                h.y = -h.y - (h.x + 1) / 2;
            }
            else
            {
                h.y = -h.y - h.x / 2;        // need to round toward -inf, not toward zero, so x-1
            }
            h.iso = false;

            return;
        }
示例#2
0
        static void hex_iso(ref hex h)
        {
            if (h.iso)
            {
                return;
            }

            if (h.x >= 0)
            {
                h.y = (-h.y - (h.x + 1) / 2);
            }
            else
            {
                h.y = (-h.y - (h.x) / 2);        // need to round toward -inf, not toward zero, so x-1
            }
            h.z   = -h.x - h.y;
            h.iso = true;

            return;
        }
示例#3
0
 (byte.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var val), val);
 /// <summary>
 ///
 /// </summary>
 /// <param name="hex"></param>
 /// <returns>Return Tuple (bool, byte) that bool represent if is a byte</returns>
 public static (bool success, byte val) HexToUniqueByte(string hex) => (byte.TryParse(hex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out byte val), val);
示例#5
0
        // y *must* be positive down as the xy /iso conversion assumes this
        static void hex_xy(ref hex h)
        {
            if(!h.iso) return;
            if(h.x>=0) h.y=-h.y-(h.x+1)/2;
            else h.y=-h.y-h.x/2; // need to round toward -inf, not toward zero, so x-1

            h.iso=false;

            return;
        }
示例#6
0
        static void hex_iso(ref hex h)
        {
            if(h.iso) return;

            if(h.x>=0) h.y=(-h.y-(h.x+1)/2);
            else h.y=(-h.y-(h.x)/2); // need to round toward -inf, not toward zero, so x-1

            h.z=-h.x-h.y;
            h.iso=true;

            return;
        }