public static string GetNumber(int order, NumeralStyle style) { if (style == NumeralStyle.Arabic) { return(order.ToString()); } else if (style == NumeralStyle.RomanUpper) { return(ToRomanNumber(order).ToUpper()); } else if (style == NumeralStyle.RomanLower) { return(ToRomanNumber(order).ToLower()); } else if (style == NumeralStyle.AlphabeticUpper) { return(((char)((int)'A' + order - 1)).ToString()); } else if (style == NumeralStyle.AlphabeticLower) { return(((char)((int)'a' + order - 1)).ToString()); } else { return(string.Empty); } }
private void setNumeralStyle() { switch (_numeralStyle = (NumeralStyle)Rnd.Range(0, 3)) { case NumeralStyle.None: Destroy(Numerals.gameObject); break; case NumeralStyle.Roman: Numerals.mesh = RomanNumerals[Rnd.Range(0, RomanNumerals.Length)]; break; case NumeralStyle.Arabic: Numerals.mesh = ArabicNumerals[Rnd.Range(0, ArabicNumerals.Length)]; break; } Debug.LogFormat("[The Clock #{0}] Numeral style: {1}", _moduleId, _numeralStyle); }
public static string GetNewName(IEnumerable <string> names, string defaultName, NumeralStyle style) { if (style == NumeralStyle.Guess) { string name1 = string.Empty; string name2 = string.Empty; foreach (string name in names) { name1 = name2; name2 = name; } int n1 = ExtractTrailingNumber(name1); int n2 = ExtractTrailingNumber(name2); if (n1 >= 0 && n2 >= 0 && n2 == n1 + 1) { string str1 = ExtractStrWithoutTrailingNumber(name1); string str2 = ExtractStrWithoutTrailingNumber(name2); if (str1 == str2) { int n3 = n2 + 1; string ret = str1 + n3.ToString(); return(ret); } } if (n2 >= 0) { int n3 = n2 + 1; string str = ExtractStrWithoutTrailingNumber(name2); string ret = str + n3.ToString(); return(ret); } return(defaultName); } else { int order = names.Count() + 1; string newName = GetNumber(order, style); while (names.Contains(newName)) { order++; newName = GetNumber(order, style); } return(newName); } }