// 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; }
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; }
(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);
// 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; }
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; }