7179 【前端】【2.0】百分比属性保留X位小数
| | |
| | | //-------------------------------------------------------- |
| | | // [Author]: Fish |
| | | // [ Date ]: Wednesday, May 15, 2019 |
| | | // [ Date ]: Monday, June 10, 2019 |
| | | //-------------------------------------------------------- |
| | | |
| | | using System.Collections.Generic; |
| | |
| | | public partial class PlayerPropertyConfig |
| | | { |
| | | |
| | | public readonly int ID; |
| | | public readonly string Name; |
| | | public readonly int ISPercentage; |
| | | public readonly int type; |
| | | public readonly string desc; |
| | | public readonly int ID;
|
| | | public readonly string Name;
|
| | | public readonly int ISPercentage;
|
| | | public readonly int type;
|
| | | public readonly int decimalCount;
|
| | | public readonly string desc;
|
| | | public readonly string Parameter; |
| | | |
| | | public PlayerPropertyConfig() |
| | |
| | | { |
| | | var tables = input.Split('\t'); |
| | | |
| | | int.TryParse(tables[0],out ID); |
| | | |
| | | Name = tables[1]; |
| | | |
| | | int.TryParse(tables[2],out ISPercentage); |
| | | |
| | | int.TryParse(tables[3],out type); |
| | | |
| | | desc = tables[4]; |
| | | |
| | | Parameter = tables[5]; |
| | | int.TryParse(tables[0],out ID); |
| | |
|
| | | Name = tables[1];
|
| | |
|
| | | int.TryParse(tables[2],out ISPercentage); |
| | |
|
| | | int.TryParse(tables[3],out type); |
| | |
|
| | | int.TryParse(tables[4],out decimalCount); |
| | |
|
| | | desc = tables[5];
|
| | |
|
| | | Parameter = tables[6]; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | fileFormatVersion: 2 |
| | | guid: 2deaa7d02e386a54a997be559b9f935b |
| | | timeCreated: 1557892564 |
| | | timeCreated: 1560135998 |
| | | licenseType: Pro |
| | | MonoImporter: |
| | | serializedVersion: 2 |
| | |
| | |
|
| | | public static string GetValueDescription(int id, int value)
|
| | | {
|
| | | return GetValueDescription(id, value, 1, false);
|
| | | return GetValueDescription(id, value, false);
|
| | | }
|
| | |
|
| | | public static string GetValueDescription(int id, int value, int decimalCount, bool largeValue)
|
| | | public static string GetValueDescription(int id, int value, bool largeValue)
|
| | | {
|
| | | var config = Get(id);
|
| | | if (config == null)
|
| | |
| | | }
|
| | | else if (config.ISPercentage == 1)
|
| | | {
|
| | | result = (float)Math.Round(value / 100f, decimalCount);
|
| | | result = (float)Math.Round(value / 100f, config.decimalCount);
|
| | | }
|
| | | else if (config.ISPercentage == 2)
|
| | | {
|
| | | result = (float)Math.Round(value / 100f, decimalCount);
|
| | | result = (float)Math.Round(value / 100f, config.decimalCount);
|
| | | }
|
| | |
|
| | | var label = string.Empty;
|
| | |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "Init", _m_Init_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "GetPropByType", _m_GetPropByType_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "GetFullDescription", _m_GetFullDescription_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "GetValueDescription", _m_GetValueDescription_xlua_st_); |
| | | |
| | | |
| | | |
| | |
| | | return LuaAPI.luaL_error(L, "invalid arguments to PlayerPropertyConfig.GetFullDescription!"); |
| | | |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _m_GetValueDescription_xlua_st_(RealStatePtr L) |
| | | { |
| | | try { |
| | | |
| | | ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); |
| | | |
| | | |
| | | |
| | | int gen_param_count = LuaAPI.lua_gettop(L); |
| | | |
| | | if(gen_param_count == 2&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)) |
| | | { |
| | | int _id = LuaAPI.xlua_tointeger(L, 1); |
| | | int _value = LuaAPI.xlua_tointeger(L, 2); |
| | | |
| | | string gen_ret = PlayerPropertyConfig.GetValueDescription( _id, _value ); |
| | | LuaAPI.lua_pushstring(L, gen_ret); |
| | | |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | if(gen_param_count == 4&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 1)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2)&& LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)&& LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4)) |
| | | { |
| | | int _id = LuaAPI.xlua_tointeger(L, 1); |
| | | int _value = LuaAPI.xlua_tointeger(L, 2); |
| | | int _decimalCount = LuaAPI.xlua_tointeger(L, 3); |
| | | bool _largeValue = LuaAPI.lua_toboolean(L, 4); |
| | | |
| | | string gen_ret = PlayerPropertyConfig.GetValueDescription( _id, _value, _decimalCount, _largeValue ); |
| | | LuaAPI.lua_pushstring(L, gen_ret); |
| | | |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | if(gen_param_count == 1&& translator.Assignable<Int2>(L, 1)) |
| | | { |
| | | Int2 _property;translator.Get(L, 1, out _property); |
| | | |
| | | string gen_ret = PlayerPropertyConfig.GetValueDescription( _property ); |
| | | LuaAPI.lua_pushstring(L, gen_ret); |
| | | |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | |
| | | return LuaAPI.luaL_error(L, "invalid arguments to PlayerPropertyConfig.GetValueDescription!"); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _g_get_inited(RealStatePtr L) |
| | |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "ReplaceLargeNum", _m_ReplaceLargeNum_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "ReplaceXianYuanCoinsNum", _m_ReplaceXianYuanCoinsNum_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "ReplacePercentage", _m_ReplacePercentage_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "GetPropertyDecimalCount", _m_GetPropertyDecimalCount_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "HasSpecialCharac", _m_HasSpecialCharac_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "GetColorNameByItemColor", _m_GetColorNameByItemColor_xlua_st_); |
| | | Utils.RegisterFunc(L, Utils.CLS_IDX, "GetDanLVColor", _m_GetDanLVColor_xlua_st_); |
| | |
| | | } |
| | | |
| | | return LuaAPI.luaL_error(L, "invalid arguments to UIHelper.ReplacePercentage!"); |
| | | |
| | | } |
| | | |
| | | [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] |
| | | static int _m_GetPropertyDecimalCount_xlua_st_(RealStatePtr L) |
| | | { |
| | | try { |
| | | |
| | | |
| | | |
| | | |
| | | { |
| | | int _property = LuaAPI.xlua_tointeger(L, 1); |
| | | |
| | | int gen_ret = UIHelper.GetPropertyDecimalCount( _property ); |
| | | LuaAPI.xlua_pushinteger(L, gen_ret); |
| | | |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | } catch(System.Exception gen_e) { |
| | | return LuaAPI.luaL_error(L, "c# exception:" + gen_e); |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | {
|
| | | m_PropertyName.text = GetPropertyName(_property);
|
| | | m_PropertyValue.text = StringUtility.Contact("+",
|
| | | PlayerPropertyConfig.GetValueDescription(_property, _value, 2, false));
|
| | | PlayerPropertyConfig.GetValueDescription(_property, _value, false));
|
| | | }
|
| | |
|
| | | string GetPropertyName(int property)
|
| | |
| | |
|
| | | string GetValueLabel(int _property, int _value)
|
| | | {
|
| | | var decimalCount = UIHelper.GetPropertyDecimalCount(_property);
|
| | | return PlayerPropertyConfig.GetValueDescription(_property, _value, decimalCount, true);
|
| | | return PlayerPropertyConfig.GetValueDescription(_property, _value, true);
|
| | | }
|
| | |
|
| | | public void SetColor(TextColType colorType, bool bright)
|
| | |
| | | return x.property == property;
|
| | | });
|
| | | var value = model.GetQualityProperty(quality, qualityProperty.propertyValues);
|
| | | var decimalCount = UIHelper.GetPropertyDecimalCount(property);
|
| | | m_PropertyValues[i].text = "+" + PlayerPropertyConfig.GetValueDescription(property, value, decimalCount, true);
|
| | | m_PropertyValues[i].text = "+" + PlayerPropertyConfig.GetValueDescription(property, value, true);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | var minAtk = PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.MINATK);
|
| | | var maxAtk = PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.MAXATK);
|
| | | var minAtkLabel = PlayerPropertyConfig.GetValueDescription((int)propertyType, minAtk, 2, true);
|
| | | var maxAtkLabel = PlayerPropertyConfig.GetValueDescription((int)propertyType, maxAtk, 2, true);
|
| | | var minAtkLabel = PlayerPropertyConfig.GetValueDescription((int)propertyType, minAtk, true);
|
| | | var maxAtkLabel = PlayerPropertyConfig.GetValueDescription((int)propertyType, maxAtk, true);
|
| | | return StringUtility.Contact(minAtkLabel, "-", maxAtkLabel);
|
| | | }
|
| | | else
|
| | |
| | | switch (propertyType)
|
| | | {
|
| | | case PropertyType.ATKSPEED:
|
| | | return PlayerPropertyConfig.GetValueDescription((int)propertyType, value, 1, true);
|
| | | return PlayerPropertyConfig.GetValueDescription((int)propertyType, value, true);
|
| | | default:
|
| | | return PlayerPropertyConfig.GetValueDescription((int)propertyType, value, 2, true);
|
| | | return PlayerPropertyConfig.GetValueDescription((int)propertyType, value, true);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | var property = config.AttrType[i];
|
| | | var propertyConfig = PlayerPropertyConfig.Get(property);
|
| | | var propertyValue = GetPropertyValue(id, level, property);
|
| | | var decimalCount = UIHelper.GetPropertyDecimalCount(property);
|
| | | var label = StringUtility.Contact(propertyConfig.Name, "+",
|
| | | PlayerPropertyConfig.GetValueDescription(property, propertyValue, decimalCount, false));
|
| | | PlayerPropertyConfig.GetValueDescription(property, propertyValue, false));
|
| | | sb.Append(label);
|
| | | if (i < config.AttrType.Length - 1)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public static int GetPropertyDecimalCount(int property)
|
| | | {
|
| | | switch (property)
|
| | | {
|
| | | case 73:
|
| | | return 2;
|
| | | case 29:
|
| | | return 2;
|
| | | default:
|
| | | return 1;
|
| | | }
|
| | | }
|
| | |
|
| | | static Regex s_SpecialCharacterRegex = new Regex("[ ()()@!#$%^&*[]|_]");
|
| | | static Regex s_AsciiCharacterRegex = new Regex("[\x00-\x2F]|[\x3A-\x40]|[\x5B-\x60]|[\x7B-\x7E]");
|
| | | public static bool HasSpecialCharac(string str)
|