private void drawRobotBody(Robot robot, Pen pen, Graphics g) { PointF[] spike = DrawerUtils.Rotate(AngleUtils.ToRads(robot.ANGLE), PointF.Empty, DefaultDrawer.spike); PointF[] bottom = DrawerUtils.Rotate(AngleUtils.ToRads(robot.ANGLE), PointF.Empty, DefaultDrawer.bottom); PointF robotPosition = robot.GetPosition(); Pen teamPen = DefaultDrawer.GetTeamPen(robot.TEAM_ID); lock (g) { lock (teamPen) { float oldTeamPenWidth = teamPen.Width; teamPen.Width = 5; g.DrawLines(teamPen, DrawerUtils.Translate(robotPosition, spike)); teamPen.Width = oldTeamPenWidth; } lock (pen) { pen.Width = 5; g.DrawLines(pen, DrawerUtils.Translate(robotPosition, bottom)); } lock (Brushes.Red) { g.FillEllipse(Brushes.Red, robotPosition.X - 1, robotPosition.Y - 1, 2, 2); } } }
/// <inheritdoc /> public void DrawScan(Scan scan, Graphics g, int turn) { int index = turn; Pen pen = scannerPen[index]; double startAngle = scan.ANGLE - scan.PRECISION + 360; double stopAngle = scan.ANGLE + scan.PRECISION + 360; if (turn == 0) { PointF scanPosition = scan.GetPosition(); PointF endScan1 = DrawerUtils.Translate(scanPosition, DrawerUtils.Rotate(AngleUtils.ToRads(startAngle), PointF.Empty, new PointF((float)scan.DISTANCE, 0F))); PointF endScan2 = DrawerUtils.Translate(scanPosition, DrawerUtils.Rotate(AngleUtils.ToRads(stopAngle), PointF.Empty, new PointF((float)scan.DISTANCE, 0F))); lock (g) { lock (pen) { pen.Width = 2; g.DrawLine(pen, scanPosition, endScan1); g.DrawLine(pen, scanPosition, endScan2); } } } RectangleF circle = new RectangleF( (float)(scan.X - scan.DISTANCE), (float)(scan.Y - scan.DISTANCE), (float)scan.DISTANCE * 2, (float)scan.DISTANCE * 2 ); if (scan.PRECISION > 0 && scan.DISTANCE > 0) { lock (g) { lock (pen) { g.DrawArc(pen, circle, (float)startAngle, (float)scan.PRECISION * 2); } } } }