| | |
| | | using System.Text.RegularExpressions; |
| | | using System.IO; |
| | | using LitJson; |
| | | using Cysharp.Threading.Tasks; |
| | | |
| | | /// <summary> |
| | | /// UI辅助类 |
| | |
| | | if (part != 0) |
| | | { |
| | | if (needZero) |
| | | result = StringUtility.Contact(numbers[0] + result); |
| | | result = StringUtility.Concat(numbers[0] + result); |
| | | |
| | | result = numbers[part] + (unitPlace == 1 ? "" : units[unitPlace - 2]) + result; // 单位只在十、百、千、万内部使用 |
| | | needZero = false; |
| | |
| | | { |
| | | // 暂不考虑富文本的情况 |
| | | // 不需要物品的情况补充 |
| | | // string iconKey = StringUtility.Contact("Money_Type_", moneyType); |
| | | // string iconKey = StringUtility.Concat("Money_Type_", moneyType); |
| | | Debug.LogError("MoneyDisplayModel 未配置货币类型:" + moneyType); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (attrName.Length == 2) |
| | | { |
| | | suitStr = StringUtility.Contact(suitStr, attrName[i], " "); |
| | | suitStr = StringUtility.Concat(suitStr, attrName[i].ToString(), " "); |
| | | } |
| | | else if (attrName.Length == 3) |
| | | { |
| | | suitStr = StringUtility.Contact(suitStr, attrName[i], " "); |
| | | suitStr = StringUtility.Concat(suitStr, attrName[i].ToString(), " "); |
| | | } |
| | | else |
| | | { |
| | | suitStr = StringUtility.Contact(suitStr, attrName[i]); |
| | | suitStr = StringUtility.Concat(suitStr, attrName[i].ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | suitStr = StringUtility.Contact(suitStr, attrName[i]); |
| | | suitStr = StringUtility.Concat(suitStr, attrName[i].ToString()); |
| | | } |
| | | } |
| | | return suitStr; |
| | |
| | | |
| | | if (num >= T) |
| | | { |
| | | return StringUtility.Contact(FormatWithoutRounding(num / T, 2), Language.Get("L1070_0")); |
| | | return StringUtility.Concat(FormatWithoutRounding(num / T, 2), Language.Get("L1070_0")); |
| | | } |
| | | else if (num >= B) |
| | | { |
| | | return StringUtility.Contact(FormatWithoutRounding(num / B, 2), Language.Get("L1070_1")); |
| | | return StringUtility.Concat(FormatWithoutRounding(num / B, 2), Language.Get("L1070_1")); |
| | | } |
| | | else if (num >= M) |
| | | { |
| | | return StringUtility.Contact(FormatWithoutRounding(num / M, decimalPlaces), Language.Get("L1070")); |
| | | return StringUtility.Concat(FormatWithoutRounding(num / M, decimalPlaces), Language.Get("L1070")); |
| | | } |
| | | else if (num >= K) |
| | | { |
| | | return StringUtility.Contact(FormatWithoutRounding(num / K, decimalPlaces), Language.Get("L1071")); |
| | | return StringUtility.Concat(FormatWithoutRounding(num / K, decimalPlaces), Language.Get("L1071")); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | if (num >= T) |
| | | { |
| | | return StringUtility.Contact(FormatWithoutRounding(num / T, 2), "t"); |
| | | return StringUtility.Concat(FormatWithoutRounding(num / T, 2), "t"); |
| | | } |
| | | else if (num >= B) |
| | | { |
| | | return StringUtility.Contact(FormatWithoutRounding(num / B, 2), "b"); |
| | | return StringUtility.Concat(FormatWithoutRounding(num / B, 2), "b"); |
| | | } |
| | | else if (num >= M) |
| | | { |
| | | return StringUtility.Contact(FormatWithoutRounding(num / M, 1), "m"); |
| | | return StringUtility.Concat(FormatWithoutRounding(num / M, 1), "m"); |
| | | } |
| | | else if (num >= K) |
| | | { |
| | | return StringUtility.Contact(FormatWithoutRounding(num / K, 1), "k"); |
| | | return StringUtility.Concat(FormatWithoutRounding(num / K, 1), "k"); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 取名验证 |
| | | static Regex s_SpecialCharacterRegex = new Regex("[()()@!#$%^&*[]|_]"); |
| | | static Regex s_AsciiCharacterRegex = new Regex("[\x00-\x1F]|[\x21-\x2F]|[\x3A-\x40]|[\x5B-\x60]|[\x7B-\x7E]"); |
| | | public static bool HasSpecialCharac(string str) |
| | |
| | | return true; |
| | | } |
| | | if (s_AsciiCharacterRegex.IsMatch(str)) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | //聊天 |
| | | static Regex s_AsciiCharacterRegexChat = new Regex("[\x00-\x1F]"); |
| | | public static bool HasSpecCheckChat(string str) |
| | | { |
| | | if (s_AsciiCharacterRegexChat.IsMatch(str)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | // switch (crossDanLVConfig.DanType) |
| | | // { |
| | | // case 0: |
| | | // return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", name, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "666666" : "dddddd", ">", name, "</color>"); |
| | | // case 1: |
| | | // return StringUtility.Contact("<color=#", bright ? "9460ff" : "7999ff", ">", name, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "9460ff" : "7999ff", ">", name, "</color>"); |
| | | // case 2: |
| | | // return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", name, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "0066ff" : "00c6ff", ">", name, "</color>"); |
| | | // case 3: |
| | | // return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", name, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "00b337" : "66ff00", ">", name, "</color>"); |
| | | // case 4: |
| | | // return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", name, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "ff6600" : "ff9000", ">", name, "</color>"); |
| | | // case 5: |
| | | // return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", name, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "ff0000" : "ff0000", ">", name, "</color>"); |
| | | // case 6: |
| | | // return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", name, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "ff00f6" : "f000ff", ">", name, "</color>"); |
| | | // } |
| | | // return name; |
| | | // } |
| | |
| | | { |
| | | case TextColType.None: |
| | | case TextColType.White: |
| | | return StringUtility.Contact("<color=#", bright ? "ffffff" : "ffffff", ">", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#", bright ? "ffffff" : "ffffff", ">", msg, "</color>"); |
| | | case TextColType.titleSelectColor: |
| | | return StringUtility.Contact("<color=#7F4139>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#7F4139>", msg, "</color>"); |
| | | case TextColType.titleUnSelectColor: |
| | | return StringUtility.Contact("<color=#6E5C60>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#6E5C60>", msg, "</color>"); |
| | | case TextColType.Red: |
| | | return StringUtility.Contact("<color=#", bright ? "ea261e" : "ea261e", ">", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#", bright ? "ea261e" : "ea261e", ">", msg, "</color>"); |
| | | case TextColType.Pink: |
| | | return StringUtility.Contact("<color=#", bright ? "f6408d" : "ff7c7c", ">", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#", bright ? "f6408d" : "ff7c7c", ">", msg, "</color>"); |
| | | case TextColType.Green: |
| | | return StringUtility.Contact("<color=#", bright ? "248B12" : "2ae337", ">", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#", bright ? "248B12" : "2ae337", ">", msg, "</color>"); |
| | | case TextColType.NavyBrown: |
| | | return StringUtility.Contact("<color=#6e4c31>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#6e4c31>", msg, "</color>"); |
| | | case TextColType.DarkGreen: |
| | | return StringUtility.Contact("<color=#248B12>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#248B12>", msg, "</color>"); |
| | | case TextColType.Black: |
| | | return StringUtility.Contact("<color=#000000>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#000000>", msg, "</color>"); |
| | | case TextColType.LightWhite: |
| | | return StringUtility.Contact("<color=f5f646>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=f5f646>", msg, "</color>"); |
| | | case TextColType.LightGreen: |
| | | return StringUtility.Contact("<color=#8ddc11>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#8ddc11>", msg, "</color>"); |
| | | case TextColType.Gray: |
| | | return StringUtility.Contact("<color=#bbbbbb>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#bbbbbb>", msg, "</color>"); |
| | | case TextColType.NavyGray: |
| | | return StringUtility.Contact("<color=#797979>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#797979>", msg, "</color>"); |
| | | case TextColType.lightYellow: |
| | | return StringUtility.Contact("<color=#fcedb9>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#fcedb9>", msg, "</color>"); |
| | | case TextColType.NavyYellow: |
| | | return StringUtility.Contact("<color=#f2ee02>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#f2ee02>", msg, "</color>"); |
| | | case TextColType.itemjingliang: |
| | | // 729de4 精良 |
| | | return StringUtility.Contact("<color=#729de4>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#729de4>", msg, "</color>"); |
| | | case TextColType.itemxiyou: |
| | | // c87bfa稀有 |
| | | return StringUtility.Contact("<color=#c87bfa>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#c87bfa>", msg, "</color>"); |
| | | case TextColType.itemshishi: |
| | | // f6de56 史诗 |
| | | return StringUtility.Contact("<color=#f6de56>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#f6de56>", msg, "</color>"); |
| | | case TextColType.itemchuanqi: |
| | | // fe8534 传奇 |
| | | return StringUtility.Contact("<color=#fe8534>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#fe8534>", msg, "</color>"); |
| | | case TextColType.itemshenhua: |
| | | // fe4a47 神话 |
| | | return StringUtility.Contact("<color=#fe4a47>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#fe4a47>", msg, "</color>"); |
| | | case TextColType.itemwuxia: |
| | | // eb5ce9 无瑕 |
| | | return StringUtility.Contact("<color=#eb5ce9>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#eb5ce9>", msg, "</color>"); |
| | | case TextColType.itemanjin: |
| | | // f9e29f 暗金 |
| | | return StringUtility.Contact("<color=#f9e29f>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#f9e29f>", msg, "</color>"); |
| | | case TextColType.itemjueyi: |
| | | // cdfef2 绝艺 |
| | | return StringUtility.Contact("<color=#cdfef2>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#cdfef2>", msg, "</color>"); |
| | | case TextColType.itemyuanzu: |
| | | // dfbbed 元祖 |
| | | return StringUtility.Contact("<color=#dfbbed>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#dfbbed>", msg, "</color>"); |
| | | case TextColType.itembuxiu: |
| | | // 5eeff2 不朽 |
| | | return StringUtility.Contact("<color=#5eeff2>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#5eeff2>", msg, "</color>"); |
| | | case TextColType.itemyonghen: |
| | | // f5b4ea 永恒 |
| | | return StringUtility.Contact("<color=#f5b4ea>", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#f5b4ea>", msg, "</color>"); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | public static string AppendColor(Color color, string msg) |
| | | { |
| | | return StringUtility.Contact("<color=#", ColorToHexWithHash(color), ">", msg, "</color>"); |
| | | return StringUtility.Concat("<color=#", ColorToHexWithHash(color), ">", msg, "</color>"); |
| | | } |
| | | |
| | | |
| | |
| | | return string.Format("{0:X2}{1:X2}{2:X2}", r, g, b); |
| | | } |
| | | } |
| | | |
| | | |
| | | //功能品质文字颜色,哪些功能由美术决定,目前用于古宝 |
| | | public static Color GetFuncQualityColor(int quality) |
| | | { |
| | | |
| | | switch (quality) |
| | | { |
| | | case 1: |
| | | // bbd5ff |
| | | return new Color32(187, 213, 255, 255); |
| | | case 2: |
| | | // e4bbfe |
| | | return new Color32(228, 187, 254, 255); |
| | | case 3: |
| | | // f7eba4 |
| | | return new Color32(247, 235, 164, 255); |
| | | case 4: |
| | | // ffc096 |
| | | return new Color32(255, 192, 150, 255); |
| | | case 5: |
| | | // fe9896 |
| | | return new Color32(254, 152, 150, 255); |
| | | } |
| | | return Color.white; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | |
| | | // switch (config.Quality) |
| | | // { |
| | | // case 1: |
| | | // return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", msg, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "666666" : "dddddd", ">", msg, "</color>"); |
| | | // case 2: |
| | | // return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", msg, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "00b337" : "66ff00", ">", msg, "</color>"); |
| | | // case 3: |
| | | // return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", msg, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "0066ff" : "00c6ff", ">", msg, "</color>"); |
| | | // case 4: |
| | | // return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", msg, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "ff00f6" : "f000ff", ">", msg, "</color>"); |
| | | // case 5: |
| | | // return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", msg, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "ff6600" : "ff9000", ">", msg, "</color>"); |
| | | // case 6: |
| | | // return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", msg, "</color>"); |
| | | // return StringUtility.Concat("<color=#", bright ? "ff0000" : "ff0000", ">", msg, "</color>"); |
| | | // default: |
| | | // return msg; |
| | | // } |
| | |
| | | |
| | | //物品 各功能品质 从精良1品质 对应 3开始 |
| | | /// <summary> |
| | | /// 颜色定义根据分组处理,如普通物品的颜色精良是1开始,树和装备也是粗糙1开始,需要调整匹配 |
| | | /// 颜色定义根据分组处理,如普通物品的颜色精良是1开始,树和装备也是粗糙1开始,命格是从颜色2开始需要调整匹配 |
| | | /// </summary> |
| | | /// <param name="itemColor"></param> |
| | | /// <param name="msg"></param> |
| | | /// <param name="bright"></param> |
| | | /// <param name="colorGroupType">0 通用功能品质分组精良到神话</param> |
| | | /// <param name="colorGroupType">0 通用功能品质分组精良到神话 1 祝福和装备用 2命格用</param> |
| | | /// <returns></returns> |
| | | public static string AppendColor(int itemColor, string msg, bool bright = true, int colorGroupType = 0) |
| | | { |
| | | if (colorGroupType == 0) |
| | | { |
| | | itemColor = itemColor + 2; |
| | | } |
| | | else if (colorGroupType == 2) |
| | | { |
| | | itemColor = itemColor + 1; |
| | | } |
| | | |
| | | switch (itemColor) |
| | |
| | | {43, PlayerDataType.default34}, |
| | | {42, PlayerDataType.default33}, |
| | | {53, PlayerDataType.ChallengeVoucher}, |
| | | {54, PlayerDataType.DailySpecials}, |
| | | {55, PlayerDataType.OSGalaScore}, |
| | | {57, PlayerDataType.QYScore}, |
| | | {58, PlayerDataType.heroSkin}, |
| | | {99, PlayerDataType.ExAttr11}, |
| | | }; |
| | | |
| | |
| | | //挑战凭证 |
| | | return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ChallengeVoucher); |
| | | } |
| | | case 54: |
| | | { |
| | | //特惠印绶 |
| | | return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.DailySpecials); |
| | | } |
| | | case 55: |
| | | { |
| | | //开服庆典积分 |
| | | return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.OSGalaScore); |
| | | } |
| | | case 56: |
| | | { |
| | | //群英挑战令 |
| | | return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.QunyingWDL); |
| | | } |
| | | case 57: |
| | | { |
| | | //群英积分 |
| | | return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.QYScore); |
| | | } |
| | | case 58: |
| | | { |
| | | //时装货币 |
| | | return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.heroSkin); |
| | | } |
| | | case 98: |
| | | { |
| | | //过期型代金券 |
| | |
| | | return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{cnt}/{useCnt}"); |
| | | } |
| | | |
| | | public static string ShowUseItem(PackType type, int itemId, long useCnt, bool showLargeNum = false) |
| | | public static string ShowUseItem(PackType type, int itemId, long useCnt, bool showLargeNum = false, bool bright = true) |
| | | { |
| | | long cnt = PackManager.Instance.GetItemCountByID(type, itemId); |
| | | if (showLargeNum) |
| | | return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{useCnt}"); |
| | | return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{useCnt}", bright); |
| | | else |
| | | return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{cnt}/{useCnt}"); |
| | | return AppendColor(useCnt <= cnt ? TextColType.Green : TextColType.Red, $"{cnt}/{useCnt}", bright); |
| | | } |
| | | |
| | | |
| | |
| | | return isEnough; |
| | | } |
| | | |
| | | /// <param name="needTips">0 不响应 1 弹提示 2 弹获取途径tips</param> |
| | | public static bool CheckItemCount(int itemId, long needCount, int needTips = 0) |
| | | { |
| | | if (needCount <= 0) |
| | | { |
| | | return true; |
| | | } |
| | | long haveCount = PackManager.Instance.GetItemCountByID(PackType.Item, itemId); |
| | | bool isEnough = haveCount >= needCount; |
| | | |
| | | if (!isEnough) |
| | | { |
| | | if (needTips == 1) |
| | | { |
| | | ItemConfig itemConfig = ItemConfig.Get(itemId); |
| | | if (itemConfig != null) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("LackItem", itemConfig.ItemName); |
| | | } |
| | | } |
| | | else if (needTips == 2) |
| | | { |
| | | ItemTipUtility.Show(itemId, true); |
| | | } |
| | | } |
| | | |
| | | return isEnough; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | |
| | | // { |
| | | // return string.Empty; |
| | | // } |
| | | // return StringUtility.Contact(GetEquipSuitName(itmeId, bright), itemConfig.ItemName); |
| | | // return StringUtility.Concat(GetEquipSuitName(itmeId, bright), itemConfig.ItemName); |
| | | // } |
| | | |
| | | public static string GetStar(int star) |
| | |
| | | GUIUtility.systemCopyBuffer = text; |
| | | Debug.Log("文字已复制到剪贴板: " + text); |
| | | } |
| | | |
| | | |
| | | //获取剪切板内容 |
| | | public static string GetClipboardText() |
| | | { |
| | | return GUIUtility.systemCopyBuffer; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 强制刷新Layout,解决嵌套Layout和ContentSizeFitter的重叠问题 |
| | | /// </summary> |
| | | public static async UniTask ForceRefreshLayout(Transform transform) |
| | | { |
| | | await UniTask.DelayFrame(2); |
| | | // 刷新所有Layout组件 |
| | | var layouts = transform.GetComponentsInChildren<LayoutGroup>(true); |
| | | foreach (var layout in layouts) |
| | | { |
| | | LayoutRebuilder.ForceRebuildLayoutImmediate(layout.GetComponent<RectTransform>()); |
| | | } |
| | | await UniTask.DelayFrame(2); |
| | | // 刷新所有Layout组件 |
| | | foreach (var layout in layouts) |
| | | { |
| | | LayoutRebuilder.ForceRebuildLayoutImmediate(layout.GetComponent<RectTransform>()); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public static void ShowServersPanel(List<int> serverIDList) |
| | | { |
| | | if (UIManager.Instance.IsOpened<ServersSmallTipWin>()) |
| | | { |
| | | UIManager.Instance.CloseWindow<ServersSmallTipWin>(); |
| | | } |
| | | ServersSmallTipWin.serverIDList = serverIDList; |
| | | UIManager.Instance.OpenWindow<ServersSmallTipWin>(); |
| | | } |
| | | |
| | | } |