Пример #1
0
        /// <summary>
        /// 获得转换后的属性字符窜,比如百分比,KGM
        /// </summary>
        /// <returns></returns>
        public static string GetAttrNumber(T Type, float Val)
        {
            List <TDAttrData> tempAttrData = GetAttrDataList();

            if (tempAttrData != null)
            {
                var tempData = tempAttrData[BoxAvoidance <T> .ToInt(Type)];
                if (tempData.NumberType == NumberType.KMG)
                {
                    return(BaseUIUtils.KMG(Val));
                }
                else if (tempData.NumberType == NumberType.Percent)
                {
                    return(BaseUIUtils.Percent(Val));
                }
                else if (tempData.NumberType == NumberType.Normal)
                {
                    return(BaseUIUtils.OptionalTwoDigit(Val));
                }
                else if (tempData.NumberType == NumberType.Integer)
                {
                    return(BaseUIUtils.Round(Val));
                }
                else if (tempData.NumberType == NumberType.Bool)
                {
                    return(BaseUIUtils.Bool(Val));
                }
            }
            return(Val.ToString());
        }
Пример #2
0
        /// <summary>
        /// 获取带有颜色的加成字符,附带正面效果和负面效果的颜色变化
        /// </summary>
        /// <param name="Type"></param>
        /// <param name="Val"></param>
        /// <returns></returns>
        public static string GetAttrStr(T Type, float Val, bool?isPercent = null, bool isIgnoreName = false, bool isColor = true)
        {
            List <TDAttrData> tempAttrData = GetAttrDataList();
            var    tempData    = tempAttrData[BoxAvoidance <T> .ToInt(Type)];
            string color       = GetAttrColor(Type, Val);
            bool   tempPercent = false;
            bool   tempBool    = false;

            //设置输入的百分比
            if (isPercent.HasValue)
            {
                tempPercent = isPercent.Value;
            }
            //如果是百分比数值则直接使用百分比
            if (tempData.NumberType == NumberType.Percent)
            {
                tempPercent = true;
            }
            if (tempData.NumberType == NumberType.Bool)
            {
                tempBool = true;
            }

            //属性名称
            string name = isIgnoreName ? "" : (Type as Enum).GetName();
            //设置属性值
            string strVal = "No";

            if (tempBool)
            {
                strVal = BaseUIUtils.Bool(Val);
            }
            else if (tempPercent)
            {
                strVal = BaseUIUtils.PercentSign(Val);
            }
            else
            {
                strVal = BaseUIUtils.Sign((float)Math.Round(Val, 2));
            }
            //组合
            string str1 = name + strVal;

            //属性颜色
            if (isColor)
            {
                str1 = color + str1 + "</color>";
            }
            return(str1);
        }