Esempio n. 1
0
 /**
  * Material Bewegen (wird Aufgerufen durch den Timer in Form
  */
 public virtual void move()
 {
     dx = 0;
     dy = 0;
     if (!selected)
     {
         foreach (Control cc in Form1.instance.Controls)
         {
             if (cc.HasChildren)
             {
                 if (cc is Rutsche)
                 {
                     Rutsche ru = (Rutsche)cc;
                     Point   p  = new Point(Location.X + Width / 2, Location.Y + Height / 2);
                     if (ru.pointInObject(p) && !this.inMagzin)
                     {
                         dx = 1;
                     }
                 }
                 else if (cc is Band)
                 {
                     Band  ba = (Band)cc;
                     Point p  = new Point(Location.X + Width / 2, Location.Y + Height / 2);
                     if (ba.pointInObject(p) && !this.inMagzin)
                     {
                         dx = ba.getSpeed();
                     }
                 }
                 else if (cc is Magazin)
                 {
                     Magazin ma = (Magazin)cc;
                     Point   p  = new Point(Location.X + Width / 2, Location.Y + Height);
                     if (ma.pointInObject(p) && !this.hasGround(4) && ma.pool.IndexOf(this) != -1)
                     {
                         dy = 4;
                     }
                 }
             }
         }
         offsetX  = dx;
         offsetY  = dy;
         Location = new Point(Location.X + dx, Location.Y + dy);
     }
 }
Esempio n. 2
0
 /**
  * Überschreibt MouseDown aus Moving Object
  * Material, welches auf Rutsche losgelassen wird, wir auf der Rutsche vertikal zentriert
  */
 public override void pictureBox_MouseUp(object sender, MouseEventArgs e)
 {
     Console.WriteLine("Material Mouse Down!");
     foreach (Control cc in Form1.instance.Controls)
     {
         if (cc.HasChildren)
         {
             if (cc is Rutsche)
             {
                 Rutsche ru      = (Rutsche)cc;
                 Point   pcenter = new Point(Location.X + Width / 2, Location.Y + Height / 2);
                 if (ru.pointInObject(pcenter))
                 {
                     Console.WriteLine("Material über Rutsche losgelassen");
                     this.Location = new Point(this.Location.X, ru.Location.Y + ru.Height / 2 - this.Height / 2);
                 }
             }
         }
     }
     base.pictureBox_MouseUp(sender, e);
 }