Example #1
0
        /// <summary>
        /// 判断一件饰品是否比现穿戴饰品更好(不包含等级限制)
        /// </summary>
        /// <param name="equip"></param>
        /// <returns></returns>
        public static bool IsBetterDecorateCanQuickUse(GoodsDecorate decorate)
        {
            if (decorate == null)
            {
                return(false);
            }

            // 支持快捷使用
            if (!decorate.is_quickuse)
            {
                return(false);
            }

            // 是否能使用
            if (!decorate.can_use)
            {
                return(false);
            }

            var wearingDecorate = GetWearingDecorateByPos(decorate.Pos);

            if (wearingDecorate == null)
            {
                return(true);
            }

            //基础评分
            if (decorate.BaseScore <= wearingDecorate.BaseScore)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// 获取饰品 突破后的附魔属性
        /// </summary>
        public static ActorAttribute GetBreakAppendAttr(GoodsDecorate decorate)
        {
            ActorAttribute ret = new ActorAttribute();

            if (decorate == null)
            {
                return(ret);
            }

            DecoratePosInfo posInfo = ItemManager.Instance.DecoratePosInfos.Find(
                delegate(DecoratePosInfo _info) { return(_info.Pos == decorate.Pos); });

            if (posInfo == null)
            {
                return(ret);
            }

            uint nextBreakLv = posInfo.BreakLv + 1;

            foreach (var attr in posInfo.AppendAttrs)
            {
                if (attr.IsOpen || attr.BreakLv == nextBreakLv)
                {
                    ret.Add(attr.AttrId, (long)attr.Value);
                }
            }

            return(ret);
        }
Example #3
0
        /// <summary>
        /// 获取正穿戴着的指定部位的饰品
        /// </summary>
        public static GoodsDecorate GetWearingDecorateByPos(uint pos)
        {
            GoodsDecorate decorate = null;

            if (ItemManager.Instance.WearingDecorate.TryGetValue(pos, out decorate))
            {
                return(decorate);
            }

            return(null);
        }
Example #4
0
        /// <summary>
        /// 返回饰品星级
        /// <returns></returns>
        public static uint GetDecorateStar(GoodsDecorate decorate)
        {
            uint ret = 0;

            if (decorate == null || decorate.LegendAttrs == null)
            {
                return(0);
            }

            if (decorate.ServerStar != 0xffffff)
            {
                return(decorate.ServerStar);
            }

            bool has_attrs = false;

            foreach (var kv in decorate.LegendAttrs)
            {
                var attrData = EquipHelper.GetEquipAttrData(kv.Id);
                if (attrData != null)
                {
                    EquipSubAttrData data = null;
                    if (DBManager.GetInstance().GetDB <DBEquipSubAttr>().EquipSubAttrDescs.TryGetValue(attrData.SubAttrId, out data))
                    {
                        has_attrs = true;
                        List <string> des_value = new List <string>();
                        for (int i = 0; i < data.DesType.Count; i++)
                        {
                            if (attrData.ColorType.Count > 4)
                            {
                                var valuerange = attrData.ColorType[3];
                                if (kv.Values[i] >= valuerange.Min)
                                {
                                    ret++;//对应就是0~4品质
                                }
                            }
                        }
                    }
                }
            }

            if (has_attrs == false)
            {
                if (decorate.DbData != null)
                {
                    ret = decorate.DbData.DefaultStar;
                }
            }

            return(ret);
        }
Example #5
0
        /// <summary>
        /// 返回背包中某个部位最好饰品(可以穿戴)
        /// </summary>
        /// <returns></returns>
        public static GoodsDecorate GetBestBagDecorate()
        {
            GoodsDecorate ret = null;

            foreach (var data in ItemManager.Instance.DecoratePosInfos)
            {
                if (ItemManager.Instance.CheckHavePos(GameConst.GIVE_TYPE_DECORATE, data.Pos))
                {
                    continue;
                }


                if (!data.IsUnlock)
                {
                    continue;
                }

                var wearingDecorate = GetWearingDecorateByPos(data.Pos);
                var canUseList      = GetBagDecoratesByPos(data.Pos, true);

                if (canUseList != null && canUseList.Count > 0)
                {
                    int score = -99999;
                    if (wearingDecorate != null)
                    {
                        score = wearingDecorate.BaseScore;
                    }

                    foreach (var value in canUseList)
                    {
                        if (ItemManager.Instance.mCloseQuickUseGoodsIdArray.ContainsKey(value.type_idx))
                        {
                            continue;
                        }

                        if (value.BaseScore > score)
                        {
                            ret   = value;
                            score = value.BaseScore;
                        }
                    }
                }

                if (ret != null)
                {
                    return(ret);
                }
            }

            return(ret);
        }
Example #6
0
        /// <summary>
        /// 展示饰品Tips
        /// </summary>
        /// <returns></returns>
        public static void ShowDecorateTipsWindow(GoodsDecorate decorate, string showType, uint strengthenLv)
        {
            // 饰品经验道具部位Id
            uint expPos = xc.GameConstHelper.GetUint("GAME_DECORATE_EXP_GOODS");

            if (decorate.Pos == expPos)
            {
                UIManager.Instance.ShowWindow("UIGoodsTipsWindow", decorate, showType);
            }
            else
            {
                UIManager.Instance.ShowWindow("UIDecorateTipsWindow", decorate, showType, strengthenLv);
            }
        }
Example #7
0
        /// <summary>
        /// 饰品传奇属性描述
        /// </summary>
        /// <param name="equip"></param>
        /// <returns></returns>
        public static string GetDecorateLegendAttrStr(GoodsDecorate decorate)
        {
            if (decorate == null && decorate.LegendAttrs == null)
            {
                return(string.Empty);
            }

            List <KeyValuePair <string, uint> > strColorPairs = new List <KeyValuePair <string, uint> >();

            strColorPairs.Clear();
            foreach (var kv in decorate.LegendAttrs)
            {
                uint   color = 0;
                string des   = EquipHelper.GetSubAttrDes(kv.Id, kv.Values, " +", out color);
                KeyValuePair <string, uint> strColorPair = new KeyValuePair <string, uint>(des, color);
                strColorPairs.Add(strColorPair);
            }

            string str = string.Empty;

            strColorPairs.Sort((a, b) =>
            {
                if (a.Value > b.Value)
                {
                    return(-1);
                }
                else if (a.Value < b.Value)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            });

            foreach (KeyValuePair <string, uint> strColorPair in strColorPairs)
            {
                str += strColorPair.Key + "\n";
            }

            if (str.Length > 0)
            {
                str = str.Substring(0, str.Length - 1);
            }

            return(str);
        }
Example #8
0
        /// <summary>
        /// 获取背包指定部位的饰品列表
        /// <para>can_use_limit: 添加可以使用限制</para>
        /// </summary>
        public static List <GoodsDecorate> GetBagDecoratesByPos(uint pos, bool can_use_limit = false)
        {
            List <GoodsDecorate> ret = new List <GoodsDecorate>();

            foreach (var kv in ItemManager.Instance.DecorateGoodsOids)
            {
                if (kv.Value != null && kv.Value is GoodsDecorate)
                {
                    GoodsDecorate decorate = kv.Value as GoodsDecorate;
                    if (decorate.Pos == pos)
                    {
                        if (can_use_limit)
                        {
                            if (decorate.can_use)
                            {
                                ret.Add(decorate);
                            }
                        }
                        else
                        {
                            ret.Add(decorate);
                        }
                    }
                }
            }

            ret.Sort(delegate(GoodsDecorate lhs, GoodsDecorate rhs)
            {
                if (lhs.BaseScore > rhs.BaseScore)
                {
                    return(-1);
                }

                else if (lhs.BaseScore < rhs.BaseScore)
                {
                    return(1);
                }

                else
                {
                    return(0);
                }
            });

            return(ret);
        }
Example #9
0
        /// <summary>
        ///  获取饰品强化属性
        /// </summary>
        public static ActorAttribute GetStrengthAttr(uint strengthLv, GoodsDecorate decorate)
        {
            ActorAttribute ret = new ActorAttribute();

            uint lv = strengthLv;

            if (lv > decorate.MaxStrengthLv)
            {
                lv = decorate.MaxStrengthLv;
            }

            string        key = string.Format("{0}_{1}", (uint)decorate.Pos, lv);
            List <string> rec = DBManager.Instance.QuerySqliteField <string>(GlobalConfig.DBFile, "data_decorate_str", "csv_id", key, "str_attrs");

            if (rec.Count == 0)
            {
                return(ret);
            }

            string raw = rec[0];

            raw = raw.Replace(" ", "");
            var matchs = Regex.Matches(raw, @"\{(\d+),(\d+)\}");

            foreach (Match _match in matchs)
            {
                if (_match.Success)
                {
                    uint attrId    = (DBTextResource.ParseUI(_match.Groups[1].Value));
                    uint attrValue = DBTextResource.ParseUI(_match.Groups[2].Value);
                    ret.Add(attrId, attrValue);
                }
            }

            return(ret);
        }