public BoardPlacement(StartPageData startPageData) { InitializeComponent(); completeClean(); this.startPageData = startPageData; Narrator.placing(narratorTxt, startPageData.getPlayerName()); battleboard = new Board(battleGrid); battleships = new Ship[5]; randomize(battleships); }
public BoardPlacement(StartPageData startPageData) { InitializeComponent(); completeClean(); /* Saving startPageData from previous StartPage while the user is choosing his ships and settings*/ this.startPageData = startPageData; Narrator.placing(narratorTxt, startPageData.getPlayerName()); battleboard = new Board(battleGrid); battleships = new Ship[5]; randomize(battleships); }
/* Wraps around a StartPageData object (adding additional information) */ public BoardPlacementData(StartPageData startPageData, Ship[] playerShips, Ship[] aiShips, AiLevel level, int idleTime) { /* Checking nullity and idleTime */ if (startPageData == null) { throw new ArgumentException("startPageData cannot be null"); } else if (startPageData == null || startPageData == null) { throw new ArgumentException("both Ship[] cannot be null"); } else if (idleTime < 1) { throw new ArgumentException("idleTime should be at least 1"); } /* Verify if both arrays are filled to capacity with Ship objects and deep-copy each Ship at the same time */ this.playerShips = new Ship[playerShips.Length]; for (int i = 0; i < playerShips.Length; i++) { if (playerShips[i] == null) { throw new ArgumentException("Ship at " + i + " cannot be null in playerShips"); } /* Deep-copy */ this.playerShips[i] = new Ship(playerShips[i]); } this.aiShips = new Ship[aiShips.Length]; for (int i = 0; i < aiShips.Length; i++) { if (aiShips[i] == null) { throw new ArgumentException("Ship at " + i + " cannot be null in aiShips"); } /* Deep-copy */ this.aiShips[i] = new Ship(aiShips[i]); } this.startPageData = startPageData; this.level = level; this.idleTime = idleTime; }
public BoardPlacementData(StartPageData startPageData, Ship[] playerShips, Ship[] aiShips, AiLevel level, int idleTime) { if (startPageData == null) { throw new ArgumentException(""); } else if (startPageData == null || startPageData == null) { throw new ArgumentException(""); } else if (idleTime < 1) { throw new ArgumentException(""); } this.playerShips = new Ship[playerShips.Length]; for (int i = 0; i < playerShips.Length; i++) { if (playerShips[i] == null) { throw new ArgumentException("Корабль на " + i + " не может быть null "); } this.playerShips[i] = new Ship(playerShips[i]); } this.aiShips = new Ship[aiShips.Length]; for (int i = 0; i < aiShips.Length; i++) { if (aiShips[i] == null) { throw new ArgumentException("Корабль на " + i + " не может быть null "); } this.aiShips[i] = new Ship(aiShips[i]); } this.startPageData = startPageData; this.level = level; this.idleTime = idleTime; }
private void goToBoatPlacement(StartPageData data) { this.NavigationService.Navigate(new BoardPlacement(data)); }