public BattlePowerInfo GetItemInfo(uint id) { string query = string.Format("SELECT * FROM {0} WHERE {0}.{1}=\"{2}\"", mTableName, "id", id); var reader = DBManager.Instance.ExecuteSqliteQueryToReader(GlobalConfig.DBFile, mTableName, query, (int)DBManager.CommandTag.TAG_3); if (reader == null) { mBattlePowerInfos[id] = null; return(null); } if (!reader.HasRows || !reader.Read()) { mBattlePowerInfos[id] = null; reader.Close(); reader.Dispose(); return(null); } BattlePowerInfo info = new BattlePowerInfo(); int suffix_len = "{0}".Length; List <string> valStrList = DBTextResource.ParseArrayString(GetReaderString(reader, "val")); if (valStrList.Count >= 2) { uint key = 0; uint.TryParse(valStrList[0], out key); float val = 0f; float.TryParse(valStrList[1], out val); info.val = new KeyValuePair <uint, float>(key, val); } info.show_type = DBTextResource.ParseBT_s(GetReaderString(reader, "show_type"), 0); info.desc = GetReaderString(reader, "desc"); if (!string.IsNullOrEmpty(info.desc)) { //if(info.desc.Length > suffix_len) // info.name = info.desc.Substring(0, info.desc.Length - suffix_len); if (info.desc.Length > suffix_len) { info.name = info.desc.Replace("{0}", ""); } } info.tips_desc = GetReaderString(reader, "tips_desc"); info.equip_val = GetReaderFloat(reader, "equip_val"); info.equip_strength_val = GetReaderFloat(reader, "equip_strength_val"); info.equip_baptize_val = GetReaderFloat(reader, "equip_baptize_val"); mBattlePowerInfos.Add(id, info); reader.Close(); reader.Dispose(); return(info); }
public DBBuffInfo GetBuffInfo(uint uiID) { DBBuffInfo info = null; if (mBuffInfos.TryGetValue(uiID, out info)) { return(info); } string query_str = string.Format("SELECT * FROM {0} WHERE {1}=\"{2}\"", mTableName, "id", uiID); var reader = DBManager.Instance.ExecuteSqliteQueryToReader(GlobalConfig.DBFile, mTableName, query_str); if (reader == null) { mBuffInfos[uiID] = null; return(null); } if (!reader.HasRows || !reader.Read()) { mBuffInfos[uiID] = null; reader.Close(); reader.Dispose(); return(null); } var buff_info = new Buff.BuffInfo(); buff_info.buff_id = DBTextResource.ParseUI(GetReaderString(reader, "id")); buff_info.is_show_tip = DBTextResource.ParseUI(GetReaderString(reader, "is_show_tip")) == 1; buff_info.max_add_num = DBTextResource.ParseUS(GetReaderString(reader, "max_layer")); buff_info.add_eff = DBTextResource.ParseArrayUint(GetReaderString(reader, "add_eff"), ","); buff_info.delay_time = DBTextResource.ParseUI_s(GetReaderString(reader, "delay_time"), 0) * 0.001f; buff_info.shape_shift = DBTextResource.ParseUI_s(GetReaderString(reader, "transform"), 0); buff_info.shift_state = DBTextResource.ParseBT_s(GetReaderString(reader, "shift_state"), 0); buff_info.life_time = 3.0f;//buff的时间由服务端发送下来 buff_info.name = GetReaderString(reader, "name"); buff_info.icon = GetReaderString(reader, "icon"); buff_info.effect_file = GetReaderString(reader, "effect_file"); buff_info.priority = DBTextResource.ParseUS_s(GetReaderString(reader, "priority"), 0); buff_info.force_show = DBTextResource.ParseUS_s(GetReaderString(reader, "force_show"), 0) == 1; buff_info.other_hide = DBTextResource.ParseUS_s(GetReaderString(reader, "other_hide"), 0) == 1; buff_info.bind_pos = (BindPos)DBTextResource.ParseUI(GetReaderString(reader, "bind_pos")); buff_info.follow_target = DBTextResource.ParseUI_s(GetReaderString(reader, "follow_target"), 1) == 1; buff_info.scale = DBTextResource.ParseF_s(GetReaderString(reader, "scale"), 1.0f); buff_info.auto_scale = DBTextResource.ParseUS_s(GetReaderString(reader, "auto_scale"), 0) == 1; buff_info.des = GetReaderString(reader, "des"); buff_info.hide_countDown = DBTextResource.ParseUS_s(GetReaderString(reader, "hide_countDown"), 0) == 1; var max_count = GetReaderString(reader, "max_count"); if (string.IsNullOrEmpty(max_count)) { buff_info.max_count = 5; } else { buff_info.max_count = DBTextResource.ParseI_s(max_count, 5); } string status = GetReaderString(reader, "status");// buff的特殊状态 BattleStatusType status_type = Buff.GetBattleState(status); if (status_type != BattleStatusType.BATTLE_STATUS_TYPE_INVALID) { buff_info.battle_effect_type = status_type; Bind(buff_info, BuffEffect.BattleStateChangeBegin, BuffEffect.BattleStateChangeEnd, null); } if (buff_info.shape_shift != 0) { Bind(buff_info, BuffEffect.ShapeShiftBegin, BuffEffect.ShapeShiftEnd, null); } // 设置周期更新时间 buff_info.period_time = Mathf.Infinity; buff_info.buff_flags |= (ushort)Buff.BuffFlags.AF_RECOVERY_AFTER_DIE; mBuffInfos.Add(buff_info.buff_id, buff_info); reader.Close(); reader.Dispose(); return(buff_info); }