public void Draw(Renderer renderer) { int polys = 0; Context g = renderer.Context; int padding = 32; VGame.Rectangle r = new VGame.Rectangle((int)Math.Round(Client.Local.ViewOrigin.X) - padding, (int)Math.Round(Client.Local.ViewOrigin.Y) - padding, Client.Local.Game.Renderer.Width + 2 * padding, Client.Local.Game.Renderer.Height + 2 * padding); double scale = renderer.GetUnitSize(); foreach (Polygon p in Terrain) { Polygon sp = p.ScaleAndOffset(scale, -Client.Local.ViewPosition + Client.Local.ViewOrigin); bool draw = false; foreach (Line l in sp.Lines) { if (r.IntersectsLine(new Vector2((float)(l.Point1.X), (float)(l.Point1.Y)), new Vector2((float)(l.Point2.X), (float)(l.Point2.Y)))) { draw = true; break; } } if (draw || sp.Contains(r)) { p.Draw(renderer, -Client.Local.ViewPosition + Client.Local.ViewOrigin, scale); polys++; } /*g.MoveTo(r.X, r.Y); g.LineTo(r.X + r.Width, r.Y); g.LineTo(r.X + r.Width, r.Y + r.Height); g.LineTo(r.X, r.Y + r.Height); g.ClosePath(); renderer.StrokeAndFill(new Color(0.2, 0.5, 0.2, 0.5), new Color(0.2, 0.5, 0.2, 0.25));*/ } foreach (Tuple<Line, Color> t in Decorations) { if (r.IntersectsLine(t.Item1.Point1, t.Item1.Point2)) { g.MoveTo((new Vector2((float)(t.Item1.Point1.X * scale), (float)(t.Item1.Point1.Y * scale)) - Client.Local.ViewPosition + Client.Local.ViewOrigin).ToPointD()); g.LineTo((new Vector2((float)(t.Item1.Point2.X * scale), (float)(t.Item1.Point2.Y * scale)) - Client.Local.ViewPosition + Client.Local.ViewOrigin).ToPointD()); renderer.SetColor(new Color(t.Item2.R, t.Item2.G, t.Item2.B, 0.4)); g.Stroke(); } } //renderer.DrawText(Client.Local.ViewOrigin, string.Format("polys: {0}", polys), 20, TextAlign.Left, TextAlign.Top, ColorPresets.White, ColorPresets.Black, null, 0, null); }
public static void Read() { if (!File.Exists("settings")) return; List<string> conf = File.ReadAllLines("settings").ToList(); PlayerName = conf[0]; PlayerNumber = int.Parse(conf[1]); LastServerAddress = conf[2]; Fullscreen = bool.Parse(conf[3]); Borderless = bool.Parse(conf[4]); DoubleBuffered = bool.Parse(conf[5]); Antialiasing = bool.Parse(conf[6]); int w, h; w = int.Parse(conf[7]); h = int.Parse(conf[8]); Resolution = new VGame.Rectangle(0, 0, w, h); }