using System; 
 | 
using System.Text; 
 | 
using UnityEngine; 
 | 
using System.Linq; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine.UI; 
 | 
  
 | 
using System.Text.RegularExpressions; 
 | 
using System.IO; 
 | 
using LitJson; 
 | 
  
 | 
/// <summary> 
 | 
/// UI辅助类 
 | 
/// </summary> 
 | 
  
 | 
public static class UIHelper 
 | 
{ 
 | 
  
 | 
    public static readonly string no_breaking_space = "\u00A0"; //Text文本框输入空格自动换行问题 替换编码 
 | 
  
 | 
  
 | 
    //不需要提取翻译的文本 
 | 
    private static readonly string[] numbers = new string[] { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" }; 
 | 
    private static readonly string[] units = new string[] { "十", "百", "千", "万" }; 
 | 
  
 | 
    //数字转中文(只做小数字),海外版本调用改函数切换版本请直接返回数字 
 | 
    public static string ChineseNumber(int number) 
 | 
    { 
 | 
        if (number == 0) 
 | 
            return numbers[0]; 
 | 
  
 | 
        string result = ""; 
 | 
        int unitPlace = 1; // 位数,1 表示十位,2 表示百位,3 表示千位,4 表示万位 
 | 
        bool needZero = false; // 是否需要添加 '零' 
 | 
  
 | 
        while (number > 0) 
 | 
        { 
 | 
            int part = number % 10; 
 | 
            if (part != 0) 
 | 
            { 
 | 
                if (needZero) 
 | 
                    result = StringUtility.Contact(numbers[0] + result); 
 | 
  
 | 
                result = numbers[part] + (unitPlace == 1 ? "" : units[unitPlace - 2]) + result; // 单位只在十、百、千、万内部使用 
 | 
                needZero = false; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                needZero = true; 
 | 
            } 
 | 
  
 | 
            number /= 10; 
 | 
            unitPlace++; 
 | 
        } 
 | 
        if (result.StartsWith("一十")) 
 | 
        { 
 | 
            result = result.Substring(1); 
 | 
        } 
 | 
        if (result.EndsWith("零")) 
 | 
        { 
 | 
            result = result.Replace("零", ""); 
 | 
        } 
 | 
  
 | 
        return result; 
 | 
    } 
 | 
  
 | 
  
 | 
    #region UI通用 
 | 
    public static void SetIconWithMoneyType(this Image _image, int moneyType) 
 | 
    { 
 | 
        if (_image == null) return; 
 | 
        if (GeneralDefine.MoneyDisplayModel.ContainsKey(moneyType)) 
 | 
        { 
 | 
            _image.SetOrgSprite(ItemConfig.Get(GeneralDefine.MoneyDisplayModel[moneyType]).IconKey); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            // 暂不考虑富文本的情况 
 | 
            // 不需要物品的情况补充 
 | 
            // string iconKey = StringUtility.Contact("Money_Type_", moneyType); 
 | 
            Debug.LogError("MoneyDisplayModel 未配置货币类型:" + moneyType); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    public static string GetIconNameWithMoneyType(int moneyType) 
 | 
    { 
 | 
        if (IconConfig.HasKey("MoneyType_" + moneyType)) 
 | 
        { 
 | 
            //富文本显示的情况 
 | 
            return IconConfig.Get("MoneyType_" + moneyType).sprite; 
 | 
        } 
 | 
        else if (GeneralDefine.MoneyDisplayModel.ContainsKey(moneyType)) 
 | 
        { 
 | 
            return ItemConfig.Get(GeneralDefine.MoneyDisplayModel[moneyType]).IconKey; 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            Debug.LogError("MoneyDisplayModel 未配置货币类型:" + moneyType); 
 | 
            return ""; 
 | 
        } 
 | 
    } 
 | 
  
 | 
    /// <summary> 
 | 
    /// 分离字符串插入空格 
 | 
    /// </summary> 
 | 
    public static string GetSuitNameByName(string attrName) 
 | 
    { 
 | 
        string suitStr = ""; 
 | 
        for (int i = 0; i < attrName.Length; i++) 
 | 
        { 
 | 
            if (i != attrName.Length - 1) 
 | 
            { 
 | 
                if (attrName.Length == 2) 
 | 
                { 
 | 
                    suitStr = StringUtility.Contact(suitStr, attrName[i], "        "); 
 | 
                } 
 | 
                else if (attrName.Length == 3) 
 | 
                { 
 | 
                    suitStr = StringUtility.Contact(suitStr, attrName[i], "  "); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    suitStr = StringUtility.Contact(suitStr, attrName[i]); 
 | 
                } 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                suitStr = StringUtility.Contact(suitStr, attrName[i]); 
 | 
            } 
 | 
        } 
 | 
        return suitStr; 
 | 
  
 | 
    } 
 | 
  
 | 
    // 基于itemColor 下,ColorEx做二级区分 
 | 
    public static void SetItemBackGround(this Image _image, int itemColor) 
 | 
    { 
 | 
        if (_image == null) 
 | 
        { 
 | 
            return; 
 | 
        } 
 | 
        _image.SetSprite($"ItemBG{itemColor}"); 
 | 
    } 
 | 
    /// <summary> 
 | 
    /// 剩余时间 
 | 
    /// </summary> 
 | 
    /// <param name="startTime">格式 年-月-日 小时:分钟:秒</param> 
 | 
    /// <param name="ownTime">毫秒</param> 
 | 
    /// <returns></returns> 
 | 
    private static Regex TimeRegex = new Regex(@"([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+)", RegexOptions.Singleline); 
 | 
    public static int GetSurplusSeconds(string startTime, int seconds) 
 | 
    { 
 | 
        string start = GetTime(startTime); 
 | 
        if (start.Equals(string.Empty)) 
 | 
        { 
 | 
            return 0; 
 | 
        } 
 | 
        DateTime s = Convert.ToDateTime(start); 
 | 
        DateTime t = s.AddTicks(seconds * TimeSpan.TicksPerSecond); 
 | 
        DateTime n = TimeUtility.ServerNow; 
 | 
        TimeSpan span = t - n; 
 | 
        return Mathf.Max(0, (int)span.TotalSeconds); 
 | 
    } 
 | 
  
 | 
    public static string GetTime(string startTime) 
 | 
    { 
 | 
        if (!TimeRegex.IsMatch(startTime)) 
 | 
        { 
 | 
            return string.Empty; 
 | 
        } 
 | 
        Match match = TimeRegex.Match(startTime); 
 | 
        int year = int.Parse(match.Groups[1].Value); 
 | 
        int month = int.Parse(match.Groups[2].Value); 
 | 
        int day = int.Parse(match.Groups[3].Value); 
 | 
        int h = int.Parse(match.Groups[4].Value); 
 | 
        int mi = int.Parse(match.Groups[5].Value); 
 | 
        int sc = int.Parse(match.Groups[6].Value); 
 | 
  
 | 
        return string.Format("{0}-{1}-{2} {3}:{4}:{5}", year, month, day, h, mi, sc); 
 | 
  
 | 
    } 
 | 
    /// <summary> 
 | 
    /// 获取过去的时间 
 | 
    /// </summary> 
 | 
    /// <param name="lastTime"></param> 
 | 
    /// <returns></returns> 
 | 
    public static string GetFadeTime(uint lastTime) 
 | 
    { 
 | 
        DateTime n = TimeUtility.ServerNow; 
 | 
        TimeSpan span = n - TimeUtility.GetTime(lastTime); 
 | 
        if (span.TotalDays > 1) return Math.Floor(span.TotalDays) + Language.Get("L1074"); 
 | 
        else if (span.TotalHours > 1) return Math.Floor(span.TotalHours) + Language.Get("L1072"); 
 | 
        else if (span.TotalMinutes > 1) return Math.Floor(span.TotalMinutes) + Language.Get("L1073"); 
 | 
        else return 1 + Language.Get("L1073"); 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    /// <summary> 
 | 
    /// 换行 
 | 
    /// </summary> 
 | 
    /// <param name="val"></param> 
 | 
    /// <returns></returns> 
 | 
    private static Regex NewLineRegex = new Regex(@"</r>", RegexOptions.Singleline); 
 | 
    public static string ReplaceNewLine(string val) 
 | 
    { 
 | 
        return val.Replace(@"</r>", "\n"); 
 | 
    } 
 | 
  
 | 
    public static double numto2Decimals(double value) 
 | 
    { 
 | 
        //为什么要value * 1000/10 这么写,特殊的数字会有问题,比如36.80000,会(int)(value * 100)被计算为3679 
 | 
        //测试下只有30几点8000的才会这样 
 | 
        return (int)(value * 1000 / 10) / 100.00; 
 | 
    } 
 | 
  
 | 
    /// <summary> 
 | 
    /// 大数值转化 格式 最多两个小数 
 | 
    /// K -千,M -百萬,B-十億,T -萬億 
 | 
    /// 不四舍五入,不用Math.Round,因为当玩家只有23.3456,但是Math.Round会显示23.35, 当购买价格为23.35时无法购买的 
 | 
    /// </summary> 
 | 
    public static string ReplaceLargeNum(double num) 
 | 
    { 
 | 
        const long K = 10000;    //国内为万,海外为千 
 | 
        const long M = K * 10000; 
 | 
        const long B = M * 10000; 
 | 
        const long T = B * 10000; 
 | 
  
 | 
        if (num >= T) 
 | 
        { 
 | 
            return StringUtility.Contact(numto2Decimals(num / T).ToString("0.##"), Language.Get("L1070_0")); 
 | 
        } 
 | 
        else if (num >= B) 
 | 
        { 
 | 
            return StringUtility.Contact(numto2Decimals(num / B).ToString("0.##"), Language.Get("L1070_1")); 
 | 
        } 
 | 
        else if (num >= M) 
 | 
        { 
 | 
            return StringUtility.Contact(numto2Decimals(num / M).ToString("0.#"), Language.Get("L1070")); 
 | 
        } 
 | 
        else if (num >= K) 
 | 
        { 
 | 
            return StringUtility.Contact(numto2Decimals(num / K).ToString("0.#"), Language.Get("L1071")); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            return numto2Decimals(num).ToString("0.#"); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    //用于美术字 统一用字母KMBT代表使用,小数点用. 
 | 
    public static string ReplaceLargeArtNum(double num) 
 | 
    { 
 | 
        const long K = 10000;    //国内为万,海外为千 
 | 
        const long M = K * 10000; 
 | 
        const long B = M * 10000; 
 | 
        const long T = B * 10000; 
 | 
  
 | 
        if (num >= T) 
 | 
        { 
 | 
            return StringUtility.Contact(numto2Decimals(num / T).ToString("0.##"), "t"); 
 | 
        } 
 | 
        else if (num >= B) 
 | 
        { 
 | 
            return StringUtility.Contact(numto2Decimals(num / B).ToString("0.##"), "b"); 
 | 
        } 
 | 
        else if (num >= M) 
 | 
        { 
 | 
            return StringUtility.Contact(numto2Decimals(num / M).ToString("0.#"), "m"); 
 | 
        } 
 | 
        else if (num >= K) 
 | 
        { 
 | 
            return StringUtility.Contact(numto2Decimals(num / K).ToString("0.#"), "k"); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            return numto2Decimals(num).ToString("0.#"); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    // 转化大数值带单位的显示,如果小于200000则显示原值,否则显示大数值 
 | 
    public static string ReplaceLargeNumEx(double num) 
 | 
    { 
 | 
        if (num < 200000) 
 | 
        { 
 | 
            //根据界面的显示假定值 200000,可根据实际情况调整 
 | 
            return GetNumFormat(num); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            return ReplaceLargeNum(num); 
 | 
        } 
 | 
    } 
 | 
  
 | 
    //显示最多两位小数,并按地区显示格式 
 | 
    // 如中文用F2 显示 1111.34,英文用N2 显示 1,111.34(带逗号) 
 | 
    public static string GetNumFormat(double num) 
 | 
    { 
 | 
        if (num == (int)num) 
 | 
        { 
 | 
            return num.ToString("F0"); 
 | 
        } 
 | 
        return num.ToString("F2").TrimEnd('0').TrimEnd('.'); 
 | 
    } 
 | 
  
 | 
  
 | 
    public static float ReplacePercentage(float num, int isPer, int decimals = 1) 
 | 
    { 
 | 
        if (isPer == 1 || isPer == 2) 
 | 
        { 
 | 
            return (float)Math.Round(num / 100, decimals); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            return (int)num; 
 | 
        } 
 | 
    } 
 | 
  
 | 
    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) 
 | 
    { 
 | 
        if (s_SpecialCharacterRegex.IsMatch(str)) 
 | 
        { 
 | 
            return true; 
 | 
        } 
 | 
        if (s_AsciiCharacterRegex.IsMatch(str)) 
 | 
        { 
 | 
            return true; 
 | 
        } 
 | 
        return false; 
 | 
    } 
 | 
  
 | 
    // 检查字符串是不是纯整数 
 | 
    public static bool IsNumeric(string input) 
 | 
    { 
 | 
        return int.TryParse(input, out _); 
 | 
    } 
 | 
  
 | 
  
 | 
    public static string GetColorNameByItemColor(int itemColor) 
 | 
    { 
 | 
        switch (itemColor) 
 | 
        { 
 | 
            case 1: 
 | 
                return Language.Get("Market_Text_42"); 
 | 
            case 2: 
 | 
                return Language.Get("Market_Text_43"); 
 | 
            case 3: 
 | 
                return Language.Get("Market_Text_44"); 
 | 
            case 4: 
 | 
                return Language.Get("Market_Text_45"); 
 | 
            case 5: 
 | 
                return Language.Get("Market_Text_46"); 
 | 
            case 6: 
 | 
            case 7: 
 | 
            case 8: 
 | 
                return Language.Get("Market_Text_47"); 
 | 
            case 9: 
 | 
                return Language.Get("Market_Text_471"); 
 | 
        } 
 | 
        return ""; 
 | 
    } 
 | 
  
 | 
    #endregion 
 | 
  
 | 
    #region 文字色值 Bright 和 Dark指背景色系是明还是暗,暗底亮字,亮底暗字的规则 
 | 
    public static readonly Color s_BrightPinkColor = new Color32(246, 64, 141, 255); 
 | 
    public static readonly Color s_BrightRedColor = new Color32(234, 38, 30, 255); 
 | 
    public static readonly Color s_BrightPurpleColor = new Color32(218, 72, 213, 255); 
 | 
    public static readonly Color s_BrightBlueColor = new Color32(0, 107, 227, 255); //006BE3FF 
 | 
    public static readonly Color s_BrightOrangeColor = new Color32(255, 103, 1, 255); //FF6701FF 
 | 
    public static readonly Color s_BrightWhiteColor = new Color32(255, 255, 255, 255);    //ffffff //new Color32(104, 104, 104, 255); //686868 
 | 
    public static readonly Color s_BrightGreenColor = new Color32(36, 139, 18, 255); //248b12 
 | 
  
 | 
    public static readonly Color s_DarkPinkColor = new Color32(255, 124, 124, 255); 
 | 
    public static readonly Color s_DarkRedColor = new Color32(234, 38, 30, 255); 
 | 
    public static readonly Color s_DarkPurpleColor = new Color32(236, 75, 246, 255); 
 | 
    public static readonly Color s_DarkBlueColor = new Color32(49, 206, 251, 255);//31cefb 
 | 
    public static readonly Color s_DarkOrangeColor = new Color32(248, 152, 59, 255); 
 | 
    public static readonly Color s_DarkWhiteColor = new Color32(255, 255, 255, 255);    //ffffff 
 | 
    public static readonly Color s_DarkGreenColor = new Color32(42, 227, 55, 255);//2ae337 
 | 
  
 | 
    public static readonly Color s_NavyBrown = new Color32(110, 76, 49, 255);//6e4c31 
 | 
    public static readonly Color s_Black = new Color32(0, 0, 0, 255); 
 | 
    public static readonly Color s_NavyYellow = new Color32(242, 238, 2, 255); //f2ee02 
 | 
    public static readonly Color s_LightGreen = new Color32(42, 227, 55, 255);//2ae337 
 | 
    public static readonly Color s_LightWhite = new Color32(245, 246, 230, 255); //f5f6e6 
 | 
    public static readonly Color s_Gray = new Color32(187, 187, 187, 255); //bbbbbb 
 | 
    public static readonly Color s_Gold = new Color32(255, 239, 71, 255);//ffef47 
 | 
    public static readonly Color s_EarthYellow = new Color32(248, 152, 59, 255);//f8983b 
 | 
  
 | 
    public static readonly Color s_BrightDanLV0 = new Color32(102, 102, 102, 255); //666666 
 | 
    public static readonly Color s_BrightDanLV1 = new Color32(148, 96, 255, 255); //9460ff 
 | 
    public static readonly Color s_BrightDanLV2 = new Color32(0, 102, 255, 255); //0066ff 
 | 
    public static readonly Color s_BrightDanLV3 = new Color32(0, 179, 55, 255); //00b337 
 | 
    public static readonly Color s_BrightDanLV4 = new Color32(255, 102, 0, 255); //ff6600 
 | 
    public static readonly Color s_BrightDanLV5 = new Color32(255, 0, 0, 255); //ff0000 
 | 
    public static readonly Color s_BrightDanLV6 = new Color32(255, 0, 246, 255); //ff00f6 
 | 
  
 | 
    public static readonly Color s_GrayDanLV0 = new Color32(221, 221, 221, 255); //dddddd 
 | 
    public static readonly Color s_GrayDanLV1 = new Color32(121, 153, 255, 255); //7999ff 
 | 
    public static readonly Color s_GrayDanLV2 = new Color32(0, 198, 255, 255); //00c6ff 
 | 
    public static readonly Color s_GrayDanLV3 = new Color32(102, 255, 0, 255); //66ff00 
 | 
    public static readonly Color s_GrayDanLV4 = new Color32(255, 144, 0, 255); //ff9000 
 | 
    public static readonly Color s_GrayDanLV5 = new Color32(255, 0, 0, 255); //ff0000 
 | 
    public static readonly Color s_GrayDanLV6 = new Color32(240, 0, 255, 255); //f000ff 
 | 
  
 | 
    // public static Color GetDanLVColor(int danLv, bool bright = true) 
 | 
    // { 
 | 
    //     var crossDanLVConfig = CrossServerArenaConfig.Get(danLv); 
 | 
    //     if (crossDanLVConfig != null) 
 | 
    //     { 
 | 
    //         switch (crossDanLVConfig.DanType) 
 | 
    //         { 
 | 
    //             case 0: 
 | 
    //                 return bright ? s_BrightDanLV0 : s_GrayDanLV0; 
 | 
    //             case 1: 
 | 
    //                 return bright ? s_BrightDanLV1 : s_GrayDanLV1; 
 | 
    //             case 2: 
 | 
    //                 return bright ? s_BrightDanLV2 : s_GrayDanLV2; 
 | 
    //             case 3: 
 | 
    //                 return bright ? s_BrightDanLV3 : s_GrayDanLV3; 
 | 
    //             case 4: 
 | 
    //                 return bright ? s_BrightDanLV4 : s_GrayDanLV4; 
 | 
    //             case 5: 
 | 
    //                 return bright ? s_BrightDanLV5 : s_GrayDanLV5; 
 | 
    //             case 6: 
 | 
    //                 return bright ? s_BrightDanLV6 : s_GrayDanLV6; 
 | 
    //         } 
 | 
    //     } 
 | 
    //     return Color.white; 
 | 
    // } 
 | 
  
 | 
    // public static string AppendDanLVNameColor(int danLv, bool bright = true) 
 | 
    // { 
 | 
    //     var crossDanLVConfig = CrossServerArenaConfig.Get(danLv); 
 | 
    //     if (crossDanLVConfig == null) 
 | 
    //     { 
 | 
    //         return string.Empty; 
 | 
    //     } 
 | 
    //     var name = crossDanLVConfig.Name; 
 | 
    //     switch (crossDanLVConfig.DanType) 
 | 
    //     { 
 | 
    //         case 0: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", name, "</color>"); 
 | 
    //         case 1: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "9460ff" : "7999ff", ">", name, "</color>"); 
 | 
    //         case 2: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", name, "</color>"); 
 | 
    //         case 3: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", name, "</color>"); 
 | 
    //         case 4: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", name, "</color>"); 
 | 
    //         case 5: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", name, "</color>"); 
 | 
    //         case 6: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", name, "</color>"); 
 | 
    //     } 
 | 
    //     return name; 
 | 
    // } 
 | 
  
 | 
  
 | 
  
 | 
    //物品 各功能品质 从精良1品质 对应 3开始 
 | 
    public static Color GetUIColorByFunc(int itemColor, bool bright = true) 
 | 
    { 
 | 
        return GetUIColor(itemColor + 2, bright); 
 | 
    } 
 | 
  
 | 
  
 | 
    //对应品质(树);物品 各功能品质 用GetUIColorByFunc 
 | 
    public static Color GetUIColor(int itemColor, bool bright = true) 
 | 
    { 
 | 
        switch (itemColor) 
 | 
        { 
 | 
            case 0: 
 | 
            case 1: 
 | 
                return GetUIColor(TextColType.Gray, bright); 
 | 
            case 2: 
 | 
                return GetUIColor(TextColType.White, bright); 
 | 
            case 3: 
 | 
                return GetUIColor(TextColType.itemjingliang, bright); 
 | 
            case 4: 
 | 
                return GetUIColor(TextColType.itemxiyou, bright); 
 | 
            case 5: 
 | 
                return GetUIColor(TextColType.itemshishi, bright); 
 | 
            case 6: 
 | 
                return GetUIColor(TextColType.itemchuanqi, bright); 
 | 
            case 7: 
 | 
                return GetUIColor(TextColType.itemshenhua, bright); 
 | 
            case 8: 
 | 
                return GetUIColor(TextColType.itemwuxia, bright); 
 | 
            case 9: 
 | 
                return GetUIColor(TextColType.itemanjin, bright); 
 | 
            case 10: 
 | 
            case 11: 
 | 
            case 12: 
 | 
            case 13: 
 | 
            case 14: 
 | 
                return GetUIColor(TextColType.itemjueyi, bright); 
 | 
            case 15: 
 | 
            case 16: 
 | 
            case 17: 
 | 
            case 18: 
 | 
            case 19: 
 | 
                return GetUIColor(TextColType.itemyuanzu, bright); 
 | 
            case 20: 
 | 
            case 21: 
 | 
            case 22: 
 | 
            case 23: 
 | 
            case 24: 
 | 
                return GetUIColor(TextColType.itembuxiu, bright); 
 | 
            case 25: 
 | 
            case 26: 
 | 
            case 27: 
 | 
            case 28: 
 | 
            case 29: 
 | 
                return GetUIColor(TextColType.itemyonghen, bright); 
 | 
  
 | 
  
 | 
        } 
 | 
        return GetUIColor(TextColType.White, bright); 
 | 
    } 
 | 
  
 | 
    public static Color GetUIColor(TextColType type, bool bright = true) 
 | 
    { 
 | 
        //Bright 和 Dark指背景色系是明还是暗,暗底亮字,亮底暗字的规则 
 | 
        switch (type) 
 | 
        { 
 | 
            case TextColType.None: 
 | 
            case TextColType.White: 
 | 
                return bright ? s_BrightWhiteColor : s_DarkWhiteColor;  // s_BrightWhiteColor 是亮底灰色 
 | 
            case TextColType.titleSelectColor: 
 | 
                return new Color32(127, 65, 57, 255); 
 | 
            case TextColType.titleUnSelectColor: 
 | 
                return new Color32(110, 92, 96, 255); 
 | 
            case TextColType.Red: 
 | 
                return bright ? s_BrightRedColor : s_DarkRedColor; 
 | 
            case TextColType.Pink: 
 | 
                return bright ? s_BrightPinkColor : s_DarkPinkColor; 
 | 
            case TextColType.Green: 
 | 
                return bright ? s_BrightGreenColor : s_DarkGreenColor; 
 | 
            case TextColType.NavyBrown: 
 | 
                return s_NavyBrown; 
 | 
            case TextColType.DarkGreen: 
 | 
                return s_BrightGreenColor; 
 | 
            case TextColType.Black: 
 | 
                return s_Black; 
 | 
            case TextColType.lightYellow:   //浅黄色 
 | 
                return new Color32(252, 237, 185, 255); 
 | 
            case TextColType.NavyYellow: 
 | 
                return s_NavyYellow; 
 | 
            case TextColType.LightGreen: 
 | 
                return s_LightGreen; 
 | 
            case TextColType.LightWhite: 
 | 
                return s_LightWhite; 
 | 
            case TextColType.Gray: 
 | 
                return s_Gray; 
 | 
            case TextColType.NavyGray: 
 | 
                return new Color32(121, 121, 121, 255); 
 | 
            case TextColType.itemjingliang: 
 | 
                // 729de4 精良 
 | 
                return new Color32(114, 157, 228, 255); 
 | 
            case TextColType.itemxiyou: 
 | 
                // c87bfa稀有 
 | 
                return new Color32(199, 123, 253, 255); 
 | 
            case TextColType.itemshishi: 
 | 
                // f6de56 史诗 
 | 
                return new Color32(246, 222, 86, 255); 
 | 
            case TextColType.itemchuanqi: 
 | 
                // fe8534 传奇 
 | 
                return new Color32(254, 133, 52, 255); 
 | 
            case TextColType.itemshenhua: 
 | 
                // fe4a47 神话 
 | 
                return new Color32(254, 66, 71, 255); 
 | 
            case TextColType.itemwuxia: 
 | 
                // eb5ce9 无瑕 
 | 
                return new Color32(235, 90, 233, 255); 
 | 
            case TextColType.itemanjin: 
 | 
                // f9e29f 暗金 
 | 
                return new Color32(254, 181, 68, 255); 
 | 
            case TextColType.itemjueyi: 
 | 
                // cdfef2 绝艺 
 | 
                return new Color32(205, 239, 242, 255); 
 | 
            case TextColType.itemyuanzu: 
 | 
                // dfbbed 元祖 
 | 
                return new Color32(223, 187, 237, 255); 
 | 
            case TextColType.itembuxiu: 
 | 
                // 5eeff2 不朽 
 | 
                return new Color32(94, 239, 242, 255); 
 | 
            case TextColType.itemyonghen: 
 | 
                // f5b4ea 永恒 
 | 
                return new Color32(245, 180, 234, 255); 
 | 
        } 
 | 
        return bright ? s_BrightWhiteColor : s_DarkWhiteColor; 
 | 
    } 
 | 
  
 | 
    //对应品质(树);物品 各功能品质 用GetUIOutlineColorByFunc 
 | 
    public static Color GetUIOutlineColor(int quality) 
 | 
    { 
 | 
        switch (quality) 
 | 
        { 
 | 
            case 1: 
 | 
            case 2: 
 | 
            case 3: 
 | 
            case 4: 
 | 
            case 5: 
 | 
            case 6: 
 | 
            case 7: 
 | 
            case 8: 
 | 
            case 9: 
 | 
                return GetUIOutlineColor((QualityTextColType)quality); 
 | 
            case 10: 
 | 
            case 11: 
 | 
            case 12: 
 | 
            case 13: 
 | 
            case 14: 
 | 
                return GetUIOutlineColor(QualityTextColType.itemjueyi); 
 | 
            case 15: 
 | 
            case 16: 
 | 
            case 17: 
 | 
            case 18: 
 | 
            case 19: 
 | 
                return GetUIOutlineColor(QualityTextColType.itemyuanzu); 
 | 
            case 20: 
 | 
            case 21: 
 | 
            case 22: 
 | 
            case 23: 
 | 
            case 24: 
 | 
                return GetUIOutlineColor(QualityTextColType.itembuxiu); 
 | 
            case 25: 
 | 
            case 26: 
 | 
            case 27: 
 | 
            case 28: 
 | 
            case 29: 
 | 
                return GetUIOutlineColor(QualityTextColType.itemyonghen); 
 | 
        } 
 | 
        return GetUIOutlineColor(QualityTextColType.itemputong); 
 | 
    } 
 | 
  
 | 
    //物品 各功能品质  从精良1品质 对应 3开始 
 | 
    public static Color GetUIOutlineColorByFunc(int quality) 
 | 
    { 
 | 
        return GetUIOutlineColor((QualityTextColType)(quality + 2)); 
 | 
    } 
 | 
  
 | 
    //描边颜色,对应品质(树) 
 | 
    public static Color GetUIOutlineColor(QualityTextColType type) 
 | 
    { 
 | 
        switch (type) 
 | 
        { 
 | 
            case QualityTextColType.itemcucao: 
 | 
                // 2d2d2d 粗糙 
 | 
                return new Color32(45, 45, 45, 128); 
 | 
            case QualityTextColType.itemputong: 
 | 
                // 424242 普通 
 | 
                return new Color32(66, 66, 66, 128); 
 | 
            case QualityTextColType.itemjingliang: 
 | 
                // 172543 精良 
 | 
                return new Color32(23, 37, 67, 128); 
 | 
            case QualityTextColType.itemxiyou: 
 | 
                // 2a0f30 稀有 
 | 
                return new Color32(42, 15, 48, 128); 
 | 
            case QualityTextColType.itemshishi: 
 | 
                // 4a2f00 史诗 
 | 
                return new Color32(74, 47, 0, 128); 
 | 
            case QualityTextColType.itemchuanqi: 
 | 
                // 451800 传奇 
 | 
                return new Color32(69, 24, 0, 128); 
 | 
            case QualityTextColType.itemshenhua: 
 | 
                // 510000 神话 
 | 
                return new Color32(81, 0, 0, 128); 
 | 
            case QualityTextColType.itemwuxia: 
 | 
                // 43003e 无瑕 
 | 
                return new Color32(67, 0, 62, 128); 
 | 
            case QualityTextColType.itemanjin: 
 | 
                // 6f4401 暗金 
 | 
                return new Color32(111, 68, 1, 128); 
 | 
            case QualityTextColType.itemjueyi: 
 | 
                // 203995 绝艺 
 | 
                return new Color32(32, 57, 149, 128); 
 | 
            case QualityTextColType.itemyuanzu: 
 | 
                // 461f5d 元祖 
 | 
                return new Color32(70, 31, 93, 128); 
 | 
            case QualityTextColType.itembuxiu: 
 | 
                // 2e3975 不朽 
 | 
                return new Color32(46, 57, 117, 128); 
 | 
            case QualityTextColType.itemyonghen: 
 | 
                // 5d1d52 永恒 
 | 
                return new Color32(93, 29, 82, 128); 
 | 
            case QualityTextColType.red: 
 | 
                return s_DarkRedColor; 
 | 
        } 
 | 
        return new Color32(0, 0, 0, 128); 
 | 
    } 
 | 
  
 | 
    // private static Regex m_TextColorRegex = new Regex("<color=#[0-9a-zA-Z]+>(.*)</color>", RegexOptions.Singleline); 
 | 
  
 | 
    public static string AppendColor(TextColType type, string msg, bool bright = true) 
 | 
    { 
 | 
        // if (m_TextColorRegex.IsMatch(msg) && msg.ToLower().StartsWith("<color=#") 
 | 
        //     && msg.ToLower().EndsWith("</color>")) 
 | 
        // { 
 | 
        //     Match match = m_TextColorRegex.Match(msg); 
 | 
        //     msg = match.Groups[1].Value; 
 | 
        // } 
 | 
        switch (type) 
 | 
        { 
 | 
            case TextColType.None: 
 | 
            case TextColType.White: 
 | 
                return StringUtility.Contact("<color=#", bright ? "ffffff" : "ffffff", ">", msg, "</color>"); 
 | 
            case TextColType.titleSelectColor: 
 | 
                return StringUtility.Contact("<color=#7F4139>", msg, "</color>"); 
 | 
            case TextColType.titleUnSelectColor: 
 | 
                return StringUtility.Contact("<color=#6E5C60>", msg, "</color>"); 
 | 
            case TextColType.Red: 
 | 
                return StringUtility.Contact("<color=#", bright ? "ea261e" : "ea261e", ">", msg, "</color>"); 
 | 
            case TextColType.Pink: 
 | 
                return StringUtility.Contact("<color=#", bright ? "f6408d" : "ff7c7c", ">", msg, "</color>"); 
 | 
            case TextColType.Green: 
 | 
                return StringUtility.Contact("<color=#", bright ? "248B12" : "2ae337", ">", msg, "</color>"); 
 | 
            case TextColType.NavyBrown: 
 | 
                return StringUtility.Contact("<color=#6e4c31>", msg, "</color>"); 
 | 
            case TextColType.DarkGreen: 
 | 
                return StringUtility.Contact("<color=#248B12>", msg, "</color>"); 
 | 
            case TextColType.Black: 
 | 
                return StringUtility.Contact("<color=#000000>", msg, "</color>"); 
 | 
            case TextColType.LightWhite: 
 | 
                return StringUtility.Contact("<color=f5f646>", msg, "</color>"); 
 | 
            case TextColType.LightGreen: 
 | 
                return StringUtility.Contact("<color=#8ddc11>", msg, "</color>"); 
 | 
            case TextColType.Gray: 
 | 
                return StringUtility.Contact("<color=#bbbbbb>", msg, "</color>"); 
 | 
            case TextColType.NavyGray: 
 | 
                return StringUtility.Contact("<color=#797979>", msg, "</color>"); 
 | 
            case TextColType.lightYellow: 
 | 
                return StringUtility.Contact("<color=#fcedb9>", msg, "</color>"); 
 | 
            case TextColType.NavyYellow: 
 | 
                return StringUtility.Contact("<color=#f2ee02>", msg, "</color>"); 
 | 
            case TextColType.itemjingliang: 
 | 
                // 729de4 精良 
 | 
                return StringUtility.Contact("<color=#729de4>", msg, "</color>"); 
 | 
            case TextColType.itemxiyou: 
 | 
                // c87bfa稀有 
 | 
                return StringUtility.Contact("<color=#c87bfa>", msg, "</color>"); 
 | 
            case TextColType.itemshishi: 
 | 
                // f6de56 史诗 
 | 
                return StringUtility.Contact("<color=#f6de56>", msg, "</color>"); 
 | 
            case TextColType.itemchuanqi: 
 | 
                // fe8534 传奇 
 | 
                return StringUtility.Contact("<color=#fe8534>", msg, "</color>"); 
 | 
            case TextColType.itemshenhua: 
 | 
                // fe4a47 神话 
 | 
                return StringUtility.Contact("<color=#fe4a47>", msg, "</color>"); 
 | 
            case TextColType.itemwuxia: 
 | 
                // eb5ce9 无瑕 
 | 
                return StringUtility.Contact("<color=#eb5ce9>", msg, "</color>"); 
 | 
            case TextColType.itemanjin: 
 | 
                // f9e29f 暗金 
 | 
                return StringUtility.Contact("<color=#f9e29f>", msg, "</color>"); 
 | 
            case TextColType.itemjueyi: 
 | 
                // cdfef2 绝艺 
 | 
                return StringUtility.Contact("<color=#cdfef2>", msg, "</color>"); 
 | 
            case TextColType.itemyuanzu: 
 | 
                // dfbbed 元祖 
 | 
                return StringUtility.Contact("<color=#dfbbed>", msg, "</color>"); 
 | 
            case TextColType.itembuxiu: 
 | 
                // 5eeff2 不朽 
 | 
                return StringUtility.Contact("<color=#5eeff2>", msg, "</color>"); 
 | 
            case TextColType.itemyonghen: 
 | 
                // f5b4ea 永恒 
 | 
                return StringUtility.Contact("<color=#f5b4ea>", msg, "</color>"); 
 | 
        } 
 | 
        return msg; 
 | 
    } 
 | 
  
 | 
    public static string AppendColor(Color color, string msg) 
 | 
    { 
 | 
        return StringUtility.Contact("<color=#", ColorToHexWithHash(color), ">", msg, "</color>"); 
 | 
    } 
 | 
  
 | 
  
 | 
    public static string ColorToHexWithHash(Color color, bool includeAlpha = false) 
 | 
    { 
 | 
        int r = Mathf.RoundToInt(color.r * 255); 
 | 
        int g = Mathf.RoundToInt(color.g * 255); 
 | 
        int b = Mathf.RoundToInt(color.b * 255); 
 | 
        if (includeAlpha) 
 | 
        { 
 | 
            int a = Mathf.RoundToInt(color.a * 255); 
 | 
            return string.Format("{0:X2}{1:X2}{2:X2}{3:X2}", r, g, b, a); 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            return string.Format("{0:X2}{1:X2}{2:X2}", r, g, b); 
 | 
        } 
 | 
    } 
 | 
  
 | 
  
 | 
  
 | 
    //needName 指官职0是否需要名称 
 | 
    public static string GetRealmName(int realmLv, bool bright = true, bool needName = false) 
 | 
    { 
 | 
        if (realmLv <= 0 && !needName) 
 | 
        { 
 | 
            return string.Empty; 
 | 
        } 
 | 
        var config = RealmConfig.Get(realmLv); 
 | 
        if (config == null) 
 | 
        { 
 | 
            return string.Empty; 
 | 
        } 
 | 
        return AppendColor(realmLv, config.Name, bright); 
 | 
    } 
 | 
  
 | 
    //strFormat附加 境界名以外的文字 
 | 
    //needName 指境界0是否需要名称 
 | 
    // public static string GetRealmNameEx(int realmLv, string strFormat, bool bright = false, bool needName = false) 
 | 
    // { 
 | 
    //     if (realmLv <= 0 && !needName) 
 | 
    //     { 
 | 
    //         return string.Empty; 
 | 
    //     } 
 | 
    //     var config = RealmConfig.Get(realmLv); 
 | 
    //     if (config == null) 
 | 
    //     { 
 | 
    //         return string.Empty; 
 | 
    //     } 
 | 
    //     return GetRealmColorByLv(realmLv, string.Format(strFormat, config.Name), bright); 
 | 
    // } 
 | 
  
 | 
    // public static string GetRealmColorByLv(int realmLv, string msg, bool bright = true) 
 | 
    // { 
 | 
    //     var config = RealmConfig.Get(realmLv); 
 | 
    //     if (config == null) 
 | 
    //     { 
 | 
    //         return string.Empty; 
 | 
    //     } 
 | 
    //     switch (config.Quality) 
 | 
    //     { 
 | 
    //         case 1: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", msg, "</color>"); 
 | 
    //         case 2: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", msg, "</color>"); 
 | 
    //         case 3: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", msg, "</color>"); 
 | 
    //         case 4: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", msg, "</color>"); 
 | 
    //         case 5: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", msg, "</color>"); 
 | 
    //         case 6: 
 | 
    //             return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", msg, "</color>"); 
 | 
    //         default: 
 | 
    //             return msg; 
 | 
    //     } 
 | 
    // } 
 | 
  
 | 
    //物品 各功能品质  从精良1品质 对应 3开始 
 | 
    /// <summary> 
 | 
    /// 颜色定义根据分组处理,如普通物品的颜色精良是1开始,树和装备也是粗糙1开始,需要调整匹配 
 | 
    /// </summary> 
 | 
    /// <param name="itemColor"></param> 
 | 
    /// <param name="msg"></param> 
 | 
    /// <param name="bright"></param> 
 | 
    /// <param name="colorGroupType">0 通用功能品质分组精良到神话</param> 
 | 
    /// <returns></returns> 
 | 
    public static string AppendColor(int itemColor, string msg, bool bright = true, int colorGroupType = 0) 
 | 
    { 
 | 
        if (colorGroupType == 0) 
 | 
        { 
 | 
            itemColor = itemColor + 2; 
 | 
        } 
 | 
  
 | 
        switch (itemColor) 
 | 
        { 
 | 
  
 | 
            case 1: 
 | 
                return AppendColor(TextColType.Gray, msg, bright); 
 | 
            case 2: 
 | 
                return AppendColor(TextColType.White, msg, bright); 
 | 
            case 3: 
 | 
                return AppendColor(TextColType.itemjingliang, msg, bright); 
 | 
            case 4: 
 | 
                return AppendColor(TextColType.itemxiyou, msg, bright); 
 | 
            case 5: 
 | 
                return AppendColor(TextColType.itemshishi, msg, bright); 
 | 
            case 6: 
 | 
                return AppendColor(TextColType.itemchuanqi, msg, bright); 
 | 
            case 7: 
 | 
                return AppendColor(TextColType.itemshenhua, msg, bright); 
 | 
            case 8: 
 | 
                return AppendColor(TextColType.itemwuxia, msg, bright); 
 | 
            case 9: 
 | 
                return AppendColor(TextColType.itemanjin, msg, bright); 
 | 
            case 10: 
 | 
            case 11: 
 | 
            case 12: 
 | 
            case 13: 
 | 
            case 14: 
 | 
                return AppendColor(TextColType.itemjueyi, msg, bright); 
 | 
            case 15: 
 | 
            case 16: 
 | 
            case 17: 
 | 
            case 18: 
 | 
            case 19: 
 | 
                return AppendColor(TextColType.itemyuanzu, msg, bright); 
 | 
            case 20: 
 | 
            case 21: 
 | 
            case 22: 
 | 
            case 23: 
 | 
            case 24: 
 | 
                return AppendColor(TextColType.itembuxiu, msg, bright); 
 | 
            case 25: 
 | 
            case 26: 
 | 
            case 27: 
 | 
            case 28: 
 | 
            case 29: 
 | 
                return AppendColor(TextColType.itemyonghen, msg, bright); 
 | 
  
 | 
        } 
 | 
        return msg; 
 | 
    } 
 | 
  
 | 
    public static Color GetPropertyColor(int property) 
 | 
    { 
 | 
        switch ((PropertyType)property) 
 | 
        { 
 | 
            case PropertyType.Mater: 
 | 
                return s_Gold; 
 | 
            case PropertyType.Wood: 
 | 
                return s_LightGreen; 
 | 
            case PropertyType.Water: 
 | 
                return s_DarkBlueColor; 
 | 
            case PropertyType.Fire: 
 | 
                return s_GrayDanLV5; 
 | 
            case PropertyType.Earth: 
 | 
                return s_EarthYellow; 
 | 
        } 
 | 
        return s_NavyBrown; 
 | 
    } 
 | 
    #endregion 
 | 
  
 | 
  
 | 
  
 | 
    #region 得到金钱数量根据金钱类型 
 | 
  
 | 
  
 | 
    //货币单位的显示,海外显示逗号, 国内不加逗号 
 | 
    public static string GetMoneyFormat(double money) 
 | 
    { 
 | 
        if (money == (int)money) 
 | 
        { 
 | 
            return money.ToString("F0"); 
 | 
        } 
 | 
        return money.ToString("F2").TrimEnd('0').TrimEnd('.'); 
 | 
        //return money.ToString(); 
 | 
    } 
 | 
  
 | 
    //仅用于显示 仙玉和灵石的特殊处理,存在负数情况,如GM惩罚扣除货币 
 | 
    public static int GetMoneyCntEx(int moneyType) 
 | 
    { 
 | 
        switch (moneyType) 
 | 
        { 
 | 
            case 1: 
 | 
                { 
 | 
                    return (int)(PlayerDatas.Instance.baseData.diamond - PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default5)); 
 | 
                } 
 | 
            case 2: 
 | 
                { 
 | 
                    return (int)(PlayerDatas.Instance.baseData.bindDiamond - PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default6)); 
 | 
                } 
 | 
        } 
 | 
        return 0; 
 | 
    } 
 | 
  
 | 
    //货币对应0418类型 
 | 
    public static Dictionary<int, PlayerDataType> moneyTypeToPlayerDataType = new Dictionary<int, PlayerDataType>() 
 | 
    { 
 | 
        {1, PlayerDataType.Gold}, 
 | 
        {2, PlayerDataType.GoldPaper}, 
 | 
        {3, PlayerDataType.Silver}, 
 | 
        {15, PlayerDataType.UnionLiven}, 
 | 
        {41, PlayerDataType.default26}, 
 | 
        {43, PlayerDataType.default34}, 
 | 
        {42, PlayerDataType.default33}, 
 | 
        {53, PlayerDataType.ChallengeVoucher}, 
 | 
        {99, PlayerDataType.ExAttr11}, 
 | 
    }; 
 | 
  
 | 
    public static long GetMoneyCnt(int moneyType) 
 | 
    { 
 | 
        switch (moneyType) 
 | 
        { 
 | 
            case 1: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.baseData.diamond; 
 | 
                } 
 | 
            case 2: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.baseData.bindDiamond; 
 | 
                } 
 | 
            case 3: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.baseData.allCopper; 
 | 
                } 
 | 
            case 18: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.extersion.honorValue; 
 | 
                } 
 | 
            case 25: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.CDBPlayerRefresh_TreasureScore); 
 | 
                    //return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataType.CDBPlayerRefresh_TreasureScore); 
 | 
                } 
 | 
            case 24: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.extersion.runeChip; 
 | 
                } 
 | 
            case 15: 
 | 
                { 
 | 
                    // 公会贡献币 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.UnionLiven); 
 | 
                    //return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataType.UnionLiven); 
 | 
                } 
 | 
            case 17: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.FBHelpPoint); 
 | 
                    //return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataType.FBHelpPoint); 
 | 
                } 
 | 
            case 27: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.CDBPlayerRefresh_Danjing); 
 | 
                    //return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataType.CDBPlayerRefresh_Danjing); 
 | 
                } 
 | 
            case 28: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.extersion.soulDust; //废弃了用44 
 | 
                } 
 | 
            case 29: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.extersion.soulSplinters; 
 | 
                } 
 | 
            case 30: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.extersion.soulCore; 
 | 
                } 
 | 
            case 32: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default4); 
 | 
                } 
 | 
            case 34: 
 | 
                { 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default13); 
 | 
                } 
 | 
            case 35: 
 | 
                { 
 | 
                    //功德点 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default14); 
 | 
                } 
 | 
            case 37: 
 | 
                { 
 | 
                    //机缘点 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default17); 
 | 
                } 
 | 
            case 39: 
 | 
                { 
 | 
                    //成就积分 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default19); 
 | 
                } 
 | 
            case 40: 
 | 
                { 
 | 
                    //万界积分 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default20); 
 | 
                } 
 | 
            case 41: 
 | 
                { 
 | 
                    //战锤 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default26); 
 | 
                } 
 | 
            case 42: 
 | 
                { 
 | 
                    //将星玉髓 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default33); 
 | 
                } 
 | 
            case 43: 
 | 
                { 
 | 
                    //将魂 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default34); 
 | 
                } 
 | 
            case 44: 
 | 
                { 
 | 
                    //聚魂精华 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default35); 
 | 
                } 
 | 
            case 45: 
 | 
                { 
 | 
                    //骑宠积分 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default37); 
 | 
                } 
 | 
            case 46: 
 | 
                { 
 | 
                    //古宝养成货币 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default38); 
 | 
                } 
 | 
            case 47: 
 | 
                { 
 | 
                    //天道币 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default39); 
 | 
                } 
 | 
            case 49: 
 | 
                { 
 | 
                    //仙缘积分 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default42); 
 | 
                } 
 | 
            case 50: 
 | 
                { 
 | 
                    //幻境阁积分 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default43); 
 | 
                } 
 | 
            case 51: 
 | 
                { 
 | 
                    //武将招募积分 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default44); 
 | 
                } 
 | 
            case 52: 
 | 
                { 
 | 
                    //淘金令 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.GoldRush); 
 | 
                } 
 | 
            case 53: 
 | 
                { 
 | 
                    //挑战凭证 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ChallengeVoucher); 
 | 
                } 
 | 
            case 98: 
 | 
                { 
 | 
                    //过期型代金券 
 | 
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default41); 
 | 
                } 
 | 
            case 99: 
 | 
                { 
 | 
                    //代金券 
 | 
                    return PlayerDatas.Instance.baseData.ExAttr11; 
 | 
                } 
 | 
        } 
 | 
        return 0; 
 | 
    } 
 | 
  
 | 
  
 | 
    public static int GetAllVourcher() 
 | 
    { 
 | 
        return (int)GetMoneyCnt(98) + (int)GetMoneyCnt(99); 
 | 
    } 
 | 
  
 | 
    //显示数量, 格式n/m, 足够绿色不足红色 
 | 
    public static string ShowUseMoney(int moneyType, long useCnt, TextColType engoughColor = TextColType.Green) 
 | 
    { 
 | 
        long cnt = GetMoneyCnt(moneyType); 
 | 
        return AppendColor(useCnt <= cnt ? engoughColor : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{ReplaceLargeNum(useCnt)}"); 
 | 
    } 
 | 
  
 | 
    public static string ShowUseItem(PackType type, int itemId, long useCnt, TextColType engoughColor = TextColType.Green) 
 | 
    { 
 | 
        long cnt = PackManager.Instance.GetItemCountByID(type, itemId); 
 | 
        return AppendColor(useCnt <= cnt ? engoughColor : TextColType.Red, $"{ReplaceLargeNum(cnt)}/{ReplaceLargeNum(useCnt)}"); 
 | 
    } 
 | 
  
 | 
  
 | 
    /// <param name="needTips">0 不响应 1 弹提示 2 弹获取途径tips</param> 
 | 
    public static bool CheckMoneyCount(int moneyType, long needCount, int needTips = 0) 
 | 
    { 
 | 
        if (needCount <= 0) 
 | 
        { 
 | 
            return true; 
 | 
        } 
 | 
  
 | 
        long haveCount = GetMoneyCnt(moneyType); 
 | 
  
 | 
        bool isEnough = haveCount >= needCount; 
 | 
  
 | 
        if (!isEnough) 
 | 
        { 
 | 
            if (needTips == 1) 
 | 
            { 
 | 
                SysNotifyMgr.Instance.ShowTip("LackMoney", moneyType); 
 | 
            } 
 | 
            else if (needTips == 2) 
 | 
            { 
 | 
                ItemTipUtility.ShowMoneyTip(moneyType); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        return isEnough; 
 | 
    } 
 | 
  
 | 
  
 | 
    #endregion 
 | 
  
 | 
    #region 得到装备位或者祝福树品质名称 带颜色 
 | 
    public static string GetQualityNameWithColor(int quality, string format = "{0}") 
 | 
    { 
 | 
        return AppendColor(quality, string.Format(format, Language.Get("equipQuality" + quality)), true, 1); 
 | 
    } 
 | 
    #endregion 
 | 
  
 | 
    #region 服务端发过来文字显示不出来问题 
 | 
    public static string ServerStringTrim(string str) 
 | 
    { 
 | 
        if (!string.IsNullOrEmpty(str)) 
 | 
        { 
 | 
            str = str.Replace("\0", ""); 
 | 
            str = str.Replace("\x00", ""); 
 | 
            return str; 
 | 
        } 
 | 
        else 
 | 
        { 
 | 
            return string.Empty; 
 | 
        } 
 | 
    } 
 | 
    #endregion 
 | 
  
 | 
    //账号:706907@1@hyyngame@s30,服务器ID:30 
 | 
    public static int GetServerIDByAccount(string account) 
 | 
    { 
 | 
        string[] strArray = account.Split('@'); 
 | 
        if (strArray.Length < 2) 
 | 
        { 
 | 
            //判断长度2不是一个实际长度,一般都是大于2 
 | 
            return 0; 
 | 
        } 
 | 
        if (strArray[strArray.Length - 1].Length < 2) 
 | 
            return 0; 
 | 
        int id = 0; 
 | 
        int.TryParse(strArray[strArray.Length - 1].Substring(1), out id); 
 | 
        return id; 
 | 
    } 
 | 
  
 | 
  
 | 
    #region 获取间隔奖励 
 | 
    public static int GetIntervalAward(ICollection<int> _keys, int _present) 
 | 
    { 
 | 
        foreach (var _key in _keys) 
 | 
        { 
 | 
            if (_present <= _key) 
 | 
            { 
 | 
                return _key; 
 | 
            } 
 | 
        } 
 | 
        return _keys.Last(); 
 | 
    } 
 | 
    #endregion 
 | 
  
 | 
    public static string GetGrade(int _star) 
 | 
    { 
 | 
        switch (_star) 
 | 
        { 
 | 
            case 5: 
 | 
                return "S"; 
 | 
            case 4: 
 | 
                return "A"; 
 | 
            case 3: 
 | 
                return "B"; 
 | 
            case 2: 
 | 
                return "C"; 
 | 
            case 1: 
 | 
                return "D"; 
 | 
        } 
 | 
        return "D"; 
 | 
    } 
 | 
  
 | 
    public static string TrimContentToServer(string content) 
 | 
    { 
 | 
        content = WordAnalysis.Color_Start_Regex.Replace(content, string.Empty); 
 | 
        content = WordAnalysis.Color_End_Regex.Replace(content, string.Empty); 
 | 
        content = content.Replace("=", string.Empty); 
 | 
        content = content.Replace(" ", string.Empty); 
 | 
        return content; 
 | 
    } 
 | 
  
 | 
    //检查名字长度,玩家名和公会名 
 | 
    //不同国家长度不同,排版不同 
 | 
    public static bool SatisfyNameLength(string name, out int error) 
 | 
    { 
 | 
        error = 0; 
 | 
        //bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$"); 
 | 
        //var chsCount = GetChsCount(name); 
 | 
        int length = Encoding.Default.GetBytes(name).Length; 
 | 
        var maxlength = 14;  //纯中文不建议超过7个字 
 | 
        var minlength = 3; 
 | 
        if (length > maxlength) 
 | 
        { 
 | 
            error = 1; 
 | 
        } 
 | 
        else if (length < minlength) 
 | 
        { 
 | 
            error = 2; 
 | 
        } 
 | 
        return error == 0; 
 | 
    } 
 | 
  
 | 
    public static int GetChsCount(string name) 
 | 
    { 
 | 
        var count = 0; 
 | 
        for (int i = 0; i < name.Length; i++) 
 | 
        { 
 | 
            if (Regex.IsMatch(name[i].ToString(), "[\u4e00-\u9fa5]")) 
 | 
            { 
 | 
                count++; 
 | 
            } 
 | 
        } 
 | 
        return count; 
 | 
    } 
 | 
  
 | 
    // public static string GetEquipSuitName(int itemId, bool bright = true) 
 | 
    // { 
 | 
    //     if (ItemLogicUtility.Instance.IsSuitEquip(itemId)) 
 | 
    //     { 
 | 
    //         var itemConfig = ItemConfig.Get(itemId); 
 | 
    //         return AppendColor(TextColType.Green, EquipModel.GetSuitName(itemConfig.LV), bright); 
 | 
    //     } 
 | 
    //     return string.Empty; 
 | 
    // } 
 | 
  
 | 
    // public static string GetItemName(int itmeId, bool bright = true) 
 | 
    // { 
 | 
    //     var itemConfig = ItemConfig.Get(itmeId); 
 | 
    //     if (itemConfig == null) 
 | 
    //     { 
 | 
    //         return string.Empty; 
 | 
    //     } 
 | 
    //     return StringUtility.Contact(GetEquipSuitName(itmeId, bright), itemConfig.ItemName); 
 | 
    // } 
 | 
  
 | 
    public static string GetStar(int star) 
 | 
    { 
 | 
        switch (star) 
 | 
        { 
 | 
            case 5: 
 | 
                return "S"; 
 | 
            case 4: 
 | 
                return "A"; 
 | 
            case 3: 
 | 
                return "B"; 
 | 
            case 2: 
 | 
                return "C"; 
 | 
            case 1: 
 | 
                return "D"; 
 | 
        } 
 | 
        return string.Empty; 
 | 
    } 
 | 
  
 | 
  
 | 
    //转为s1,s2,s3格式 
 | 
    public static string GetServers(string serverIDRangeInfo) 
 | 
    { 
 | 
        var serverList = new List<string>(); 
 | 
        if (string.IsNullOrEmpty(serverIDRangeInfo) || serverIDRangeInfo == "[]") 
 | 
        { 
 | 
            return "all"; 
 | 
        } 
 | 
  
 | 
        var serverArray = JsonMapper.ToObject<int[][]>(serverIDRangeInfo); 
 | 
  
 | 
        for (int i = 0; i < serverArray.Length; i++) 
 | 
        { 
 | 
            int startID = serverArray[i][0]; 
 | 
            int endID = serverArray[i][1]; 
 | 
            for (int j = startID; j <= endID; j++) 
 | 
            { 
 | 
                var serverName = ServerListCenter.Instance.GetServerName(j); 
 | 
                serverList.Add(serverName); 
 | 
                //太长会导致界面顶点数超过65000 
 | 
                if (serverList.Count > 1000) 
 | 
                    return string.Join(", ", serverList.ToArray()); 
 | 
            } 
 | 
        } 
 | 
        return string.Join(", ", serverList.ToArray()); 
 | 
    } 
 | 
  
 | 
    //不同版本现金的单位不一样,比如越南盾是整数,下发是原值;美元和RMB是小数,下发是原值的100 
 | 
    public static float GetRealCoin(int money, float scale = 100.0f) 
 | 
    { 
 | 
        return money / scale; 
 | 
    } 
 | 
  
 | 
  
 | 
    public static string RemoveColor(string content) 
 | 
    { 
 | 
        content = WordAnalysis.Color_Start_Regex.Replace(content, string.Empty); 
 | 
        content = WordAnalysis.Color_End_Regex.Replace(content, string.Empty); 
 | 
        return content; 
 | 
    } 
 | 
  
 | 
    //复制到剪贴板 
 | 
    // TODO 暂不支持web后续补充 
 | 
    public static void CopyToClipboard(string text) 
 | 
    { 
 | 
        GUIUtility.systemCopyBuffer = text; 
 | 
        Debug.Log("文字已复制到剪贴板: " + text); 
 | 
    } 
 | 
     
 | 
    //获取剪切板内容 
 | 
    public static string GetClipboardText() 
 | 
    { 
 | 
        return GUIUtility.systemCopyBuffer; 
 | 
    } 
 | 
     
 | 
} 
 |