Ejemplo n.º 1
0
 public BallConsumer(BallCommonData data, Rectangle rect, int x, int y, int radius, Animator animator) : base(rect)
 {
     rectangle     = rect;
     this.radius   = radius;
     this.animator = animator;
     this.data     = data;
     position      = new Point(x, y);
     pen           = new Pen(Color.Black, 5);
     brush         = new SolidBrush(color);
 }
Ejemplo n.º 2
0
 public BallProducer(BallCommonData data, int id, int x, int y, int radius, Rectangle rect, Animator animator, Point destination, Color color) : base(rect)
 {
     position         = new Point(x, y);
     this.destination = destination;
     this.data        = data;
     this.color       = color;
     this.radius      = radius;
     this.id          = id;
     if (_animator == null)
     {
         _animator = animator;
     }
     rand = new Random((int)DateTime.Now.Ticks);
     Start();
 }
Ejemplo n.º 3
0
 private void panel1_Click(object sender, EventArgs e)
 {
     if (flag)
     {
         Point consumerPos = new Point(panel1.Width / 2 - radius, panel1.Height / 10 * 9 - radius);
         commonData       = new BallCommonData(3, animator, consumerPos);
         ballConsumer     = new BallConsumer(commonData, rect, consumerPos.X, consumerPos.Y, radius, animator);
         ballProducers    = new BallProducer[3];
         ballProducers[0] = new BallProducer(commonData, 0, panel1.Width / 2 - radius, 0, radius, rect, animator, consumerPos, Color.Red);
         ballProducers[1] = new BallProducer(commonData, 1, 0, 0, radius, rect, animator, consumerPos, Color.Green);
         ballProducers[2] = new BallProducer(commonData, 2, panel1.Width - 2 * radius, 0, radius, rect, animator, consumerPos, Color.Blue);
         animator.Start(ballConsumer);
         animator.Start(ballProducers[0]);
         animator.Start(ballProducers[1]);
         animator.Start(ballProducers[2]);
         flag = false;
     }
 }