public void HegdingToValue(string strAttrName, ref uint attrValue) { GetAttrValueByName(strAttrName, ref attrValue); AttrNameData attrItem = GameSystem.Instance.AttrNameConfigData.AttrNameDatas.Find((AttrNameData item) => { return(item.symbol == strAttrName); }); if (attrItem == null) { return; } Debug.Log("Player id: " + m_player.m_id + " attrName: " + strAttrName + " , attrValue0: " + attrValue); if (attrItem.type != AttributeType.HEDGINGLEVEL) { return; } AttrData attrData = m_player.m_attrData; HedgingConfig.hedgeLevelData data = GameSystem.Instance.HedgingConfig.GetHedgeLevelFactor(attrItem.id); if (data != null) { IM.PrecNumber factor = data.factor; uint attrID = data.oppositeID; string symbol = GameSystem.Instance.AttrNameConfigData.GetAttrSymbol(attrID); if (attrData.attrs.ContainsKey(symbol)) { Debug.Log("Attr data: " + attrData.attrs[symbol] + " factor: " + factor); attrValue = (uint)(attrData.attrs[symbol] * (1 + attrValue * factor)).roundToInt; } } Debug.Log("Player id: " + m_player.m_id + " attrName: " + strAttrName + " , attrValue1: " + attrValue); }
static int GetAttrData(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); AttrNameConfig obj = (AttrNameConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "AttrNameConfig"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); AttrNameData o = obj.GetAttrData(arg0); LuaScriptMgr.PushObject(L, o); return(1); }
static int _CreateAttrNameData(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 0) { AttrNameData obj = new AttrNameData(); LuaScriptMgr.PushObject(L, obj); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: AttrNameData.New"); } return(0); }
static int get_type(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); AttrNameData obj = (AttrNameData)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name type"); } else { LuaDLL.luaL_error(L, "attempt to index type on a nil value"); } } LuaScriptMgr.Push(L, obj.type); return(1); }
static int set_fc_weight(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); AttrNameData obj = (AttrNameData)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name fc_weight"); } else { LuaDLL.luaL_error(L, "attempt to index fc_weight on a nil value"); } } obj.fc_weight = (IM.Number)LuaScriptMgr.GetNetObject(L, 3, typeof(IM.Number)); return(0); }
static int set_is_factor(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); AttrNameData obj = (AttrNameData)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name is_factor"); } else { LuaDLL.luaL_error(L, "attempt to index is_factor on a nil value"); } } obj.is_factor = (uint)LuaScriptMgr.GetNumber(L, 3); return(0); }
static int set_recommend(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); AttrNameData obj = (AttrNameData)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name recommend"); } else { LuaDLL.luaL_error(L, "attempt to index recommend on a nil value"); } } obj.recommend = (List <uint>)LuaScriptMgr.GetNetObject(L, 3, typeof(List <uint>)); return(0); }
static int set_name(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); AttrNameData obj = (AttrNameData)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name name"); } else { LuaDLL.luaL_error(L, "attempt to index name on a nil value"); } } obj.name = LuaScriptMgr.GetString(L, 3); return(0); }
public void ReadConfig() { if (isLoadFinish == false) { return; } isLoadFinish = false; lock (LockObject) { GameSystem.Instance.readConfigCnt += 1; } Debug.Log("Config reading " + name); string text = ResourceLoadManager.Instance.GetConfigText(name); if (text == null) { Debug.LogError("LoadConfig failed: " + name); return; } AttrNameDatas.Clear(); XmlDocument xmlDoc = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_ATTRNAME, text); XmlNodeList nodelist = xmlDoc.SelectSingleNode("Data").ChildNodes; foreach (XmlElement xe in nodelist) { XmlNode comment = xe.SelectSingleNode(GlobalConst.CONFIG_SWITCH_COLUMN); if (comment != null && comment.InnerText == GlobalConst.CONFIG_SWITCH) { continue; } AttrNameData data = new AttrNameData(); foreach (XmlElement xel in xe) { uint value; if (xel.Name == "ID") { uint.TryParse(xel.InnerText, out data.id); } else if (xel.Name == "type") { uint.TryParse(xel.InnerText, out value); data.type = (AttributeType)value; } else if (xel.Name == "symbol") { data.symbol = xel.InnerText; } else if (xel.Name == "name") { data.name = xel.InnerText; } else if (xel.Name == "display") { uint.TryParse(xel.InnerText, out data.display); } else if (xel.Name == "recommend") { string s = xel.InnerText; string[] slist = s.Split('&'); foreach (string item in slist) { uint n; uint.TryParse(item, out n); data.recommend.Add(n); } } else if (xel.Name == "is_factor") { uint.TryParse(xel.InnerText, out data.is_factor); } else if (xel.Name == "fc_weight") { IM.Number.TryParse(xel.InnerText, out data.fc_weight); } } AttrNameDatas.Add(data); if (!AttrName.ContainsKey(data.symbol)) { AttrName.Add(data.symbol, data.name); } } isReadFinish = true; }