public override void PlaceCombatants(SafeDictionary <ICombatant, IntVector2> locations) { if (Sector.SpaceObjects.OfType <WarpPoint>().Any()) { // HACK - warp point in sector, assume someone warped // TODO - do this for warp point exits instead since warp points may be one way // warp battles start with everyone mashed together to allow blockades foreach (var c in Combatants.OrderByDescending(q => q.Size)) { PlaceCombatant(locations, 0, 0, c); } } else { // place all combatants at the points of a regular polygon var sideLength = 20 + (int)Math.Ceiling((double)Combatants.GroupBy(q => q.Owner).Max(q => q.Count())); // make sure no one can shoot each other at the start // https://stackoverflow.com/questions/32169875/calculating-the-coordinates-of-a-regular-polygon-given-its-center-and-its-side-l var radius = sideLength / (2 * Sin(PI / Empires.Count())); var combs = Combatants.ToArray(); for (int i = 0; i < Empires.Count(); i++) { var x = radius * Cos(PI / Empires.Count() * (1 + 2 * i)); var y = radius * Sin(PI / Empires.Count() * (1 + 2 * i)); foreach (var comb in Combatants.Where(q => q.Owner == Empires.ElementAt(i)).OrderByDescending(q => q.Size)) { PlaceCombatant(locations, x, y, comb); } } } }
private void PlotCities(PlotModel m) { if (Empires == null) { return; } AddXDatesAxis(m); //miasta LinearAxis citiesY = new LinearAxis(); citiesY.Title = Labels.Cities; citiesY.Key = "cities"; citiesY.Position = AxisPosition.Right; citiesY.MajorGridlineStyle = LineStyle.None; citiesY.MinorGridlineStyle = LineStyle.None; m.Axes.Add(citiesY); foreach (var empire in Empires.OrderBy(x => x.Key.CitiesNo)) { OxyPlot.Series.StairStepSeries citiesSerie = new OxyPlot.Series.StairStepSeries(); citiesSerie.XAxisKey = "x"; citiesSerie.YAxisKey = "cities"; citiesSerie.VerticalStrokeThickness = 0.2; citiesSerie.MarkerType = MarkerType.None; citiesSerie.Title = string.Format("{0} ({1})", empire.Key.PlayerName, empire.Key.AlianceName); foreach (var hr in empire.Value.OrderBy(x => x.CreateDT.Value)) { citiesSerie.Points.Add(DateTimeAxis.CreateDataPoint(hr.CreateDT.Value, hr.CitiesNo)); } m.Series.Add(citiesSerie); } }
private void PlotScore(PlotModel m) { if (Empires == null) { return; } AddXDatesAxis(m); //punktacja LinearAxis scoreY = new LinearAxis(); if (DiffScore) { scoreY.Title = Labels.ScoreSpeed; } else { scoreY.Title = Labels.Score; } scoreY.Key = "score"; scoreY.Position = AxisPosition.Left; scoreY.MajorGridlineStyle = LineStyle.Solid; scoreY.MinorGridlineStyle = LineStyle.Dot; m.Axes.Add(scoreY); foreach (var empire in Empires.OrderBy(x => x.Key.Rank)) { long lastScore = -1; double scoreValue = 0; DateTime lastTime = DateTime.Now; double deltaTime = 0; OxyPlot.Series.LineSeries ls = new OxyPlot.Series.LineSeries(); ls.XAxisKey = "x"; ls.YAxisKey = "score"; ls.MarkerType = MarkerType.Diamond; ls.Title = string.Format("{0} ({1})", empire.Key.PlayerName, empire.Key.AlianceName); foreach (var hr in empire.Value.OrderBy(x => x.CreateDT.Value)) { if (DiffScore) { if (lastScore < 0) { //pierwszy wynik, zaczynam od zera lastScore = hr.Score; lastTime = hr.CreateDT.Value; scoreValue = 0; } else { deltaTime = (hr.CreateDT.Value - lastTime).TotalMinutes; //liczę przyrosty na minutę, jeżeli czas między pomiaram > 3h, inaczej nie ma to sensu - za wolno punkty przyrastają i będąg głupoty if (deltaTime > 180) { scoreValue = (hr.Score - lastScore) / deltaTime; lastScore = hr.Score; lastTime = hr.CreateDT.Value; } } } else { scoreValue = hr.Score; } if (((DiffScore && (deltaTime > 60)) || !DiffScore) && ShowScore) { ls.Points.Add(DateTimeAxis.CreateDataPoint(hr.CreateDT.Value, scoreValue)); } } m.Series.Add(ls); } }