public static bool IsThisPositionFreeFromOtherBoats(BattleshipBoat boat, int x1, int y1, int x2, int y2) { if (boat.X1 == x1 && boat.Y1 == y1 || boat.X1 == x2 && boat.Y1 == y2) { return(false); } return(true); }
public static bool IsThisPositionFreeFromOtherBoats(BattleshipBoat boat, BattleshipBoat boat2, int x1, int y1, int x2, int y2, int x3, int y3) { List <BattleshipBoat> listBoats = new List <BattleshipBoat>(); listBoats.Add(boat); listBoats.Add(boat2); foreach (BattleshipBoat boats in listBoats) { if (boat.X1 == x1 && boat.Y1 == y1 || boat.X1 == x2 && boat.Y1 == y2 || boat.X1 == x3 && boat.Y1 == y3) { return(false); } if (boat is Ship) { if (boat.X2 == x1 && boat.Y2 == y1 || boat.X2 == x2 && boat.Y2 == y2 || boat.X2 == x3 && boat.Y2 == y3) { return(false); } } } return(true); }