public bool AutomaticShipCoordinates2() { int shipCount = 0; while (true) { Ships shipType = (Ships)shipCount; x_coord = rnd.Next(1, boardSize + 1); y_coord = rnd.Next(1, boardSize + 1); Player2ShipCoordinates.Add(x_coord.ToString() + y_coord.ToString()); direction = GameBoard.directionNumberToString[rnd.Next(0, 2)]; shipLength = shipCount; if (ShipLocationCheck2(x_coord, y_coord, StringToEnum(direction), shipType)) { Player2ShipCoordinates.Add(x_coord.ToString() + y_coord.ToString()); Player2ShipDirections.Add(StringToEnum(direction)); PlaceOneShip(Player2Board1); shipCount++; if (shipCount == 5) { break; } } else { return(false); } } return(true); }
public void ManualShipCoordinates2() { //ask player 2 for ship coordinates Console.WriteLine(GetBoardString21()); Console.WriteLine("Please enter the vertical coordinate of your carrier (1-...)"); x_coord_string = Console.ReadLine(); Console.WriteLine("Please enter the horizontal coordinate of your carrier (a-...)"); y_coord = letterToNumber[Console.ReadLine()]; Player2ShipCoordinates.Add(x_coord_string + y_coord.ToString()); Console.WriteLine( "Please enter the direction of the ship: \"W\" - west, \"N\" - north, \"E\" - east, \"S\" - south"); direction = Console.ReadLine().ToUpper(); Player2ShipDirections.Add(StringToEnum(direction)); Console.WriteLine(GetBoardString21()); Console.WriteLine("Please enter the vertical coordinate of your battleship (1-...)"); x_coord_string = Console.ReadLine(); Console.WriteLine("Please enter the horizontal coordinate of your battleship (a-...)"); y_coord = letterToNumber[Console.ReadLine()]; Player2ShipCoordinates.Add(x_coord_string + y_coord.ToString()); Console.WriteLine( "Please enter the direction of the ship: \"W\" - west, \"N\" - north, \"E\" - east, \"S\" - south"); direction = Console.ReadLine().ToUpper(); Player2ShipDirections.Add(StringToEnum(direction)); Console.WriteLine(GetBoardString21()); Console.WriteLine("Please enter the vertical coordinate of your submarine (1-...)"); x_coord_string = Console.ReadLine(); Console.WriteLine("Please enter the horizontal coordinate of your submarine (a-...)"); y_coord = letterToNumber[Console.ReadLine()]; Player2ShipCoordinates.Add(x_coord_string + y_coord.ToString()); Console.WriteLine( "Please enter the direction of the ship: \"W\" - west, \"N\" - north, \"E\" - east, \"S\" - south"); direction = Console.ReadLine().ToUpper(); Player2ShipDirections.Add(StringToEnum(direction)); Console.WriteLine(GetBoardString21()); Console.WriteLine("Please enter the vertical coordinate of your cruiser (1-...)"); x_coord_string = Console.ReadLine(); Console.WriteLine("Please enter the horizontal coordinate of your cruiser (a-...)"); y_coord = letterToNumber[Console.ReadLine()]; Player2ShipCoordinates.Add(x_coord_string + y_coord.ToString()); Console.WriteLine( "Please enter the direction of the ship: \"W\" - west, \"N\" - north, \"E\" - east, \"S\" - south"); direction = Console.ReadLine().ToUpper(); Player2ShipDirections.Add(StringToEnum(direction)); Console.WriteLine(GetBoardString21()); Console.WriteLine("Please enter the vertical coordinate of your patrol (1-...)"); x_coord_string = Console.ReadLine(); Console.WriteLine("Please enter the horizontal coordinate of your patrol (a-...)"); y_coord = letterToNumber[Console.ReadLine()]; Player2ShipCoordinates.Add(x_coord_string + y_coord.ToString()); Console.WriteLine( "Please enter the direction of the ship: \"W\" - west, \"N\" - north, \"E\" - east, \"S\" - south"); direction = Console.ReadLine().ToUpper(); Player2ShipDirections.Add(StringToEnum(direction)); }
public void AutomaticShipCoordinates2() { for (int i = 0; i < 5; i++) { StringBuilder sb1 = new StringBuilder(); sb1.Append(random.Next(0, 10).ToString()); sb1.Append(random.Next(0, 10).ToString()); Player2ShipCoordinates.Add(sb1.ToString()); Player2ShipDirections.Add(NumberToEnum(random.Next(0, 4))); } }