Ejemplo n.º 1
0
 private static SparePartProperty CopyProperty(SparePartProperty property)
 {
     return(new SparePartProperty()
     {
         AbilityType = property.AbilityType,
         NumRange = property.NumRange,
         Rate = property.Rate,
         DefNum = property.DefNum,
         ValueIndex = property.ValueIndex
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 刷新随机灵件属性
        /// </summary>
        /// <param name="partInfo"></param>
        /// <param name="isDefault"></param>
        /// <param name="ignorePropertys">忽视的</param>
        /// <returns></returns>
        public static SparePartProperty RandomProperty(SparePartInfo partInfo, bool isDefault, CacheList <SparePartProperty> ignorePropertys)
        {
            SparePartProperty partProperty = new SparePartProperty();

            if (partInfo.PropertyRange.Length > 0)
            {
                SparePartProperty ability = RandomAbilityProperty(partInfo, ignorePropertys);
                int rangeIndex            = RandomUtils.GetHitIndex(ability.Rate);
                partProperty = BuildPartProperty(ability, rangeIndex, isDefault);
            }
            return(partProperty);
        }
Ejemplo n.º 3
0
        public static SparePartProperty BuildPartProperty(SparePartProperty property, int rangeIndex, bool isDefault)
        {
            SparePartProperty ability = CopyProperty(property);
            double            valNum  = ability.DefNum;

            if (!isDefault)
            {
                if (rangeIndex < 0)
                {
                    rangeIndex = 0;
                }
                if (rangeIndex >= ability.NumRange.Length)
                {
                    rangeIndex = ability.NumRange.Length - 1;
                }
                ability.ValueIndex = (short)rangeIndex;
                if (rangeIndex < ability.NumRange.Length)
                {
                    if (ability.HitMinValue % 1 == 0)
                    {
                        valNum = RandomUtils.GetRandom(ability.HitMinValue.ToInt(), ability.HitMaxValue.ToInt());
                    }
                    else
                    {
                        int minVal = (int)MathUtils.RoundCustom(ability.HitMinValue * 1000);
                        int maxVal = (int)MathUtils.RoundCustom(ability.HitMaxValue * 1000);
                        int temnum = RandomUtils.GetRandom(minVal, maxVal);
                        valNum = (double)temnum / 1000;
                    }
                }
            }

            SparePartProperty partProperty = new SparePartProperty();

            partProperty.DefNum      = ability.DefNum;
            partProperty.NumRange    = ability.NumRange;
            partProperty.Rate        = ability.Rate;
            partProperty.ValueIndex  = (short)rangeIndex;
            partProperty.AbilityType = ability.AbilityType;
            partProperty.Num         = valNum;
            partProperty.IsEnable    = true;
            return(partProperty);
        }
Ejemplo n.º 4
0
 public SparePartInfo()
     : base(AccessLevel.ReadOnly)
 {
     PropertyRange = new SparePartProperty[0];
     ResetProperty = new SparePartReset[0];
 }
Ejemplo n.º 5
0
 private static SparePartProperty CopyProperty(SparePartProperty property)
 {
     return new SparePartProperty()
     {
         AbilityType = property.AbilityType,
         NumRange = property.NumRange,
         Rate = property.Rate,
         DefNum = property.DefNum,
         ValueIndex = property.ValueIndex
     };
 }
Ejemplo n.º 6
0
 public static void SetSparePartProperty(UserSparePart sparePart, SparePartProperty[] propertys)
 {
     for (int i = 0; i < sparePart.Propertys.Count; i++)
     {
         if (i < propertys.Length)
         {
             sparePart.Propertys[i] = propertys[i];
         }
         else
         {
             sparePart.Propertys[i] = new SparePartProperty() { IsEnable = false };
         }
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 刷新随机灵件属性
 /// </summary>
 /// <param name="partInfo"></param>
 /// <param name="isDefault"></param>
 /// <param name="ignorePropertys">忽视的</param>
 /// <returns></returns>
 public static SparePartProperty RandomProperty(SparePartInfo partInfo, bool isDefault, CacheList<SparePartProperty> ignorePropertys)
 {
     SparePartProperty partProperty = new SparePartProperty();
     if (partInfo.PropertyRange.Length > 0)
     {
         SparePartProperty ability = RandomAbilityProperty(partInfo, ignorePropertys);
         int rangeIndex = RandomUtils.GetHitIndex(ability.Rate);
         partProperty = BuildPartProperty(ability, rangeIndex, isDefault);
     }
     return partProperty;
 }
Ejemplo n.º 8
0
        public static SparePartProperty BuildPartProperty(SparePartProperty property, int rangeIndex, bool isDefault)
        {
            SparePartProperty ability = CopyProperty(property);
            double valNum = ability.DefNum;
            if (!isDefault)
            {
                if (rangeIndex < 0) rangeIndex = 0;
                if (rangeIndex >= ability.NumRange.Length) rangeIndex = ability.NumRange.Length - 1;
                ability.ValueIndex = (short)rangeIndex;
                if (rangeIndex < ability.NumRange.Length)
                {
                    if (ability.HitMinValue % 1 == 0)
                    {
                        valNum = RandomUtils.GetRandom(ability.HitMinValue.ToInt(), ability.HitMaxValue.ToInt());
                    }
                    else
                    {
                        int minVal = (int)MathUtils.RoundCustom(ability.HitMinValue * 1000);
                        int maxVal = (int)MathUtils.RoundCustom(ability.HitMaxValue * 1000);
                        int temnum = RandomUtils.GetRandom(minVal, maxVal);
                        valNum = (double)temnum / 1000;
                    }
                }
            }

            SparePartProperty partProperty = new SparePartProperty();
            partProperty.DefNum = ability.DefNum;
            partProperty.NumRange = ability.NumRange;
            partProperty.Rate = ability.Rate;
            partProperty.ValueIndex = (short)rangeIndex;
            partProperty.AbilityType = ability.AbilityType;
            partProperty.Num = valNum;
            partProperty.IsEnable = true;
            return partProperty;
        }