public override bool Draw() { if (!base.Draw()) { return(false); } int currentTime = GameBase.Time - startTime; Vector2 drawOffset = (SpriteManager.Current.ScrollOffset - SpriteManager.Current.ViewOffset) * GameBase.WindowManager.Ratio; if (graphLine.Count > 0 && (currentTime <= lengthMs || drawOffset != lastDrawOffset)) { drawList.Clear(); double lengthRequired = graphLength * (Math.Min(lengthMs, (float)currentTime / lengthMs)); foreach (ColouredLine l in graphLine) { if (l.rho < lengthRequired) { ColouredLine c = l.Clone() as ColouredLine; c.p1 += drawOffset; c.p2 += drawOffset; drawList.Add(c); lengthRequired -= l.rho; } else { drawList.Add(new ColouredLine(l.p1 + drawOffset, l.p1 + Vector2.Normalize(l.p2 - l.p1) * (float)lengthRequired + drawOffset, l.colour)); break; } } lastDrawOffset = drawOffset; } if (drawList.Count > 0) { GameBase.LineManager.Draw(drawList, GameBase.Tournament ? 1 : 2, Color.Green, 0, @"StandardNoGradient", true, true); } return(true); }
internal HealthGraph(int startTime, int lengthMS, Score score, RectangleF region) : base(true) { Depth = 0.85f; this.score = score; this.startTime = startTime; this.lengthMs = lengthMS; this.InitialRegion = region; if (score.HpGraph != null && score.HpGraph.Count > 0) { float time1 = score.HpGraph[0].X; float time2 = score.HpGraph[score.HpGraph.Count - 1].X; float ratio = (float)(region.Width) / (time2 - time1); List <Vector2> lowResGraph = new List <Vector2>(); lowResGraph.AddRange(score.HpGraph); while (lowResGraph.Count > 100) { for (int i = lowResGraph.Count - 1; i >= 0 && i < lowResGraph.Count; i -= 2) { lowResGraph.RemoveAt(i); } } Vector2[] va = lowResGraph.ToArray(); for (int i = 0; i < va.Length; i++) { va[i].X = GameBase.WindowManager.Ratio * ((va[i].X - time1) * ratio + region.X); bool ok = va[i].Y > 0.5; va[i].Y = GameBase.WindowManager.Ratio * ((1 - va[i].Y) * region.Height + region.Y); if (i > 0) { ColouredLine l = new ColouredLine(va[i - 1], va[i], (ok ? Color.YellowGreen : Color.Red)); graphLine.Add(l); graphLength += l.rho; } } } }