public static hexNumFloat HexNumToFloat(hexNum point) { return(new hexNumFloat { num_x_float = point.num_x, num_z_float = point.num_z }); }
public static hexNum Lerp(hexNum start, hexNum end, float ratio) { Debug.Assert(ratio >= 0 && ratio <= 1, "ratio out of [0, 1] in Lerp"); hexNum tmp; tmp.num_x = Mathf.RoundToInt(ratio * start.num_x + (1 - ratio) * end.num_x); tmp.num_z = Mathf.RoundToInt(ratio * start.num_z + (1 - ratio) * end.num_z); return(tmp); }
public static areaStartEnd CreateAreaStartEnd(hexNum hexN, hexNum hexN_new, bool same = true) { areaStartEnd center; center.start = hexN; center.end = hexN_new; center.same = same; return(center); }
public static void AddHexagonCenter(hexNum hexN, hexNum hexN_new, bool same = true) { if (longArea) { Utils.Add(ref hexCenter[0], CreateAreaStartEnd(hexN, hexN_new, same)); } else { if (hexN.num_x >= 0 && hexN.num_x < areaHeight / 3) { if (hexN.num_z >= 0 && hexN.num_z < areaWidth / 3) { Utils.Add(ref hexCenter[0], CreateAreaStartEnd(hexN, hexN_new, same)); } else if (hexN.num_z >= areaWidth / 3 && hexN.num_z < areaWidth * 2 / 3) { Utils.Add(ref hexCenter[1], CreateAreaStartEnd(hexN, hexN_new, same)); } else //hexN.num_z>=areaWidth*2/3 && hexN.num_z<areaWidth { Utils.Add(ref hexCenter[2], CreateAreaStartEnd(hexN, hexN_new, same)); } } else if (hexN.num_x >= areaHeight / 3 && hexN.num_x < areaHeight * 2 / 3) { if (hexN.num_z >= 0 && hexN.num_z < areaWidth / 3) { Utils.Add(ref hexCenter[5], CreateAreaStartEnd(hexN, hexN_new, same)); } else if (hexN.num_z >= areaWidth / 3 && hexN.num_z < areaWidth * 2 / 3) { Utils.Add(ref hexCenter[4], CreateAreaStartEnd(hexN, hexN_new, same)); } else //hexN.num_z>=areaWidth*2/3 && hexN.num_z<areaWidth { Utils.Add(ref hexCenter[3], CreateAreaStartEnd(hexN, hexN_new, same)); } } else //hexN.num_x>=areaHeight*2/3 && hexN.num_x<areaHeight { if (hexN.num_z >= 0 && hexN.num_z < areaWidth / 3) { Utils.Add(ref hexCenter[6], CreateAreaStartEnd(hexN, hexN_new, same)); } else if (hexN.num_z >= 33 && hexN.num_z < areaWidth * 2 / 3) { Utils.Add(ref hexCenter[7], CreateAreaStartEnd(hexN, hexN_new, same)); } else //hexN.num_z>=areaWidth*2/3 && hexN.num_z<areaWidth { Utils.Add(ref hexCenter[8], CreateAreaStartEnd(hexN, hexN_new, same)); } } } }
public static hexNum HalfLerp(hexNum start, hexNum end) { return(Lerp(start, end, 0.5f)); }