Exemplo n.º 1
0
    private List <AttributePreviewDetail> GetAttributeDetails(EvolveEquipInfo info)
    {
        var list = new List <AttributePreviewDetail>();

        if (info.attributes == null)
        {
            return(list);
        }

        foreach (var item in info.attributes)
        {
            //获取道具的初始属性
            var originalAttri = PropItemInfo.GetBaseAttribute(itemInfo, item.id);
            //计算属性(百分比或者累加)
            var value = ItemAttachAttr.CalculateAttributeValue(originalAttri, item);

            if (!ContainSameAttirbutePreview(list, item.id))
            {
                double oldValue = data.GetFixedAttirbute(item.id);
                if (oldValue == 0 && value == 0)
                {
                    continue;
                }

                var de = new AttributePreviewDetail(item.id);
                de.oldValue = oldValue;
                //must before set newValue
                de.FixPercentAttribute();
                de.newValue = de.oldValue + value;
                list.Add(de);
            }
            else
            {
                var de = list.Find(o => o.id == item.id);
                de.newValue += value;
            }
        }

        return(list);
    }
Exemplo n.º 2
0
    private List <AttributePreviewDetail> GetAttributePreview()
    {
        var list = new List <AttributePreviewDetail>();

        //add preview attirbute change
        if (m_previewIntentifyInfo != null)
        {
            List <IntentifyEquipInfo> allIntents = moduleEquip.GetGetIntentifyInfos(equipType, data.GetIntentyLevel(), m_previewIntentifyInfo.level);

            foreach (var item in allIntents)
            {
                if (item.attributes == null)
                {
                    continue;
                }
                foreach (var attri in item.attributes)
                {
                    //获取道具的初始属性
                    var originalAttri = PropItemInfo.GetBaseAttribute(itemInfo, attri.id);
                    //计算属性(百分比或者累加)
                    var value = m_previewIntentifyInfo.level == data.GetIntentyLevel() ? 0 : ItemAttachAttr.CalculateAttributeValue(originalAttri, attri);

                    //未包含就把初始值填充进去
                    if (!ContainSameAttirbutePreview(list, attri.id))
                    {
                        double oldValue = data.GetFixedAttirbute(attri.id);
                        if (oldValue <= 0 && value <= 0)
                        {
                            continue;
                        }

                        var de = new AttributePreviewDetail(attri.id);
                        de.oldValue = oldValue;
                        //must before set newValue
                        de.FixPercentAttribute();
                        de.newValue = de.oldValue + value;
                        list.Add(de);
                    }
                    //已经添加了就开始操作缓存
                    else
                    {
                        var d = list.Find(o => o.id == attri.id);
                        d.newValue += value;
                    }
                }
            }
        }
        //添加初始化属性
        else
        {
            if (data.GetIntentyLevel() > 0 && !data.InvalidGrowAttr())
            {
                PItemAttachAttr[] attris = data.growAttr.equipAttr.fixedAttrs;
                foreach (var item in attris)
                {
                    if (item.type == 2)
                    {
                        continue;
                    }

                    var de = new AttributePreviewDetail(item.id);
                    de.oldValue = item.value;
                    de.newValue = item.value;
                    de.FixPercentAttribute();
                    list.Add(de);
                }
            }
            else
            {
                PropItemInfo info = data.GetPropItem();
                if (info && info.attributes != null)
                {
                    foreach (var item in info.attributes)
                    {
                        if (item.type == 2)
                        {
                            continue;
                        }

                        var de = new AttributePreviewDetail(item.id);
                        de.oldValue = item.value;
                        de.newValue = item.value;
                        de.FixPercentAttribute();
                        list.Add(de);
                    }
                }
            }
        }

        return(list);
    }