示例#1
0
 public void drawWorld(System.Drawing.Graphics g, bool drawPie)
 {
     System.Drawing.Brush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
     Draw(g);
     foreach (Predator a in Player)
     {
         if (drawPie)
         {
             float arc = 180F / a.sensors.Length;
             float f   = a.heading * (360f / (2 * (float)Math.PI)) - 90;
             for (int i = 0; i < a.sensors.Length; f += arc, i++)
             {
                 if (a.sensors[i] > 0)
                 {
                     ((SolidBrush)myBrush).Color = Color.FromArgb(255, (byte)(255 * (1 - a.sensors[i])), (byte)(255 * (1 - a.sensors[i])));
                     g.FillPie(myBrush, a.x - a.radius, Utilities.shiftDown + (a.y - a.radius), a.radius * 2, a.radius * 2, f, arc);
                     //g.DrawPie(Pens.Black, a.x - a.radius, a.y - a.radius, a.radius * 2, a.radius * 2, f, arc);
                 }
                 else
                 {
                     g.DrawPie(Pens.Black, a.x - a.radius, Utilities.shiftDown + (a.y - a.radius), a.radius * 2, a.radius * 2, f, arc);
                 }
             }
         }
         System.Drawing.Pen p = new Pen(System.Drawing.Color.Red, 5f);
         g.DrawLine(p, a.x, Utilities.shiftDown + a.y, a.x + (float)Math.Cos(a.heading) * (25), Utilities.shiftDown + a.y + (float)Math.Sin(a.heading) * (25));
         a.Draw(g);
     }
     foreach (Prey p in Enemy)
     {
         p.Draw(g);
     }
 }
示例#2
0
        void pictureBox_Paint(object sender, PaintEventArgs e)
        {
            var galaxy = GalaxyMap.Instance.Galaxy;

            if (galaxy != null)
            {
                e.Graphics.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                e.Graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                var mapSize = Image.Size.Scale(ZoomFactor);
                if (selectedPlanetDrawing != null)
                {
                    e.Graphics.DrawEllipse(
                        selectionPen,
                        (int)(selectedPlanetDrawing.Position.X * mapSize.Width - SelectionCircleSize / 2),
                        (int)(selectedPlanetDrawing.Position.Y * mapSize.Height - SelectionCircleSize / 2),
                        SelectionCircleSize,
                        SelectionCircleSize);
                }
                var linkImageMaker = new LinkImageGenerator(mapSize, galaxy, "links/");
                Directory.GetFiles(linkImageMaker.ImagePath).ForEach(File.Delete);

                foreach (var link in galaxy.Links)
                {
                    var points = link.PlanetIDs.Select(id => galaxy.GetPlanet(id).Position.Scale(mapSize).ToPoint()).ToArray();
                    using (var p = new Pen(Color.Green, 2)) {
                        e.Graphics.DrawLine(p, points[0], points[1]);
                    }
                }

                GalaxyMap.Instance.PlanetDrawings.ForEach(p => p.Draw(e.Graphics, mapSize));
                GalaxyMap.Instance.PlanetDrawings.ForEach(p => p.Label.Draw(e.Graphics, mapSize));
            }
        }
 public void Draw(Pen pen)
 {
     _stringBuilder.Append("Figure drawn ");
     pen.Draw(_stringBuilder);
     _stringBuilder.AppendLine();
 }