public void Move(KolobokEventArgs kolobokEventArgs) { if (kolobokEventArgs.Directions == Direction.RIGHT) { CurrentPosition.X += (20 * Speed); } else if (kolobokEventArgs.Directions == Direction.LEFT) { CurrentPosition.X -= (20 * Speed); } else if (kolobokEventArgs.Directions == Direction.UP) { CurrentPosition.Y -= (20 * Speed); } else if (kolobokEventArgs.Directions == Direction.DOWN) { CurrentPosition.Y += (20 * Speed); } if (kolobok != null) { kolobok.ShotEvent -= Kolobok_ShotEvent; } if (tank != null) { tank.ShotEvent -= Kolobok_ShotEvent; } }
internal void Shot() { KolobokEventArgs kolobokEventArgs = new KolobokEventArgs(CurrentPosition, Directions); Shot shot = new Shot(imageList, this); positionsOfShot.Add(shot); OnShot(kolobokEventArgs); }
private void Kolobok_ShotEvent(object sender, EventArgs e) { if (e is KolobokEventArgs) { KolobokEventArgs kolobokEventArgs = e as KolobokEventArgs; Directions = kolobokEventArgs.Directions; Move(kolobokEventArgs); } }
public void OnShot(KolobokEventArgs e) { EventHandler shotEvent = ShotEvent; shotEvent?.Invoke(this, e); }