public virtual void SetRandomShips() { Random rand = new Random(); Ship tempShip; ResetField(); Ships = Ships.OrderBy(x => x.Size).Reverse().ToList(); foreach (var ship in Ships.ToList()) { do { tempShip = Ship.CreateNewShip( new Point(rand.Next(FieldSize), rand.Next(FieldSize)), (Orientation)rand.Next(Enum.GetNames(typeof(Orientation)).Length), ship.Id, ship.Size ); } while (!CanShipBeSet(tempShip)); SetShip(tempShip); } }