private void Bootsetzen(Schiff schiff) { if (schiff.Horizontal) { for (int i = schiff.XKoord; i < schiff.XKoord + schiff.Laenge; i++) { Felder[schiff.YKoord, i].BackColor = Color.Green; } } if (!schiff.Horizontal) { for (int i = schiff.YKoord; i < schiff.YKoord + schiff.Laenge; i++) { Felder[i, schiff.XKoord].BackColor = Color.Green; } } }
private void Item_MouseClick(object sender, MouseEventArgs e) { Schiff schiff = new Schiff(0, 0, 0, true); for (int x = 0; x < Felder.GetLength(0); x++) { for (int y = 0; y < Felder.GetLength(1); y++) { if (Felder[x, y] == (PictureBox)sender) { schiff = new Schiff(4, y, x, true); } } } Bootsetzen(schiff); }