Example #1
0
        /// <summary>
        ///     Updates the maximum minimum value.
        /// </summary>
        /// <param name="item">
        ///     The item.
        /// </param>
        /// <param name="heroes">
        ///     The heroes.
        /// </param>
        /// <param name="simulation">
        ///     Indicates whether to use simluation.
        /// </param>
        public void UpdateMaxMinValue(WeightItemWrapper item, List <AIHeroClient> heroes, bool simulation = false)
        {
            var min = float.MaxValue;
            var max = float.MinValue;

            foreach (var hero in heroes)
            {
                var value = item.GetValue(hero);
                if (value < min)
                {
                    min = value;
                }

                if (value > max)
                {
                    max = value;
                }
            }

            if (!simulation)
            {
                item.MinValue = Math.Min(max, min);
                item.MaxValue = Math.Max(max, min);
            }
            else
            {
                item.SimulationMinValue = Math.Min(max, min);
                item.SimulationMaxValue = Math.Max(max, min);
            }
        }
Example #2
0
        /// <summary>
        ///     Sets the weight.
        /// </summary>
        /// <param name="weightItem">
        ///     The weight item.
        /// </param>
        /// <param name="weight">
        ///     The weight.
        /// </param>
        public void SetMenuWeight(WeightItemWrapper weightItem, int weight)
        {
            var item = this.weightsMenu[weightItem.Name];

            if (item != null)
            {
                weightItem.Weight = Math.Max(MinWeight, Math.Min(MaxWeight, weight));
                item.GetValue <MenuSlider>().Value = weightItem.Weight;
            }
        }
Example #3
0
        /// <summary>
        ///     Calculates the weight.
        /// </summary>
        /// <param name="item">
        ///     The item.
        /// </param>
        /// <param name="hero">
        ///     The hero.
        /// </param>
        /// <param name="simulation">Indicates whether to enable simulation.</param>
        /// <returns>
        ///     The <see cref="float" />.
        /// </returns>
        public float Calculate(WeightItemWrapper item, AIHeroClient hero, bool simulation = false)
        {
            var minValue = simulation ? item.SimulationMinValue : item.MinValue;
            var maxValue = simulation ? item.SimulationMaxValue : item.MaxValue;

            if (item.Weight <= MinWeight || maxValue <= 0)
            {
                return(MinWeight);
            }

            var minWeight = minValue > 0 ? item.Weight / (maxValue / minValue) : MinWeight;
            var weight    = item.Inverted
                             ? item.Weight - (item.Weight * item.GetValue(hero) / maxValue) + minWeight
                             : item.Weight * item.GetValue(hero) / maxValue;

            return(float.IsNaN(weight) || float.IsInfinity(weight)
                       ? MinWeight
                       : Math.Min(MaxWeight, Math.Min(item.Weight, Math.Max(MinWeight, Math.Max(weight, minWeight)))));
        }
Example #4
0
        /// <summary>
        ///     Updates the maximum minimum value.
        /// </summary>
        /// <param name="item">
        ///     The item.
        /// </param>
        /// <param name="heroes">
        ///     The heroes.
        /// </param>
        /// <param name="simulation">
        ///     Indicates whether to use simluation.
        /// </param>
        public void UpdateMaxMinValue(WeightItemWrapper item, List<Obj_AI_Hero> heroes, bool simulation = false)
        {
            var min = float.MaxValue;
            var max = float.MinValue;
            foreach (var hero in heroes)
            {
                var value = item.GetValue(hero);
                if (value < min)
                {
                    min = value;
                }

                if (value > max)
                {
                    max = value;
                }
            }

            if (!simulation)
            {
                item.MinValue = Math.Min(max, min);
                item.MaxValue = Math.Max(max, min);
            }
            else
            {
                item.SimulationMinValue = Math.Min(max, min);
                item.SimulationMaxValue = Math.Max(max, min);
            }
        }
Example #5
0
 /// <summary>
 ///     Sets the weight.
 /// </summary>
 /// <param name="weightItem">
 ///     The weight item.
 /// </param>
 /// <param name="weight">
 ///     The weight.
 /// </param>
 public void SetMenuWeight(WeightItemWrapper weightItem, int weight)
 {
     var item = this.weightsMenu[weightItem.Name];
     if (item != null)
     {
         weightItem.Weight = Math.Max(MinWeight, Math.Min(MaxWeight, weight));
         item.GetValue<MenuSlider>().Value = weightItem.Weight;
     }
 }
Example #6
0
        /// <summary>
        ///     Calculates the weight.
        /// </summary>
        /// <param name="item">
        ///     The item.
        /// </param>
        /// <param name="hero">
        ///     The hero.
        /// </param>
        /// <param name="simulation">Indicates whether to enable simulation.</param>
        /// <returns>
        ///     The <see cref="float" />.
        /// </returns>
        public float Calculate(WeightItemWrapper item, Obj_AI_Hero hero, bool simulation = false)
        {
            var minValue = simulation ? item.SimulationMinValue : item.MinValue;
            var maxValue = simulation ? item.SimulationMaxValue : item.MaxValue;
            if (item.Weight <= MinWeight || maxValue <= 0)
            {
                return MinWeight;
            }

            var minWeight = minValue > 0 ? item.Weight / (maxValue / minValue) : MinWeight;
            var weight = item.Inverted
                             ? item.Weight - (item.Weight * item.GetValue(hero) / maxValue) + minWeight
                             : item.Weight * item.GetValue(hero) / maxValue;
            return float.IsNaN(weight) || float.IsInfinity(weight)
                       ? MinWeight
                       : Math.Min(MaxWeight, Math.Min(item.Weight, Math.Max(MinWeight, Math.Max(weight, minWeight))));
        }