static void CreateRandomShape() { Random rnd = new Random(); switch (rnd.Next(0, 3)) { case 0: { ProtocolModel.Shapes shape = new ProtocolModel.Shapes { Type = 0, Color = Color.Red, Point = new RectangleF(new PointF(rnd.Next(0, GamePanelSizeX), rnd.Next(0, GamePanelSizeY)), new SizeF(50, 50)) }; ShapesPanel.Add(shape); break; } case 1: { ProtocolModel.Shapes shape = new ProtocolModel.Shapes { Type = 1, Color = Color.Blue, Point = new RectangleF(new PointF(rnd.Next(0, GamePanelSizeX), rnd.Next(0, GamePanelSizeY)), new SizeF(30, 30)) }; ShapesPanel.Add(shape); break; } case 2: { ProtocolModel.Shapes shape = new ProtocolModel.Shapes { Type = 2, Color = Color.Yellow, Point = new RectangleF(new PointF(rnd.Next(0, GamePanelSizeX), rnd.Next(0, GamePanelSizeY)), new SizeF(40, 40)) }; ShapesPanel.Add(shape); break; } } BroadcastShapes(); }
// CreateShape: Create a shape using the specified arguments, updating and re-broadcasting the ShapesPanel afterwards private static void CreateShape(ProtocolModel.ShapeType type, Color color, int sizeX, int sizeY, int posX, int posY, int value, int ticksExisted = 0) { ProtocolModel.Shape shape = new ProtocolModel.Shape { Type = type, Color = color, Location = new RectangleF(new PointF(posX, posY), new SizeF(sizeX, sizeY)), Value = value, TicksExisted = ticksExisted }; SyncShapeTicks(); if (ShapesPanel.Count < MaxShapeCount) { ShapesPanel.Add(shape); BroadcastShapes(); } }