| | |
| | | using System; |
| | | using System.Text; |
| | | using UnityEngine; |
| | | using System.Linq; |
| | | using System.Xml.Linq; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine.UI; |
| | | using TableConfig; |
| | | using System.Text.RegularExpressions; |
| | | using System.IO; |
| | | using Snxxz.UI; |
| | | |
| | | /// <summary> |
| | | /// UI辅助类 |
| | | /// </summary> |
| | | public static class UIHelper |
| | | { |
| | | #region UI通用 |
| | | public static void SetIconWithMoneyType(this Image _image, int moneyType) |
| | | { |
| | | if (_image == null) return; |
| | | string iconKey = StringUtility.Contact("Money_Type_", moneyType); |
| | | _image.SetSprite(iconKey); |
| | | } |
| | | |
| | | /// <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; |
| | | |
| | | } |
| | | |
| | | public static void SetItemBackGround(this Image _image, int itemColor) |
| | | { |
| | | if (_image == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | switch (itemColor) |
| | | { |
| | | case 0: |
| | | _image.SetSprite("Common_Public_ItemNormalBG"); |
| | | break; |
| | | case 1: |
| | | _image.SetSprite("Common_Public_ItemNormalBG"); |
| | | break; |
| | | case 2: |
| | | _image.SetSprite("Common_Public_ItemBlueBG"); |
| | | break; |
| | | case 3: |
| | | _image.SetSprite("Common_Public_ItemPurpleBG"); |
| | | break; |
| | | case 5: |
| | | _image.SetSprite("Common_Public_ItemRedBG"); |
| | | break; |
| | | case 4: |
| | | _image.SetSprite("Common_Public_ItemOrangeBG"); |
| | | break; |
| | | case 6: |
| | | _image.SetSprite("Common_Public_ItemPinkBG"); |
| | | break; |
| | | } |
| | | } |
| | | /// <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="type"></param> |
| | | /// <returns></returns> |
| | | public static float GetPropertyMapPlayerData(AttrEnum type) |
| | | { |
| | | switch (type) |
| | | { |
| | | case AttrEnum.LV: |
| | | return PlayerDatas.Instance.baseData.LV; |
| | | case AttrEnum.POWER: |
| | | return PlayerDatas.Instance.baseData.STR; |
| | | case AttrEnum.AGILITY: |
| | | return PlayerDatas.Instance.baseData.PHY; |
| | | case AttrEnum.PHYSIQUE: |
| | | return PlayerDatas.Instance.baseData.CON; |
| | | case AttrEnum.MENTALITY: |
| | | return PlayerDatas.Instance.baseData.PNE; |
| | | case AttrEnum.HP: |
| | | return (int)PlayerDatas.Instance.extersion.MaxHP; |
| | | case AttrEnum.ATK: |
| | | return PlayerDatas.Instance.extersion.MAXATK; |
| | | case AttrEnum.DEF: |
| | | return PlayerDatas.Instance.extersion.DEF; |
| | | case AttrEnum.HIT: |
| | | return PlayerDatas.Instance.extersion.HIT; |
| | | case AttrEnum.MISS: |
| | | return PlayerDatas.Instance.extersion.Miss; |
| | | case AttrEnum.ATKSPEED: |
| | | return PlayerDatas.Instance.extersion.battleValEx1; |
| | | case AttrEnum.CritChance: |
| | | return PlayerDatas.Instance.extersion.SuperHitRate; |
| | | case AttrEnum.CritHurt: |
| | | return PlayerDatas.Instance.extersion.SuperHit; |
| | | case AttrEnum.CritResis: |
| | | return PlayerDatas.Instance.extersion.SuperHitReduce; |
| | | case AttrEnum.HeartHit: |
| | | return PlayerDatas.Instance.extersion.luckHitRate; |
| | | case AttrEnum.HeartHurt: |
| | | return PlayerDatas.Instance.extersion.luckHitVal; |
| | | case AttrEnum.HeartResis: |
| | | return PlayerDatas.Instance.extersion.LuckyHitRateReduce; |
| | | case AttrEnum.SkillHurt: |
| | | return PlayerDatas.Instance.extersion.SkillAtkRate; |
| | | case AttrEnum.AddHurt: |
| | | return PlayerDatas.Instance.extersion.DamagePer; |
| | | case AttrEnum.ReduceHurt: |
| | | return PlayerDatas.Instance.extersion.damageReduceRate; |
| | | case AttrEnum.LifeReply: |
| | | return PlayerDatas.Instance.extersion.HPRestorePer; |
| | | case AttrEnum.HurtReflect: |
| | | return PlayerDatas.Instance.extersion.DamageBackRate; |
| | | case AttrEnum.MoveSpeed: |
| | | return PlayerDatas.Instance.extersion.SpeedValue; |
| | | case AttrEnum.PetAddHurt: |
| | | return PlayerDatas.Instance.extersion.PetDamPer; |
| | | case AttrEnum.RealHurt: |
| | | return PlayerDatas.Instance.extersion.realATK; |
| | | case AttrEnum.RealResis: |
| | | return PlayerDatas.Instance.extersion.realDEF; |
| | | case AttrEnum.DefyDef: |
| | | return PlayerDatas.Instance.extersion.IgnoreDefRate; |
| | | case AttrEnum.DefyDefResis: |
| | | return PlayerDatas.Instance.extersion.IgnoreDefRateReduce; |
| | | case AttrEnum.DefChance: |
| | | return PlayerDatas.Instance.extersion.DamChanceDef; |
| | | case AttrEnum.BloodHurt: |
| | | return PlayerDatas.Instance.extersion.BleedDamage; |
| | | case AttrEnum.AktReplyBlood: |
| | | return PlayerDatas.Instance.extersion.BattleValEx2; |
| | | case AttrEnum.Stun: |
| | | return PlayerDatas.Instance.extersion.FaintRate; |
| | | case AttrEnum.CtrlResis: |
| | | return PlayerDatas.Instance.extersion.FaintDefRate; |
| | | case AttrEnum.OutHurt: |
| | | return PlayerDatas.Instance.extersion.FinalHurt; |
| | | case AttrEnum.ReduceBearHurt: |
| | | return PlayerDatas.Instance.extersion.FinalHurtReduce; |
| | | case AttrEnum.PVPAddHurt: |
| | | return PlayerDatas.Instance.extersion.DamagePerPVP; |
| | | case AttrEnum.PVPReduceHurt: |
| | | return PlayerDatas.Instance.extersion.DamagePerPVPReduce; |
| | | case AttrEnum.DleHitChance: |
| | | return PlayerDatas.Instance.extersion.ComboDamPerRate; |
| | | case AttrEnum.DleHurt: |
| | | return PlayerDatas.Instance.extersion.ComboDamPer; |
| | | case AttrEnum.SkillHurtPrecent: |
| | | return PlayerDatas.Instance.extersion.skillAtkRateReduce; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | /// <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"); |
| | | } |
| | | /// <summary> |
| | | /// 大数值转化 |
| | | /// </summary> |
| | | private static StringBuilder _textBuilder = new StringBuilder(); |
| | | public static string ReplaceLargeNum(double num) |
| | | { |
| | | _textBuilder.Length = 0; |
| | | float hm = (float)Math.Round(num / 100000000, 2); |
| | | if(hm >= 100) |
| | | { |
| | | hm = (int)Math.Round(num / 100000000); |
| | | _textBuilder.Append(hm); |
| | | _textBuilder.Append(Language.Get("L1070")); |
| | | return _textBuilder.ToString(); |
| | | } |
| | | else if(hm >= 10) |
| | | { |
| | | hm = (float)Math.Round(num / 100000000,1); |
| | | _textBuilder.Append(hm); |
| | | _textBuilder.Append(Language.Get("L1070")); |
| | | return _textBuilder.ToString(); |
| | | } |
| | | if (hm >= 1) |
| | | { |
| | | _textBuilder.Append(hm); |
| | | _textBuilder.Append(Language.Get("L1070")); |
| | | return _textBuilder.ToString(); |
| | | } |
| | | |
| | | float tt = (float)Math.Round(num / 10000, 2); |
| | | if (tt >= 100) |
| | | { |
| | | tt = (float)Math.Round(num / 10000); |
| | | _textBuilder.Append(tt); |
| | | _textBuilder.Append(Language.Get("L1071")); |
| | | return _textBuilder.ToString(); |
| | | } |
| | | else if(tt >= 10) |
| | | { |
| | | tt = (float)Math.Round(num / 10000,1); |
| | | _textBuilder.Append(tt); |
| | | _textBuilder.Append(Language.Get("L1071")); |
| | | return _textBuilder.ToString(); |
| | | } |
| | | else if(tt >= 1) |
| | | { |
| | | _textBuilder.Append(tt); |
| | | _textBuilder.Append(Language.Get("L1071")); |
| | | return _textBuilder.ToString(); |
| | | } |
| | | |
| | | if (_textBuilder.Length == 0) |
| | | { |
| | | tt = (float)Math.Round(num,2); |
| | | _textBuilder.Append(tt); |
| | | } |
| | | return _textBuilder.ToString(); |
| | | } |
| | | |
| | | public static float ReplacePercentage(float num, int isPer) |
| | | { |
| | | if (isPer == 1 || isPer == 2) |
| | | { |
| | | return (float)Math.Round(num / 100, 1); |
| | | } |
| | | else |
| | | { |
| | | return (int)num; |
| | | } |
| | | } |
| | | |
| | | private const string SPECIAL_CHA = " ()()@!#$%^&*[]|_"; |
| | | public static bool HasSpecialCharac(string str) |
| | | { |
| | | foreach (char c in SPECIAL_CHA) |
| | | { |
| | | if (str.Contains(c)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | 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: |
| | | return Language.Get("Market_Text_47"); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 文字色值 |
| | | public static readonly Color32 s_BrightPinkColor = new Color32(246, 64, 141, 255); |
| | | public static readonly Color32 s_BrightRedColor = new Color32(255, 3, 3, 255); |
| | | public static readonly Color32 s_BrightPurpleColor = new Color32(218, 72, 213, 255); |
| | | public static readonly Color32 s_BrightBlueColor = new Color32(0, 107, 227, 255); |
| | | public static readonly Color32 s_BrightOrangeColor = new Color32(255, 103, 1, 255); |
| | | public static readonly Color32 s_BrightWhiteColor = new Color32(104, 104, 104, 255); |
| | | public static readonly Color32 s_BrightGreenColor = new Color32(16, 157, 6, 255); |
| | | |
| | | public static readonly Color32 s_DarkPinkColor = new Color32(255, 124, 124, 255); |
| | | public static readonly Color32 s_DarkRedColor = new Color32(250, 1, 1, 255); |
| | | public static readonly Color32 s_DarkPurpleColor = new Color32(236, 75, 246, 255); |
| | | public static readonly Color32 s_DarkBlueColor = new Color32(49, 206, 251, 255); |
| | | public static readonly Color32 s_DarkOrangeColor = new Color32(248, 152, 59, 255); |
| | | public static readonly Color32 s_DarkWhiteColor = new Color32(247, 247, 247, 255); |
| | | public static readonly Color32 s_DarkGreenColor = new Color32(53, 225, 34, 255); //35e122 |
| | | |
| | | public static readonly Color s_NavyBrown = new Color32(64, 28, 6, 255);//401c06 |
| | | public static readonly Color s_Black = new Color32(0, 0, 0, 255); |
| | | public static readonly Color s_NavyYellow = new Color32(255, 239, 71, 255); |
| | | public static readonly Color s_LightGreen = new Color32(141, 220, 17, 255); |
| | | public static readonly Color s_LightYellow = new Color32(255, 244, 205, 255); //fff4cd |
| | | public static Color GetUIColor(int itemColor, bool bright = false) |
| | | { |
| | | switch (itemColor) |
| | | { |
| | | case 0: |
| | | return GetUIColor(TextColType.White, bright); |
| | | case 1: |
| | | return GetUIColor(TextColType.White, bright); |
| | | case 2: |
| | | return GetUIColor(TextColType.Blue, bright); |
| | | case 3: |
| | | return GetUIColor(TextColType.Purple, bright); |
| | | case 4: |
| | | return GetUIColor(TextColType.Orange, bright); |
| | | case 5: |
| | | return GetUIColor(TextColType.Red, bright); |
| | | case 6: |
| | | return GetUIColor(TextColType.Pink, bright); |
| | | } |
| | | return GetUIColor(TextColType.White, bright); |
| | | } |
| | | public static Color GetUIColor(TextColType type, bool bright = false) |
| | | { |
| | | switch (type) |
| | | { |
| | | case TextColType.None: |
| | | case TextColType.White: |
| | | return bright ? s_BrightWhiteColor : s_DarkWhiteColor; |
| | | case TextColType.Blue: |
| | | return bright ? s_BrightBlueColor : s_DarkBlueColor; |
| | | case TextColType.Purple: |
| | | return bright ? s_BrightPurpleColor : s_DarkPurpleColor; |
| | | case TextColType.Orange: |
| | | return bright ? s_BrightOrangeColor : s_DarkOrangeColor; |
| | | 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.NavyYellow: |
| | | return s_NavyYellow; |
| | | case TextColType.LightGreen: |
| | | return s_LightGreen; |
| | | case TextColType.LightYellow: |
| | | return s_LightYellow; |
| | | } |
| | | return bright ? s_BrightWhiteColor : s_DarkWhiteColor; |
| | | } |
| | | private static Regex m_TextColorRegex = new Regex("<color=#[0-9a-zA-Z]+>(.*)</color>", RegexOptions.Singleline); |
| | | |
| | | public static string GetTextColorByItemColor(TextColType type, string msg, bool bright = false) |
| | | { |
| | | if (m_TextColorRegex.IsMatch(msg)) |
| | | { |
| | | Match match = m_TextColorRegex.Match(msg); |
| | | msg = match.Groups[1].Value; |
| | | } |
| | | switch (type) |
| | | { |
| | | case TextColType.None: |
| | | case TextColType.White: |
| | | return StringUtility.Contact("<color=#", bright ? "686868" : "f7f7f7", ">", msg, "</color>"); |
| | | case TextColType.Blue: |
| | | return StringUtility.Contact("<color=#", bright ? "006be3" : "31cefb", ">", msg, "</color>"); |
| | | case TextColType.Purple: |
| | | return StringUtility.Contact("<color=#", bright ? "da48d5" : "ec4bf6", ">", msg, "</color>"); |
| | | case TextColType.Orange: |
| | | return StringUtility.Contact("<color=#", bright ? "ff6701" : "f8983b", ">", msg, "</color>"); |
| | | case TextColType.Red: |
| | | return StringUtility.Contact("<color=#", bright ? "ff0303" : "ff0101", ">", msg, "</color>"); |
| | | case TextColType.Pink: |
| | | return StringUtility.Contact("<color=#", bright ? "f6408d" : "ff7c7c", ">", msg, "</color>"); |
| | | case TextColType.Green: |
| | | return StringUtility.Contact("<color=#", bright ? "109d06" : "35e122", ">", msg, "</color>"); |
| | | case TextColType.NavyBrown: |
| | | return StringUtility.Contact("<color=#", "401c06", ">", msg, "</color>"); |
| | | case TextColType.DarkGreen: |
| | | return StringUtility.Contact("<color=#", "109d06", ">", msg, "</color>"); |
| | | case TextColType.Black: |
| | | return StringUtility.Contact("<color=#", "000000", ">", msg, "</color>"); |
| | | case TextColType.LightYellow: |
| | | return StringUtility.Contact("<color=#", "fff4cd", ">", msg, "</color>"); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | public static string GetTextColorByItemColor(int itemColor, string msg, bool bright = false) |
| | | { |
| | | switch (itemColor) |
| | | { |
| | | case 0: |
| | | case 1: |
| | | return GetTextColorByItemColor(TextColType.White, msg, bright); |
| | | case 2: |
| | | return GetTextColorByItemColor(TextColType.Blue, msg, bright); |
| | | case 3: |
| | | return GetTextColorByItemColor(TextColType.Purple, msg, bright); |
| | | case 4: |
| | | return GetTextColorByItemColor(TextColType.Orange, msg, bright); |
| | | case 5: |
| | | return GetTextColorByItemColor(TextColType.Red, msg, bright); |
| | | case 6: |
| | | return GetTextColorByItemColor(TextColType.Pink, msg, bright); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | public static int GetItemColor(int _id, Dictionary<int, List<int>> _dict = null) |
| | | { |
| | | int _itemColor = 0; |
| | | var _itemCfg = ConfigManager.Instance.GetTemplate<ItemConfig>(_id); |
| | | if (_itemCfg != null) |
| | | { |
| | | _itemColor = _itemCfg.ItemColor; |
| | | if (_itemCfg.Type == 111 && _dict != null) |
| | | { |
| | | _itemColor = ModelCenter.Instance.GetModel<PackModelInterface>().GetItemQuality(_itemCfg.ID, _dict); |
| | | } |
| | | } |
| | | return _itemColor; |
| | | } |
| | | #endregion |
| | | |
| | | #region 计算战斗力 |
| | | public static readonly string FightPowerFormula = "FightpowerFormula"; |
| | | public static uint GetFightPower(params int[] paraArray) |
| | | { |
| | | Equation.Instance.Clear(); |
| | | if (paraArray == null || paraArray.Length < 2 || paraArray.Length % 2 != 0) return 0; |
| | | for (int i = 0; i < paraArray.Length; i += 2) |
| | | { |
| | | PlayerPropertyConfig cfg = ConfigManager.Instance.GetTemplate<PlayerPropertyConfig>(paraArray[i]); |
| | | if (cfg != null) |
| | | { |
| | | if (paraArray[i] == 7) |
| | | { |
| | | Equation.Instance.AddKeyValue("MinAtk", paraArray[i + 1]); |
| | | Equation.Instance.AddKeyValue("MaxAtk", paraArray[i + 1]); |
| | | } |
| | | else |
| | | { |
| | | Equation.Instance.AddKeyValue(cfg.Parameter, paraArray[i + 1]); |
| | | } |
| | | } |
| | | } |
| | | FuncConfigConfig funcCfg = ConfigManager.Instance.GetTemplate<FuncConfigConfig>(FightPowerFormula); |
| | | return Equation.Instance.Eval<uint>(funcCfg.Numerical1); |
| | | } |
| | | public static int GetFightPower(Dictionary<int, int> _propertyDict) |
| | | { |
| | | Equation.Instance.Clear(); |
| | | if (_propertyDict == null || _propertyDict.Count == 0) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | foreach (var _key in _propertyDict.Keys) |
| | | { |
| | | PlayerPropertyConfig cfg = ConfigManager.Instance.GetTemplate<PlayerPropertyConfig>(_key); |
| | | if (cfg != null) |
| | | { |
| | | if (_key == 7) |
| | | { |
| | | Equation.Instance.AddKeyValue("MinAtk", _propertyDict[_key]); |
| | | Equation.Instance.AddKeyValue("MaxAtk", _propertyDict[_key]); |
| | | } |
| | | else |
| | | { |
| | | int attrValue = _propertyDict[_key]; |
| | | int fightParm = GetFightPowerParmByAttrId(_key); |
| | | if(_key == 11) |
| | | { |
| | | int playerLv = PlayerDatas.Instance.baseData.LV; |
| | | FightPowerParamConfig paramConfig = ConfigManager.Instance.GetTemplate<FightPowerParamConfig>(playerLv); |
| | | Equation.Instance.AddKeyValue("AtkSpeedParameter", paramConfig.AtkSpeedParameter); |
| | | } |
| | | else if(_key == 15) |
| | | { |
| | | int playerLv = PlayerDatas.Instance.baseData.LV; |
| | | FightPowerParamConfig paramConfig = ConfigManager.Instance.GetTemplate<FightPowerParamConfig>(playerLv); |
| | | Equation.Instance.AddKeyValue("LuckyHitParameter",paramConfig.LuckyHitParameter); |
| | | } |
| | | else |
| | | { |
| | | if (fightParm != 0) |
| | | { |
| | | attrValue = attrValue * fightParm; |
| | | } |
| | | } |
| | | Equation.Instance.AddKeyValue(cfg.Parameter,attrValue); |
| | | } |
| | | } |
| | | |
| | | } |
| | | FuncConfigConfig funcCfg = ConfigManager.Instance.GetTemplate<FuncConfigConfig>(FightPowerFormula); |
| | | return Equation.Instance.Eval<int>(funcCfg.Numerical1); |
| | | } |
| | | |
| | | public static int GetFightPowerParmByAttrId(int attrId) |
| | | { |
| | | int playerLv = PlayerDatas.Instance.baseData.LV; |
| | | FightPowerParamConfig paramConfig = ConfigManager.Instance.GetTemplate<FightPowerParamConfig>(playerLv); |
| | | PlayerPropertyConfig cfg = ConfigManager.Instance.GetTemplate<PlayerPropertyConfig>(attrId); |
| | | if (paramConfig == null || cfg == null) return 0; |
| | | |
| | | switch(cfg.Parameter) |
| | | { |
| | | case "Hit": |
| | | return paramConfig.Hit; |
| | | case "Miss": |
| | | return paramConfig.Miss; |
| | | case "DamagePer": |
| | | return paramConfig.DamagePer; |
| | | case "DamReduce": |
| | | return paramConfig.DamReduce; |
| | | case "IgnoreDefRate": |
| | | return paramConfig.IgnoreDefRate; |
| | | case "DamChanceDef": |
| | | return paramConfig.DamChanceDef; |
| | | case "BleedDamage": |
| | | return paramConfig.BleedDamage; |
| | | case "FaintRate": |
| | | return paramConfig.FaintRate; |
| | | case "SuperHitReduce": |
| | | return paramConfig.SuperHitReduce; |
| | | case "LuckyHitRateReduce": |
| | | return paramConfig.LuckyHitRateReduce; |
| | | case "SkillAtkRate": |
| | | return paramConfig.SkillAtkRate; |
| | | case "SkillAtkRateReduce": |
| | | return paramConfig.SkillAtkRateReduce; |
| | | case "DamagePerPVP": |
| | | return paramConfig.DamagePerPVP; |
| | | case "DamagePerPVPReduce": |
| | | return paramConfig.DamagePerPVPReduce; |
| | | case "DamBackPer": |
| | | return paramConfig.DamBackPer; |
| | | case "IgnoreDefRateReduce": |
| | | return paramConfig.IgnoreDefRateReduce; |
| | | case "FaintDefRate": |
| | | return paramConfig.FaintDefRate; |
| | | case "AtkSpeedParameter": |
| | | return paramConfig.AtkSpeedParameter; |
| | | case "LuckyHitParameter": |
| | | return paramConfig.LuckyHitParameter; |
| | | |
| | | } |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 得到金钱数量根据金钱类型 |
| | | public static ulong GetMoneyCnt(int moneyType) |
| | | { |
| | | switch (moneyType) |
| | | { |
| | | case 1: |
| | | { |
| | | return PlayerDatas.Instance.baseData.Gold; |
| | | } |
| | | case 2: |
| | | { |
| | | return PlayerDatas.Instance.baseData.GoldPaper; |
| | | } |
| | | case 3: |
| | | { |
| | | return PlayerDatas.Instance.baseData.allSliver; |
| | | } |
| | | case 25: |
| | | { |
| | | return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataRefresh.CDBPlayerRefresh_TreasureScore); |
| | | } |
| | | case 24: |
| | | { |
| | | return (ulong)ModelCenter.Instance.GetModel<RuneModel>().RuneChip; |
| | | } |
| | | case 15: |
| | | { |
| | | return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataRefresh.UnionLiven); |
| | | } |
| | | case 16: |
| | | { |
| | | return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataRefresh.FBHelpPoint); |
| | | } |
| | | } |
| | | return 0; |
| | | } |
| | | #endregion |
| | | |
| | | #region 得到装备位对应的部位名称 |
| | | public static string GetEquipAreaName(int place) |
| | | { |
| | | FuncConfigConfig funcAreaModel = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("EquipArea"); |
| | | int[] placelist = ConfigParse.GetMultipleStr<int>(funcAreaModel.Numerical1); |
| | | string[] namelist = ConfigParse.GetMultipleStr(funcAreaModel.Numerical2); |
| | | int i = 0; |
| | | for (i = 0; i < placelist.Length; i++) |
| | | { |
| | | if (placelist[i] == place) |
| | | { |
| | | return namelist[i]; |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | #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 |
| | | |
| | | #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"; |
| | | } |
| | | } |
| | | using System;
|
| | | using System.Text;
|
| | | using UnityEngine;
|
| | | using System.Linq;
|
| | | using System.Xml.Linq;
|
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using UnityEngine.UI;
|
| | | using TableConfig;
|
| | | using System.Text.RegularExpressions;
|
| | | using System.IO;
|
| | | using Snxxz.UI;
|
| | |
|
| | | /// <summary>
|
| | | /// UI辅助类
|
| | | /// </summary>
|
| | | public static class UIHelper
|
| | | {
|
| | | #region UI通用
|
| | | public static void SetIconWithMoneyType(this Image _image, int moneyType)
|
| | | {
|
| | | if (_image == null) return;
|
| | | string iconKey = StringUtility.Contact("Money_Type_", moneyType);
|
| | | _image.SetSprite(iconKey);
|
| | | }
|
| | |
|
| | | /// <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;
|
| | | |
| | | }
|
| | |
|
| | | public static void SetItemBackGround(this Image _image, int itemColor)
|
| | | {
|
| | | if (_image == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | switch (itemColor)
|
| | | {
|
| | | case 0:
|
| | | _image.SetSprite("Common_Public_ItemNormalBG");
|
| | | break;
|
| | | case 1:
|
| | | _image.SetSprite("Common_Public_ItemNormalBG");
|
| | | break;
|
| | | case 2:
|
| | | _image.SetSprite("Common_Public_ItemBlueBG");
|
| | | break;
|
| | | case 3:
|
| | | _image.SetSprite("Common_Public_ItemPurpleBG");
|
| | | break;
|
| | | case 5:
|
| | | _image.SetSprite("Common_Public_ItemRedBG");
|
| | | break;
|
| | | case 4:
|
| | | _image.SetSprite("Common_Public_ItemOrangeBG");
|
| | | break;
|
| | | case 6:
|
| | | _image.SetSprite("Common_Public_ItemPinkBG");
|
| | | break;
|
| | | }
|
| | | }
|
| | | /// <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="type"></param>
|
| | | /// <returns></returns>
|
| | | public static float GetPropertyMapPlayerData(AttrEnum type)
|
| | | {
|
| | | switch (type)
|
| | | {
|
| | | case AttrEnum.LV:
|
| | | return PlayerDatas.Instance.baseData.LV;
|
| | | case AttrEnum.POWER:
|
| | | return PlayerDatas.Instance.baseData.STR;
|
| | | case AttrEnum.AGILITY:
|
| | | return PlayerDatas.Instance.baseData.PHY;
|
| | | case AttrEnum.PHYSIQUE:
|
| | | return PlayerDatas.Instance.baseData.CON;
|
| | | case AttrEnum.MENTALITY:
|
| | | return PlayerDatas.Instance.baseData.PNE;
|
| | | case AttrEnum.HP:
|
| | | return (int)PlayerDatas.Instance.extersion.MaxHP;
|
| | | case AttrEnum.ATK:
|
| | | return PlayerDatas.Instance.extersion.MAXATK;
|
| | | case AttrEnum.DEF:
|
| | | return PlayerDatas.Instance.extersion.DEF;
|
| | | case AttrEnum.HIT:
|
| | | return PlayerDatas.Instance.extersion.HIT;
|
| | | case AttrEnum.MISS:
|
| | | return PlayerDatas.Instance.extersion.Miss;
|
| | | case AttrEnum.ATKSPEED:
|
| | | return PlayerDatas.Instance.extersion.battleValEx1;
|
| | | case AttrEnum.CritChance:
|
| | | return PlayerDatas.Instance.extersion.SuperHitRate;
|
| | | case AttrEnum.CritHurt:
|
| | | return PlayerDatas.Instance.extersion.SuperHit;
|
| | | case AttrEnum.CritResis:
|
| | | return PlayerDatas.Instance.extersion.SuperHitReduce;
|
| | | case AttrEnum.HeartHit:
|
| | | return PlayerDatas.Instance.extersion.luckHitRate;
|
| | | case AttrEnum.HeartHurt:
|
| | | return PlayerDatas.Instance.extersion.luckHitVal;
|
| | | case AttrEnum.HeartResis:
|
| | | return PlayerDatas.Instance.extersion.LuckyHitRateReduce;
|
| | | case AttrEnum.SkillHurt:
|
| | | return PlayerDatas.Instance.extersion.SkillAtkRate;
|
| | | case AttrEnum.AddHurt:
|
| | | return PlayerDatas.Instance.extersion.DamagePer;
|
| | | case AttrEnum.ReduceHurt:
|
| | | return PlayerDatas.Instance.extersion.damageReduceRate;
|
| | | case AttrEnum.LifeReply:
|
| | | return PlayerDatas.Instance.extersion.HPRestorePer;
|
| | | case AttrEnum.HurtReflect:
|
| | | return PlayerDatas.Instance.extersion.DamageBackRate;
|
| | | case AttrEnum.MoveSpeed:
|
| | | return PlayerDatas.Instance.extersion.SpeedValue;
|
| | | case AttrEnum.PetAddHurt:
|
| | | return PlayerDatas.Instance.extersion.PetDamPer;
|
| | | case AttrEnum.RealHurt:
|
| | | return PlayerDatas.Instance.extersion.realATK;
|
| | | case AttrEnum.RealResis:
|
| | | return PlayerDatas.Instance.extersion.realDEF;
|
| | | case AttrEnum.DefyDef:
|
| | | return PlayerDatas.Instance.extersion.IgnoreDefRate;
|
| | | case AttrEnum.DefyDefResis:
|
| | | return PlayerDatas.Instance.extersion.IgnoreDefRateReduce;
|
| | | case AttrEnum.DefChance:
|
| | | return PlayerDatas.Instance.extersion.DamChanceDef;
|
| | | case AttrEnum.BloodHurt:
|
| | | return PlayerDatas.Instance.extersion.BleedDamage;
|
| | | case AttrEnum.AktReplyBlood:
|
| | | return PlayerDatas.Instance.extersion.BattleValEx2;
|
| | | case AttrEnum.Stun:
|
| | | return PlayerDatas.Instance.extersion.FaintRate;
|
| | | case AttrEnum.CtrlResis:
|
| | | return PlayerDatas.Instance.extersion.FaintDefRate;
|
| | | case AttrEnum.OutHurt:
|
| | | return PlayerDatas.Instance.extersion.FinalHurt;
|
| | | case AttrEnum.ReduceBearHurt:
|
| | | return PlayerDatas.Instance.extersion.FinalHurtReduce;
|
| | | case AttrEnum.PVPAddHurt:
|
| | | return PlayerDatas.Instance.extersion.DamagePerPVP;
|
| | | case AttrEnum.PVPReduceHurt:
|
| | | return PlayerDatas.Instance.extersion.DamagePerPVPReduce;
|
| | | case AttrEnum.DleHitChance:
|
| | | return PlayerDatas.Instance.extersion.ComboDamPerRate;
|
| | | case AttrEnum.DleHurt:
|
| | | return PlayerDatas.Instance.extersion.ComboDamPer;
|
| | | case AttrEnum.SkillHurtPrecent:
|
| | | return PlayerDatas.Instance.extersion.skillAtkRateReduce;
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | |
|
| | | /// <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");
|
| | | }
|
| | | /// <summary>
|
| | | /// 大数值转化
|
| | | /// </summary>
|
| | | private static StringBuilder _textBuilder = new StringBuilder();
|
| | | public static string ReplaceLargeNum(double num)
|
| | | {
|
| | | _textBuilder.Length = 0;
|
| | | float hm = (float)Math.Round(num / 100000000, 2);
|
| | | if(hm >= 100)
|
| | | {
|
| | | hm = (int)Math.Round(num / 100000000);
|
| | | _textBuilder.Append(hm);
|
| | | _textBuilder.Append(Language.Get("L1070"));
|
| | | return _textBuilder.ToString();
|
| | | }
|
| | | else if(hm >= 10)
|
| | | {
|
| | | hm = (float)Math.Round(num / 100000000,1);
|
| | | _textBuilder.Append(hm);
|
| | | _textBuilder.Append(Language.Get("L1070"));
|
| | | return _textBuilder.ToString();
|
| | | }
|
| | | if (hm >= 1)
|
| | | {
|
| | | _textBuilder.Append(hm);
|
| | | _textBuilder.Append(Language.Get("L1070"));
|
| | | return _textBuilder.ToString();
|
| | | }
|
| | | |
| | | float tt = (float)Math.Round(num / 10000, 2);
|
| | | if (tt >= 100)
|
| | | {
|
| | | tt = (float)Math.Round(num / 10000);
|
| | | _textBuilder.Append(tt);
|
| | | _textBuilder.Append(Language.Get("L1071"));
|
| | | return _textBuilder.ToString();
|
| | | }
|
| | | else if(tt >= 10)
|
| | | {
|
| | | tt = (float)Math.Round(num / 10000,1);
|
| | | _textBuilder.Append(tt);
|
| | | _textBuilder.Append(Language.Get("L1071"));
|
| | | return _textBuilder.ToString();
|
| | | }
|
| | | else if(tt >= 1)
|
| | | {
|
| | | _textBuilder.Append(tt);
|
| | | _textBuilder.Append(Language.Get("L1071"));
|
| | | return _textBuilder.ToString();
|
| | | }
|
| | |
|
| | | if (_textBuilder.Length == 0)
|
| | | {
|
| | | tt = (float)Math.Round(num,2);
|
| | | _textBuilder.Append(tt);
|
| | | }
|
| | | return _textBuilder.ToString();
|
| | | }
|
| | |
|
| | | public static float ReplacePercentage(float num, int isPer)
|
| | | {
|
| | | if (isPer == 1 || isPer == 2)
|
| | | {
|
| | | return (float)Math.Round(num / 100, 1);
|
| | | }
|
| | | else
|
| | | {
|
| | | return (int)num;
|
| | | }
|
| | | }
|
| | |
|
| | | private const string SPECIAL_CHA = " ()()@!#$%^&*[]|_";
|
| | | public static bool HasSpecialCharac(string str)
|
| | | {
|
| | | foreach (char c in SPECIAL_CHA)
|
| | | {
|
| | | if (str.Contains(c))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | 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:
|
| | | return Language.Get("Market_Text_47");
|
| | | }
|
| | | return "";
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region 文字色值
|
| | | public static readonly Color32 s_BrightPinkColor = new Color32(246, 64, 141, 255);
|
| | | public static readonly Color32 s_BrightRedColor = new Color32(255, 3, 3, 255);
|
| | | public static readonly Color32 s_BrightPurpleColor = new Color32(218, 72, 213, 255);
|
| | | public static readonly Color32 s_BrightBlueColor = new Color32(0, 107, 227, 255);
|
| | | public static readonly Color32 s_BrightOrangeColor = new Color32(255, 103, 1, 255);
|
| | | public static readonly Color32 s_BrightWhiteColor = new Color32(104, 104, 104, 255);
|
| | | public static readonly Color32 s_BrightGreenColor = new Color32(16, 157, 6, 255);
|
| | |
|
| | | public static readonly Color32 s_DarkPinkColor = new Color32(255, 124, 124, 255);
|
| | | public static readonly Color32 s_DarkRedColor = new Color32(250, 1, 1, 255);
|
| | | public static readonly Color32 s_DarkPurpleColor = new Color32(236, 75, 246, 255);
|
| | | public static readonly Color32 s_DarkBlueColor = new Color32(49, 206, 251, 255);
|
| | | public static readonly Color32 s_DarkOrangeColor = new Color32(248, 152, 59, 255);
|
| | | public static readonly Color32 s_DarkWhiteColor = new Color32(247, 247, 247, 255);
|
| | | public static readonly Color32 s_DarkGreenColor = new Color32(53, 225, 34, 255); //35e122
|
| | |
|
| | | public static readonly Color s_NavyBrown = new Color32(64, 28, 6, 255);//401c06
|
| | | public static readonly Color s_Black = new Color32(0, 0, 0, 255);
|
| | | public static readonly Color s_NavyYellow = new Color32(255, 239, 71, 255);
|
| | | public static readonly Color s_LightGreen = new Color32(141, 220, 17, 255);
|
| | | public static readonly Color s_LightYellow = new Color32(255, 244, 205, 255); //fff4cd
|
| | | public static Color GetUIColor(int itemColor, bool bright = false)
|
| | | {
|
| | | switch (itemColor)
|
| | | {
|
| | | case 0:
|
| | | return GetUIColor(TextColType.White, bright);
|
| | | case 1:
|
| | | return GetUIColor(TextColType.White, bright);
|
| | | case 2:
|
| | | return GetUIColor(TextColType.Blue, bright);
|
| | | case 3:
|
| | | return GetUIColor(TextColType.Purple, bright);
|
| | | case 4:
|
| | | return GetUIColor(TextColType.Orange, bright);
|
| | | case 5:
|
| | | return GetUIColor(TextColType.Red, bright);
|
| | | case 6:
|
| | | return GetUIColor(TextColType.Pink, bright);
|
| | | }
|
| | | return GetUIColor(TextColType.White, bright);
|
| | | }
|
| | | public static Color GetUIColor(TextColType type, bool bright = false)
|
| | | {
|
| | | switch (type)
|
| | | {
|
| | | case TextColType.None:
|
| | | case TextColType.White:
|
| | | return bright ? s_BrightWhiteColor : s_DarkWhiteColor;
|
| | | case TextColType.Blue:
|
| | | return bright ? s_BrightBlueColor : s_DarkBlueColor;
|
| | | case TextColType.Purple:
|
| | | return bright ? s_BrightPurpleColor : s_DarkPurpleColor;
|
| | | case TextColType.Orange:
|
| | | return bright ? s_BrightOrangeColor : s_DarkOrangeColor;
|
| | | 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.NavyYellow:
|
| | | return s_NavyYellow;
|
| | | case TextColType.LightGreen:
|
| | | return s_LightGreen;
|
| | | case TextColType.LightYellow:
|
| | | return s_LightYellow;
|
| | | }
|
| | | return bright ? s_BrightWhiteColor : s_DarkWhiteColor;
|
| | | }
|
| | | private static Regex m_TextColorRegex = new Regex("<color=#[0-9a-zA-Z]+>(.*)</color>", RegexOptions.Singleline);
|
| | |
|
| | | public static string GetTextColorByItemColor(TextColType type, string msg, bool bright = false)
|
| | | {
|
| | | if (m_TextColorRegex.IsMatch(msg))
|
| | | {
|
| | | Match match = m_TextColorRegex.Match(msg);
|
| | | msg = match.Groups[1].Value;
|
| | | }
|
| | | switch (type)
|
| | | {
|
| | | case TextColType.None:
|
| | | case TextColType.White:
|
| | | return StringUtility.Contact("<color=#", bright ? "686868" : "f7f7f7", ">", msg, "</color>");
|
| | | case TextColType.Blue:
|
| | | return StringUtility.Contact("<color=#", bright ? "006be3" : "31cefb", ">", msg, "</color>");
|
| | | case TextColType.Purple:
|
| | | return StringUtility.Contact("<color=#", bright ? "da48d5" : "ec4bf6", ">", msg, "</color>");
|
| | | case TextColType.Orange:
|
| | | return StringUtility.Contact("<color=#", bright ? "ff6701" : "f8983b", ">", msg, "</color>");
|
| | | case TextColType.Red:
|
| | | return StringUtility.Contact("<color=#", bright ? "ff0303" : "ff0101", ">", msg, "</color>");
|
| | | case TextColType.Pink:
|
| | | return StringUtility.Contact("<color=#", bright ? "f6408d" : "ff7c7c", ">", msg, "</color>");
|
| | | case TextColType.Green:
|
| | | return StringUtility.Contact("<color=#", bright ? "109d06" : "35e122", ">", msg, "</color>");
|
| | | case TextColType.NavyBrown:
|
| | | return StringUtility.Contact("<color=#", "401c06", ">", msg, "</color>");
|
| | | case TextColType.DarkGreen:
|
| | | return StringUtility.Contact("<color=#", "109d06", ">", msg, "</color>");
|
| | | case TextColType.Black:
|
| | | return StringUtility.Contact("<color=#", "000000", ">", msg, "</color>");
|
| | | case TextColType.LightYellow:
|
| | | return StringUtility.Contact("<color=#", "fff4cd", ">", msg, "</color>");
|
| | | }
|
| | | return msg;
|
| | | }
|
| | |
|
| | | public static string GetRealmName(int realmLv, bool bright = false)
|
| | | {
|
| | | var config = ConfigManager.Instance.GetTemplate<RealmConfig>(realmLv);
|
| | | if (config == null)
|
| | | {
|
| | | return string.Empty;
|
| | | }
|
| | | switch (config.Quality)
|
| | | {
|
| | | case 1:
|
| | | return StringUtility.Contact("<color=#", bright ? "686868" : "f7f7f7", ">", config.Name, "</color>");
|
| | | case 2:
|
| | | return StringUtility.Contact("<color=#", bright ? "08d00a" : "08d00a", ">", config.Name, "</color>");
|
| | | case 3:
|
| | | return StringUtility.Contact("<color=#", bright ? "006be3" : "31cefb", ">", config.Name, "</color>");
|
| | | case 4:
|
| | | return StringUtility.Contact("<color=#", bright ? "da48d5" : "ec4bf6", ">", config.Name, "</color>");
|
| | | case 5:
|
| | | return StringUtility.Contact("<color=#", bright ? "ff6701" : "f8983b", ">", config.Name, "</color>");
|
| | | case 6:
|
| | | return StringUtility.Contact("<color=#", bright ? "ff0303" : "ff0101", ">", config.Name, "</color>");
|
| | | case 7:
|
| | | return StringUtility.Contact("<color=#", bright ? "f6408d" : "ff7c7c", ">", config.Name, "</color>");
|
| | | case 8:
|
| | | return StringUtility.Contact("<color=#", bright ? "bb8800" : "ffde00", ">", config.Name, "</color>");
|
| | | case 9:
|
| | | return StringUtility.Contact("<color=#", bright ? "ff0303" : "ff0101", ">", config.Name, "</color>");
|
| | | default:
|
| | | return config.Name;
|
| | | }
|
| | | }
|
| | |
|
| | | public static string GetTextColorByItemColor(int itemColor, string msg, bool bright = false)
|
| | | {
|
| | | switch (itemColor)
|
| | | {
|
| | | case 0:
|
| | | case 1:
|
| | | return GetTextColorByItemColor(TextColType.White, msg, bright);
|
| | | case 2:
|
| | | return GetTextColorByItemColor(TextColType.Blue, msg, bright);
|
| | | case 3:
|
| | | return GetTextColorByItemColor(TextColType.Purple, msg, bright);
|
| | | case 4:
|
| | | return GetTextColorByItemColor(TextColType.Orange, msg, bright);
|
| | | case 5:
|
| | | return GetTextColorByItemColor(TextColType.Red, msg, bright);
|
| | | case 6:
|
| | | return GetTextColorByItemColor(TextColType.Pink, msg, bright);
|
| | | }
|
| | | return msg;
|
| | | }
|
| | |
|
| | | public static int GetItemColor(int _id, Dictionary<int, List<int>> _dict = null)
|
| | | {
|
| | | int _itemColor = 0;
|
| | | var _itemCfg = ConfigManager.Instance.GetTemplate<ItemConfig>(_id);
|
| | | if (_itemCfg != null)
|
| | | {
|
| | | _itemColor = _itemCfg.ItemColor;
|
| | | if (_itemCfg.Type == 111 && _dict != null)
|
| | | {
|
| | | _itemColor = ModelCenter.Instance.GetModel<PackModelInterface>().GetItemQuality(_itemCfg.ID, _dict);
|
| | | }
|
| | | }
|
| | | return _itemColor;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region 计算战斗力
|
| | | public static readonly string FightPowerFormula = "FightpowerFormula";
|
| | | public static uint GetFightPower(params int[] paraArray)
|
| | | {
|
| | | Equation.Instance.Clear();
|
| | | if (paraArray == null || paraArray.Length < 2 || paraArray.Length % 2 != 0) return 0;
|
| | | for (int i = 0; i < paraArray.Length; i += 2)
|
| | | {
|
| | | PlayerPropertyConfig cfg = ConfigManager.Instance.GetTemplate<PlayerPropertyConfig>(paraArray[i]);
|
| | | if (cfg != null)
|
| | | {
|
| | | if (paraArray[i] == 7)
|
| | | {
|
| | | Equation.Instance.AddKeyValue("MinAtk", paraArray[i + 1]);
|
| | | Equation.Instance.AddKeyValue("MaxAtk", paraArray[i + 1]);
|
| | | }
|
| | | else
|
| | | {
|
| | | Equation.Instance.AddKeyValue(cfg.Parameter, paraArray[i + 1]);
|
| | | }
|
| | | }
|
| | | }
|
| | | FuncConfigConfig funcCfg = ConfigManager.Instance.GetTemplate<FuncConfigConfig>(FightPowerFormula);
|
| | | return Equation.Instance.Eval<uint>(funcCfg.Numerical1);
|
| | | }
|
| | | public static int GetFightPower(Dictionary<int, int> _propertyDict)
|
| | | {
|
| | | Equation.Instance.Clear();
|
| | | if (_propertyDict == null || _propertyDict.Count == 0)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | | |
| | | foreach (var _key in _propertyDict.Keys)
|
| | | {
|
| | | PlayerPropertyConfig cfg = ConfigManager.Instance.GetTemplate<PlayerPropertyConfig>(_key);
|
| | | if (cfg != null)
|
| | | {
|
| | | if (_key == 7)
|
| | | {
|
| | | Equation.Instance.AddKeyValue("MinAtk", _propertyDict[_key]);
|
| | | Equation.Instance.AddKeyValue("MaxAtk", _propertyDict[_key]);
|
| | | }
|
| | | else
|
| | | {
|
| | | int attrValue = _propertyDict[_key];
|
| | | int fightParm = GetFightPowerParmByAttrId(_key);
|
| | | if(_key == 11)
|
| | | {
|
| | | int playerLv = PlayerDatas.Instance.baseData.LV;
|
| | | FightPowerParamConfig paramConfig = ConfigManager.Instance.GetTemplate<FightPowerParamConfig>(playerLv);
|
| | | Equation.Instance.AddKeyValue("AtkSpeedParameter", paramConfig.AtkSpeedParameter);
|
| | | }
|
| | | else if(_key == 15)
|
| | | {
|
| | | int playerLv = PlayerDatas.Instance.baseData.LV;
|
| | | FightPowerParamConfig paramConfig = ConfigManager.Instance.GetTemplate<FightPowerParamConfig>(playerLv);
|
| | | Equation.Instance.AddKeyValue("LuckyHitParameter",paramConfig.LuckyHitParameter);
|
| | | }
|
| | | else
|
| | | {
|
| | | if (fightParm != 0)
|
| | | {
|
| | | attrValue = attrValue * fightParm;
|
| | | }
|
| | | }
|
| | | Equation.Instance.AddKeyValue(cfg.Parameter,attrValue);
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | | FuncConfigConfig funcCfg = ConfigManager.Instance.GetTemplate<FuncConfigConfig>(FightPowerFormula);
|
| | | return Equation.Instance.Eval<int>(funcCfg.Numerical1);
|
| | | }
|
| | |
|
| | | public static int GetFightPowerParmByAttrId(int attrId)
|
| | | {
|
| | | int playerLv = PlayerDatas.Instance.baseData.LV;
|
| | | FightPowerParamConfig paramConfig = ConfigManager.Instance.GetTemplate<FightPowerParamConfig>(playerLv);
|
| | | PlayerPropertyConfig cfg = ConfigManager.Instance.GetTemplate<PlayerPropertyConfig>(attrId);
|
| | | if (paramConfig == null || cfg == null) return 0;
|
| | |
|
| | | switch(cfg.Parameter)
|
| | | {
|
| | | case "Hit":
|
| | | return paramConfig.Hit;
|
| | | case "Miss":
|
| | | return paramConfig.Miss;
|
| | | case "DamagePer":
|
| | | return paramConfig.DamagePer;
|
| | | case "DamReduce":
|
| | | return paramConfig.DamReduce;
|
| | | case "IgnoreDefRate":
|
| | | return paramConfig.IgnoreDefRate;
|
| | | case "DamChanceDef":
|
| | | return paramConfig.DamChanceDef;
|
| | | case "BleedDamage":
|
| | | return paramConfig.BleedDamage;
|
| | | case "FaintRate":
|
| | | return paramConfig.FaintRate;
|
| | | case "SuperHitReduce":
|
| | | return paramConfig.SuperHitReduce;
|
| | | case "LuckyHitRateReduce":
|
| | | return paramConfig.LuckyHitRateReduce;
|
| | | case "SkillAtkRate":
|
| | | return paramConfig.SkillAtkRate;
|
| | | case "SkillAtkRateReduce":
|
| | | return paramConfig.SkillAtkRateReduce;
|
| | | case "DamagePerPVP":
|
| | | return paramConfig.DamagePerPVP;
|
| | | case "DamagePerPVPReduce":
|
| | | return paramConfig.DamagePerPVPReduce;
|
| | | case "DamBackPer":
|
| | | return paramConfig.DamBackPer;
|
| | | case "IgnoreDefRateReduce":
|
| | | return paramConfig.IgnoreDefRateReduce;
|
| | | case "FaintDefRate":
|
| | | return paramConfig.FaintDefRate;
|
| | | case "AtkSpeedParameter":
|
| | | return paramConfig.AtkSpeedParameter;
|
| | | case "LuckyHitParameter":
|
| | | return paramConfig.LuckyHitParameter;
|
| | |
|
| | | }
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region 得到金钱数量根据金钱类型
|
| | | public static ulong GetMoneyCnt(int moneyType)
|
| | | {
|
| | | switch (moneyType)
|
| | | {
|
| | | case 1:
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.Gold;
|
| | | }
|
| | | case 2:
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.GoldPaper;
|
| | | }
|
| | | case 3:
|
| | | {
|
| | | return PlayerDatas.Instance.baseData.allSliver;
|
| | | }
|
| | | case 25:
|
| | | {
|
| | | return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataRefresh.CDBPlayerRefresh_TreasureScore);
|
| | | }
|
| | | case 24:
|
| | | {
|
| | | return (ulong)ModelCenter.Instance.GetModel<RuneModel>().RuneChip;
|
| | | }
|
| | | case 15:
|
| | | {
|
| | | return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataRefresh.UnionLiven);
|
| | | }
|
| | | case 16:
|
| | | {
|
| | | return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataRefresh.FBHelpPoint);
|
| | | }
|
| | | case 27:
|
| | | {
|
| | | return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataRefresh.CDBPlayerRefresh_Danjing);
|
| | | }
|
| | | }
|
| | | return 0;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region 得到装备位对应的部位名称
|
| | | public static string GetEquipAreaName(int place)
|
| | | {
|
| | | FuncConfigConfig funcAreaModel = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("EquipArea");
|
| | | int[] placelist = ConfigParse.GetMultipleStr<int>(funcAreaModel.Numerical1);
|
| | | string[] namelist = ConfigParse.GetMultipleStr(funcAreaModel.Numerical2);
|
| | | int i = 0;
|
| | | for (i = 0; i < placelist.Length; i++)
|
| | | {
|
| | | if (placelist[i] == place)
|
| | | {
|
| | | return namelist[i];
|
| | | }
|
| | | }
|
| | | return "";
|
| | | }
|
| | | #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
|
| | |
|
| | | #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";
|
| | | }
|
| | | }
|