예제 #1
0
        /// <summary>
        /// 根据装备id来获取装备属性
        /// </summary>
        /// <param name="attr_id"></param>
        /// <returns></returns>
        public EquipAttrData GetAttrData(uint attr_id)
        {
            EquipAttrData attr_data = null;

            if (EquipAttrDatas.TryGetValue(attr_id, out attr_data))
            {
                return(attr_data);
            }

            string query_str = string.Format("SELECT * FROM {0} WHERE {0}.{1}={2}", mTableName, "id", attr_id);
            var    reader    = DBManager.Instance.ExecuteSqliteQueryToReader(GlobalConfig.DBFile, mTableName, query_str);

            if (reader == null)
            {
                EquipAttrDatas[attr_id] = null;
                return(null);
            }

            if (!reader.HasRows || !reader.Read())
            {
                EquipAttrDatas[attr_id] = null;
                reader.Close();
                reader.Dispose();
                return(null);
            }

            attr_data = ReadInfo(reader);
            EquipAttrDatas.Add(attr_data.Id, attr_data);

            reader.Close();
            reader.Dispose();

            return(attr_data);
        }
예제 #2
0
        EquipAttrData ReadInfo(SqliteDataReader reader)
        {
            var id     = GetReaderUint(reader, "id");
            var base_g = GetReaderFloat(reader, "val"); // DBTextResource.ParseUI(GetReaderString(reader, "val"),0.0f);

            var sub_attr_id     = DBTextResource.ParseUI(GetReaderString(reader, "sub_attr_id"));
            var attr_color_type = GetReaderString(reader, "attr_color_type");
            var matchs          = Regex.Matches(attr_color_type, @"\{(\d+),(\d+)\}");
            List <ValueRange> attr_color_types = new List <ValueRange>();

            foreach (Match _match in matchs)
            {
                if (_match.Success)
                {
                    uint       min   = (DBTextResource.ParseUI(_match.Groups[1].Value));
                    uint       max   = DBTextResource.ParseUI(_match.Groups[2].Value);
                    ValueRange value = new ValueRange(min, max);
                    attr_color_types.Add(value);
                }
            }

            var attr_data = new EquipAttrData(id, sub_attr_id, base_g, attr_color_types);

            attr_data.AttrId  = DBTextResource.ParseUI(GetReaderString(reader, "attr"));
            attr_data.ArgsStr = GetReaderString(reader, "args");
            attr_data.Args    = DBTextResource.ParseArrayUint(attr_data.ArgsStr, ",");

            return(attr_data);
        }
예제 #3
0
        public string GetSubAttrDesc(EquipAttrData attrData, string replace_str, uint sub_attr_id, out uint color, params uint[] values)
        {
            color = 0;
            string colorStr = string.Empty;
            string attr     = "";

            EquipSubAttrData data = GetSubAttrData(sub_attr_id);

            if (data != null)
            {
                List <string> des_value = new List <string>();
                for (int i = 0; i < data.DesType.Count; i++)
                {
                    for (int j = 0; j < attrData.ColorType.Count; j++)
                    {
                        var valuerange = attrData.ColorType[j];
                        if (values[i] >= valuerange.Min && values[i] <= valuerange.Max)
                        {
                            color    = (uint)j;
                            colorStr = GoodsHelper.GetGoodsColor((uint)j);//对应就是0~4品质
                            break;
                        }
                    }
                    if (i < values.Length)
                    {
                        switch (data.DesType[i])
                        {
                        case 0:
                        {
                            string val = values[i].ToString();

                            des_value.Add(val);
                        }
                        break;

                        case 1:
                        {
                            string val = (values[i] / ActorHelper.UnitConvert).ToString("0.00");
                            val = ActorUtils.Instance.TrimFloatStr(val);
                            des_value.Add(val);
                        }
                        break;

                        case 2:
                        {
                            string val_noSign = (values[i] / ActorHelper.DisplayPercentUnitConvert).ToString("0.00");
                            val_noSign = ActorUtils.Instance.TrimFloatStr(val_noSign);
                            string val = val_noSign + "%";
                            des_value.Add(val);
                        }
                        break;
                        }
                    }
                }
                string des_str = data.Des;
                if (replace_str != null && replace_str.Length > 0)
                {
                    for (int index = 0; index < des_value.Count; ++index)
                    {
                        des_str = des_str.Replace("{" + index.ToString() + "}", replace_str + "{" + index.ToString() + "}");
                    }
                }
                if (des_value.Count > 0)
                {
                    attr = string.Format(des_str, des_value.ToArray());
                }
            }
            if (colorStr.CompareTo(string.Empty) != 0)
            {
                attr = colorStr + attr + "</color>";
            }
            return(attr);
        }