private void DrawChemoeffector(Graphics graphics, Rectangle clip, Chemoeffector chemoeffector, Pen pen, Point[] shape, bool showDetectionZone) { Rectangle bounds; bounds = new Rectangle(chemoeffector.Position.X - (chemoeffector.Strength / 2), chemoeffector.Position.Y - (chemoeffector.Strength / 2), chemoeffector.Strength, chemoeffector.Strength); if (this.ShouldRender(clip, bounds)) { if (showDetectionZone) { if (_outlinesOnly) { graphics.DrawEllipse(pen, bounds); } else { using (GraphicsPath ellipsePath = new GraphicsPath()) { ellipsePath.AddEllipse(bounds); using (PathGradientBrush brush = new PathGradientBrush(ellipsePath)) { brush.CenterPoint = chemoeffector.Position; brush.CenterColor = Color.FromArgb(128, pen.Color); brush.SurroundColors = new[] { Color.Transparent }; graphics.FillEllipse(brush, bounds); } } } } if (_drawShapes) { int x; int y; GraphicsState state; x = chemoeffector.Position.X; y = chemoeffector.Position.Y; state = graphics.Save(); graphics.TranslateTransform(x, y); graphics.RotateTransform(Compass.GetAngle(chemoeffector.Heading)); graphics.DrawPolygon(pen, shape); graphics.Restore(state); } else { graphics.DrawLine(pen, new Point(chemoeffector.Position.X - 1, chemoeffector.Position.Y), new Point(chemoeffector.Position.X + 1, chemoeffector.Position.Y)); graphics.DrawLine(pen, new Point(chemoeffector.Position.X, chemoeffector.Position.Y - 1), new Point(chemoeffector.Position.X, chemoeffector.Position.Y + 1)); } } }
private void DrawNoxious(Graphics graphics, Rectangle clip, Chemoeffector noxious) { this.DrawChemoeffector(graphics, clip, noxious, _repellentPen, _repellentShape, _showNoxiousDetectionZone); }
private void DrawFood(Graphics graphics, Rectangle clip, Chemoeffector food) { this.DrawChemoeffector(graphics, clip, food, _attractorPen, _attractorShape, _showFoodDetectionZone); }
public static void AreEqual(Chemoeffector expected, Chemoeffector actual) { Assert.AreEqual(expected.Heading, actual.Heading, nameof(Chemoeffector.Heading) + " does not match."); Assert.AreEqual(expected.Position, actual.Position, nameof(Chemoeffector.Position) + " does not match."); Assert.AreEqual(expected.Strength, actual.Strength, nameof(Chemoeffector.Strength) + " does not match."); }