private void BTNCvC_Click(object sender, RoutedEventArgs e) { options.fieldSize = Convert.ToInt32(TXTFieldSize.Text); options.sizeCarrier = Convert.ToInt32(TXTCarrierSize.Text); options.countCarrier = Convert.ToInt32(TXTCarrierCount.Text); options.sizeBattleship = Convert.ToInt32(TXTBattleshipSize.Text); options.countBattleship = Convert.ToInt32(TXTBattleshipCount.Text); options.sizeCruiser = Convert.ToInt32(TXTCruiserSize.Text); options.countCruiser = Convert.ToInt32(TXTCruiserCount.Text); options.sizeSubmarine = Convert.ToInt32(TXTSubmarineSize.Text); options.countSubmarine = Convert.ToInt32(TXTSubmarineCount.Text); options.sizeDestroyer = Convert.ToInt32(TXTDestroyerSize.Text); options.countDestroyer = Convert.ToInt32(TXTDestroyerCount.Text); options.totalShips = options.countCarrier * options.sizeCarrier + options.countBattleship * options.sizeBattleship + options.countCruiser * options.sizeCruiser + options.countSubmarine * options.sizeSubmarine + options.countDestroyer * options.sizeDestroyer; options.gameMode = 2; var Game = new GameWindow(options, field); Game.Show(); this.Close(); }
private void PlayerSetupShips() { int coorX = selectX; int coorY = selectY; int direc = selectDir; int size; if (setCarrier < gameOptions.countCarrier) { size = gameOptions.sizeCarrier; if (ValidTile(coorX, coorY, direc, field1Own, size) == true) { switch (direc) { case 0: for (int i = coorX; i < coorX + size; i++) { field1Own[i, coorY] = 2; } break; case 1: for (int i = coorY; i < coorY + size; i++) { field1Own[coorX, i] = 2; } break; case 2: for (int i = coorX; i > coorX - size; i--) { field1Own[i, coorY] = 2; } break; case 3: for (int i = coorY; i > coorY - size; i--) { field1Own[coorX, i] = 2; } break; default: break; } setCarrier++; } } else if (setBattleship < gameOptions.countBattleship) { size = gameOptions.sizeBattleship; if (ValidTile(coorX, coorY, direc, field1Own, size) == true) { switch (direc) { case 0: for (int i = coorX; i < coorX + size; i++) { field1Own[i, coorY] = 2; } break; case 1: for (int i = coorY; i < coorY + size; i++) { field1Own[coorX, i] = 2; } break; case 2: for (int i = coorX; i > coorX - size; i--) { field1Own[i, coorY] = 2; } break; case 3: for (int i = coorY; i > coorY - size; i--) { field1Own[coorX, i] = 2; } break; default: break; } setBattleship++; } } else if (setCruiser < gameOptions.countCruiser) { size = gameOptions.sizeCruiser; if (ValidTile(coorX, coorY, direc, field1Own, size) == true) { switch (direc) { case 0: for (int i = coorX; i < coorX + size; i++) { field1Own[i, coorY] = 2; } break; case 1: for (int i = coorY; i < coorY + size; i++) { field1Own[coorX, i] = 2; } break; case 2: for (int i = coorX; i > coorX - size; i--) { field1Own[i, coorY] = 2; } break; case 3: for (int i = coorY; i > coorY - size; i--) { field1Own[coorX, i] = 2; } break; default: break; } setCruiser++; } } else if (setSubmarine < gameOptions.countSubmarine) { size = gameOptions.sizeSubmarine; if (ValidTile(coorX, coorY, direc, field1Own, size) == true) { switch (direc) { case 0: for (int i = coorX; i < coorX + size; i++) { field1Own[i, coorY] = 2; } break; case 1: for (int i = coorY; i < coorY + size; i++) { field1Own[coorX, i] = 2; } break; case 2: for (int i = coorX; i > coorX - size; i--) { field1Own[i, coorY] = 2; } break; case 3: for (int i = coorY; i > coorY - size; i--) { field1Own[coorX, i] = 2; } break; default: break; } setSubmarine++; } } else if (setDestroyer < gameOptions.countDestroyer) { size = gameOptions.sizeDestroyer; if (ValidTile(coorX, coorY, direc, field1Own, size) == true) { switch (direc) { case 0: for (int i = coorX; i < coorX + size; i++) { field1Own[i, coorY] = 2; } break; case 1: for (int i = coorY; i < coorY + size; i++) { field1Own[coorX, i] = 2; } break; case 2: for (int i = coorX; i > coorX - size; i--) { field1Own[i, coorY] = 2; } break; case 3: for (int i = coorY; i > coorY - size; i--) { field1Own[coorX, i] = 2; } break; default: break; } setDestroyer++; } } if (setDestroyer == gameOptions.countDestroyer) { var Game = new GameWindow(gameOptions, field1Own); Game.Show(); this.Close(); } UpdateButtons(); }