/** * 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); } }
/** * Überschreibt MouseDown aus Moving Object * Material welches sich im Magazin befindet wird aus dem Magazin entfernt ! */ public override void pictureBox_MouseDown(object sender, MouseEventArgs e) { foreach (Control cc in Form1.instance.Controls) { if (cc.HasChildren) { if (cc is Magazin) { Magazin ma = (Magazin)cc; if (ma.pool.IndexOf(this) != -1) { ma.pool.Remove(this); this.inMagzin = false; } } } } block = false; base.pictureBox_MouseDown(sender, e); }