当前位置: 首页>>代码示例>>C#>>正文


C# Stats.Values方法代码示例

本文整理汇总了C#中Stats.Values方法的典型用法代码示例。如果您正苦于以下问题:C# Stats.Values方法的具体用法?C# Stats.Values怎么用?C# Stats.Values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stats的用法示例。


在下文中一共展示了Stats.Values方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateScalingGraph

 public void UpdateScalingGraph(Character character, Stats[] statsList, Stats baseStat, bool requiresReferenceCalculations, Color[] colors, int scale, string explanatoryText, string calculation)
 {
     CharacterCalculationsBase baseCalc = Calculations.GetCharacterCalculations(character);
     if (statsList.Length == 0 || statsList.Length > colors.Length) return; // more than 12 elements for the array would run out of colours
     Point[][] points = new Point[statsList.Length][];
     // extract property data for relative stats calculations
     KeyValuePair<PropertyInfo, float>[] properties = new KeyValuePair<PropertyInfo, float>[statsList.Length];
     for (int index = 0; index < statsList.Length; index++)
     {
         var p = statsList[index].Values(x => x > 0);
         foreach (var kvp in p)
         {
             properties[index] = kvp;
         }
         points[index] = new Point[2 * scale + 1];
     }
     float unit = 1f;
     var bp = baseStat.Values(x => x > 0);
     foreach (var kvp in bp)
     {
         unit = kvp.Value;
     }
     Chart.Series.Clear();
     for (int count = -scale; count <= scale; count++)
     {
         Stats newStats = new Stats();
         newStats.Accumulate(baseStat, count);
         Item item = new Item() { Stats = newStats };
         if (requiresReferenceCalculations)
         {
             Calculations.GetCharacterCalculations(character, item, true, false, false);
         }
         for (int index = 0; index < statsList.Length; index++)
         {
             ComparisonCalculationBase currentCalc = CalculationsBase.GetRelativeStatValue(character, properties[index].Key, item, properties[index].Value);
             float dpsChange = GetCalculationValue(currentCalc, calculation);
             points[index][count + scale] = new Point(count * unit, dpsChange);
         }
     }
     for (int index = 0; index < statsList.Length; index++)
     {
         Style dataPointStyle = new Style(typeof(LineDataPoint));
         dataPointStyle.Setters.Add(new Setter(DataPoint.TemplateProperty, Resources["InvisibleDataPointTemplate"]));
         dataPointStyle.Setters.Add(new Setter(DataPoint.BackgroundProperty, new SolidColorBrush(colors[index])));
         Chart.Series.Add(new LineSeries()
         {
             Title = statsList[index].ToString(),
             ItemsSource = points[index],
             IndependentValuePath = "X",
             DependentValuePath = "Y",
             DataPointStyle = dataPointStyle,
         });
     }
     Chart.Axes.Clear();
     Chart.Axes.Add(new LinearAxis()
     {
         Orientation = AxisOrientation.X,
         Title = "Stat Change",
         ShowGridLines = true,
     });
     Chart.Axes.Add(new LinearAxis()
     {
         Orientation = AxisOrientation.Y,
         Title = calculation,
         ShowGridLines = true,
     });
     // restore reference calculation
     if (requiresReferenceCalculations)
     {
         Stats newStats = new Stats();
         Item item = new Item() { Stats = newStats };
         Calculations.GetCharacterCalculations(character, item, true, false, false);
     }
     orgDataDirty = true;
 }
开发者ID:LucasPeacecraft,项目名称:rawr,代码行数:75,代码来源:Graph.xaml.cs

示例2: RenderScalingGraph

 public static void RenderScalingGraph(Graphics g, int graphWidth, int graphHeight, Character character, Stats[] statsList, Stats baseStat, bool requiresReferenceCalculations, Color[] colors, int scale, string explanatoryText, string calculation, Style style)
 {
     CharacterCalculationsBase baseCalc = Calculations.GetCharacterCalculations(character);
     g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
     g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
     float graphOffset = graphWidth / 2.0f, graphStep = (graphWidth - 100) / 2.0f / scale;
     if (statsList.Length == 0 || statsList.Length > colors.Length) return; // more than 12 elements for the array would run out of colours
     float minDpsChange = 0f, maxDpsChange = 0f;
     PointF[][] points = new PointF[statsList.Length][];
     // extract property data for relative stats calculations
     KeyValuePair<PropertyInfo, float>[] properties = new KeyValuePair<PropertyInfo,float>[statsList.Length];
     for (int index = 0; index < statsList.Length; index++)
     {
         var p = statsList[index].Values(x => x > 0);
         foreach (var kvp in p)
         {
             properties[index] = kvp;
         }
         points[index] = new PointF[2 * scale + 1];
     }
     for (int count = -scale; count <= scale; count++)
     {
         Stats newStats = new Stats();
         newStats.Accumulate(baseStat, count);
         Item item = new Item() { Stats = newStats };
         if (requiresReferenceCalculations)
         {
             Calculations.GetCharacterCalculations(character, item, true, false, false);
         }
         for (int index = 0; index < statsList.Length; index++)
         {
             ComparisonCalculationBase currentCalc = CalculationsBase.GetRelativeStatValue(character, properties[index].Key, item, properties[index].Value);
             float dpsChange = GetCalculationValue(currentCalc, calculation);
             points[index][count + scale] = new PointF(graphOffset + count * graphStep, dpsChange);
             if (dpsChange < minDpsChange)
                 minDpsChange = dpsChange;
             if (dpsChange > maxDpsChange)
                 maxDpsChange = dpsChange;
         }
     }
     // restore reference calculation
     if (requiresReferenceCalculations)
     {
         Stats newStats = new Stats();
         Item item = new Item() { Stats = newStats };
         Calculations.GetCharacterCalculations(character, item, true, false, false);
     }
     // increase the spread a bit to so that you can see if something is at the edges and straight
     float DpsVariance = maxDpsChange - minDpsChange;
     minDpsChange -= DpsVariance * 0.05f;
     maxDpsChange += DpsVariance * 0.05f;
     DpsVariance = maxDpsChange - minDpsChange;
     if (DpsVariance == 0)
         DpsVariance = 1;
     for (int index = 0; index < statsList.Length; index++)
     {
         for (int count = -scale; count <= scale; count++)
         {
             points[index][count + scale].Y = (int)((maxDpsChange - points[index][count + scale].Y) * (graphHeight - 48) / DpsVariance) + 20;
         }
         Brush statBrush = new SolidBrush(colors[index]);
         switch (style)
         {
             case Style.DpsWarr:
                 g.DrawLines(new Pen(statBrush, 3), points[index]);
                 break;
             case Style.Mage:
                 g.DrawLines(new Pen(statBrush, 1), points[index]);
                 break;
         }
     }
     float unit = 1f;
     var bp = baseStat.Values(x => x > 0);
     foreach (var kvp in bp)
     {
         unit = kvp.Value;
     }
     RenderGrid(g, graphWidth, graphHeight, character, statsList, colors, scale, unit, "F", explanatoryText, calculation, style, minDpsChange, maxDpsChange, DpsVariance, false);
 }
开发者ID:LucasPeacecraft,项目名称:rawr,代码行数:79,代码来源:Graph.cs


注:本文中的Stats.Values方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。