Ejemplo n.º 1
0
        void RefreshWeaponAttr()
        {
            var config = GetConfig();

            viewModel.AttrGroupActive = false;
            WeaponProperty contrastProperty = new WeaponProperty();

            if (config.Category == (int)ECategory.Weapon ||
                config.Category == (int)ECategory.WeaponPart) //需要加上武器配件的//
            {
                if (IsWeaponAvatar(config))
                {
                    return;
                }
                if (curShowTipData.NeedContrast())
                {
                    contrastProperty = GetWeaponProperty(curShowTipData.ContrastTemId);
                }
                viewModel.AttrGroupActive = true;
                arrtDataList.Clear();//todo
                WeaponProperty wp = new WeaponProperty();
                if (config.Category == (int)ECategory.Weapon)
                {
                    wp = GetWeaponProperty(config.Id);

                    if (IsMyWeapon())//todo,还需添加装备配件的属性
                    {
                        foreach (var it in curShowTipData.WeaponPartsList)
                        {
                            var newWp = GetWeaponProperty(it.Id);
                            wp.Add(newWp);
                        }
                    }
                }

                foreach (var item in TipConst.WeaponPropertyName)
                {
                    string propertyName = item.Key;
                    if (propertyName.Equals(TipConst.BulletPropertyName) ||
                        propertyName.Equals(TipConst.MaxBulletPropertyName))
                    {
                        continue;
                    }

                    var   cpropertyInfo = wp.GetType().GetField(propertyName);
                    float propertyValue = (float)cpropertyInfo.GetValue(wp);
                    if (propertyValue > 0)
                    {
                        var itemData = new ContrastPropertyItemData()
                        {
                            IsBullet = false,
                            Value    = propertyValue,
                            Name     = TipConst.GetWeaponPropertyName(propertyName),
                        };
                        if (curShowTipData.NeedContrast())
                        {
                            var contrastProperValue = (float)cpropertyInfo.GetValue(contrastProperty);
                            itemData.DiffValue = itemData.Value - contrastProperValue;
                        }
                        arrtDataList.Add(itemData);
                    }
                }

                int BulletValue    = wp.Bullet;
                int MaxBulletValue = wp.Bulletmax;
                if (BulletValue != 0 && MaxBulletValue != 0)
                {
                    var itemData = new ContrastPropertyItemData()
                    {
                        IsBullet  = true,
                        Bullet    = BulletValue,
                        MaxBullet = MaxBulletValue,
                        Name      = TipConst.GetWeaponPropertyName(TipConst.BulletPropertyName),
                    };
                    arrtDataList.Add(itemData);
                }

                attrUIList.SetDataList <WeaponPropertyBarItem, ContrastPropertyItemData>(arrtDataList);
            }
        }
Ejemplo n.º 2
0
 void RefreshWeaponPartsItem(List <TipPartUiData> slotList)
 {
     partsUIList.SetDataList <TipPartItem, TipPartUiData>(slotList);
 }