private void SingleShot(Grid square) { turnLabel.Content = ((turnCount / 2) + 2).ToString(); switch (square.Tag.ToString()) { case "water": square.Tag = "miss"; square.Background = BSR.Miss; Beeper.PlayBeep(500, 300); MissSound.Play(); turnCount++; compTurn(); return; case "miss": case "hit": Console.WriteLine("User hit a miss/hit"); return; case "destroyer": cDestroyerCount--; break; case "cruiser": cCruiserCount--; break; case "submarine": cSubmarineCount--; break; case "battleship": cBattleshipCount--; break; case "carrier": cCarrierCount--; break; case "seaplane": cPlaneCount--; break; } square.Tag = "hit"; HitSound.Play(); square.Background = BSR.Hit; turnCount++; Beeper.PlayBeep(1000, 300); checkPlayerWin(); compTurn(); }
private void checkComputerWin() { if (pCarrierCount == 0) { pCarrierCount = -1; WriteLog("Your Aircraft Carrier was destroyed!"); Beeper.PlayFriendlyShipSink(); } if (pCruiserCount == 0) { pCruiserCount = -1; WriteLog("Your Cruiser was destroyed!"); Beeper.PlayFriendlyShipSink(); } if (pDestroyerCount == 0) { pDestroyerCount = -1; WriteLog("Your Destroyer was destroyed!"); Beeper.PlayFriendlyShipSink(); } if (pBattleshipCount == 0) { pBattleshipCount = -1; WriteLog("Your Battleship was destroyed!"); Beeper.PlayFriendlyShipSink(); } if (pSubmarineCount == 0) { pSubmarineCount = -1; WriteLog("Your Submarine was destroyed!"); Beeper.PlayFriendlyShipSink(); } if (pPlaneCount == 0) { pPlaneCount = -1; WriteLog("Your Seaplane was destroyed!"); Beeper.PlayFriendlyShipSink(); } if (pCarrierCount == -1 && pBattleshipCount == -1 && pSubmarineCount == -1 && pCruiserCount == -1 && pDestroyerCount == -1 && pPlaneCount == -1) { WriteLog("You lose!"); disableGrids(); lb.saveHighScores(false); } }
private void checkPlayerWin() { if (cCarrierCount == 0) { cCarrierCount = -1; WriteLog("You sunk my Aircraft Carrier!"); Beeper.PlayEnemyShipSink(); } if (cCruiserCount == 0) { cCruiserCount = -1; WriteLog("You sunk my Cruiser!"); Beeper.PlayEnemyShipSink(); } if (cDestroyerCount == 0) { cDestroyerCount = -1; WriteLog("You sunk my Destroyer!"); Beeper.PlayEnemyShipSink(); } if (cBattleshipCount == 0) { cBattleshipCount = -1; WriteLog("You sunk my Battleship!"); Beeper.PlayEnemyShipSink(); } if (cSubmarineCount == 0) { cSubmarineCount = -1; WriteLog("You sunk my Submarine!"); Beeper.PlayEnemyShipSink(); } if (cPlaneCount == 0) { cPlaneCount = -1; WriteLog("You sunk my Seaplane!"); Beeper.PlayEnemyShipSink(); } if (cCarrierCount == -1 && cBattleshipCount == -1 && cSubmarineCount == -1 && cCruiserCount == -1 && cDestroyerCount == -1 && cPlaneCount == -1) { WriteLog("You win!"); disableGrids(); lb.saveHighScores(true); } }