예제 #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);
예제 #4
0
 /// <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;
        }