private void Game1_MouseDown(object sender, MouseEventArgs e) { s = null; if (boardCreated == false) { g = CreateGraphics(); int x = e.X; int y = e.Y; if (s1.GetPosition() == true) { if (x >= s1.GetX() && x <= s1.GetX() + 22 && y >= s1.GetY() && y <= s1.GetY() + 125)//ship5 { s = this.s1; } } else if (x >= s1.GetX() && x <= s1.GetX() + 125 && y >= s1.GetY() && y <= s1.GetY() + 22) { s = this.s1; } if (s2.GetPosition() == true) { if (x >= s2.GetX() && x <= s2.GetX() + 22 && y >= s2.GetY() && y <= s2.GetY() + 105)//ship4 { s = this.s2; } } else if (x >= s2.GetX() && x <= s2.GetX() + 105 && y >= s2.GetY() && y <= s2.GetY() + 22) { s = this.s2; } if (s3.GetPosition() == true) { if (x >= s3.GetX() && x <= s3.GetX() + 22 && y >= s3.GetY() && y <= s3.GetY() + 85)//ship3 { s = this.s3; } } else if (x >= s3.GetX() && x <= s3.GetX() + 85 && y >= s3.GetY() && y <= s3.GetY() + 22) { s = this.s3; } if (s4.GetPosition() == true) { if (x >= s4.GetX() && x <= s4.GetX() + 22 && y >= s4.GetY() && y <= s4.GetY() + 85)//ship3(2) { s = this.s4; } } else if (x >= s4.GetX() && x <= s4.GetX() + 85 && y >= s4.GetY() && y <= s4.GetY() + 22) { s = this.s4; } if (s5.GetPosition() == true) { if (x >= s5.GetX() && x <= s5.GetX() + 22 && y >= s5.GetY() && y <= s5.GetY() + 65)//ship2 { s = this.s5; } } else if (x >= s5.GetX() && x <= s5.GetX() + 65 && y >= s5.GetY() && y <= s5.GetY() + 22) { s = this.s5; } if (s != null) { if (x >= 400 && x <= 700 && y >= 270 && y <= 570)//האם הלחיצה הייתה בגבולות המשחק { int oldI = (s.GetY() - 150) / 30; int oldJ = (s.GetX() - 280) / 30; if (game1.GetBoard()[oldI, oldJ].GetShip() != null) { game1.RemoveShipOfBoard(oldI, oldJ); } } } } }