private void ShotWithEnemyIntellegence(ref UserActions chosenAction) { do { UserInterface.ShowMessage(_enemyTurn); System.Threading.Thread.Sleep(1000); if (CheckExit()) { chosenAction = UserActions.GameOver; break; } _enemysMind.MakeTheShot(ref _isAlivePlayerAfterRigthShoot, _playerMap); _isTargetPlayer = _enemysMind.IsTargetPlayer; _playerMap.CheckShipCondition(_isTargetPlayer, _isAlivePlayerAfterRigthShoot, _enemysMind); int cursorLeft = UserInterface.DISTANCE_BETWEEN_MAP; int cursorTop = UserInterface.START_TOP_CURSOR; UserInterface.PrintShipPlayer(_playerMap, cursorLeft, cursorTop); UserInterface.ShowResultOfShot(_isAlivePlayerAfterRigthShoot, _isTargetPlayer); UserInterface.PrintExitSymbol();///////////////// System.Threading.Thread.Sleep(1500); bool shipSearched = _playerMap.SearchShips(); if (!shipSearched) { break; } } while (_isTargetPlayer); }
public void IsEnemyTurn(out string message, out bool isEnemyWin) { isEnemyWin = false; if (_isEasyLevel) { RandomCoords.SearchRandomCoords(_playerMap); _isTargetPlayer = _playerMap.HitTarget(ref _isAlivePlayerAfterRigthShoot); } else { _enemysMind.MakeTheShot(ref _isAlivePlayerAfterRigthShoot, _playerMap); _isTargetPlayer = _enemysMind.IsTargetPlayer; _playerMap.CheckShipCondition(_isTargetPlayer, _isAlivePlayerAfterRigthShoot, _enemysMind); } if (_isTargetPlayer) { message = (_playerMap.TargetCoordY + 1) + ((Letters)_playerMap.TargetCoordX).ToString() + "\nHit the target!" + "\n Enemy's turn!"; } else { message = (_playerMap.TargetCoordY + 1) + ((Letters)_playerMap.TargetCoordX).ToString() + "\nPast!!" + "\nYour turn!"; } if (!_playerMap.SearchShips()) { isEnemyWin = true; message = "ENEMY WON!!!"; } }