Exemple #1
0
        private void Shot()
        {
            if (_corditateI < Field.Size)
            {
                if (_shotState == CellStatus.Drowned)
                {
                    MarkDrownedShip();
                }
                Thread.Sleep(100);

                if (!(_cordinateJ < Field.Size))
                {
                    _cordinateJ = 0;
                    _corditateI++;
                }
                do
                {
                    _shotState = OponentField.Shot(OponentField.CellField[_corditateI, _cordinateJ]);
                    _cordinateJ++;
                    if (_cordinateJ != Field.Size)
                    {
                        continue;
                    }
                    _cordinateJ = 0;
                    _corditateI++;
                } while (OponentField.CellField[_corditateI, _cordinateJ].CellStatus == CellStatus.Miss);

                _currentShot = new Location(_corditateI, _cordinateJ);
            }

            if (_shotState != CellStatus.Miss)
            {
                Move();
            }
        }
Exemple #2
0
        private void LongShot()
        {
            Logger.Debug("Attempt to get random point in order to make a shot");
            var shot = _random.Next(0, IntactCell);

            var newShot = OverrideShot(CheckShot, shot);

            Logger.Debug("Attempt to get random point in order to make a shot successfully completed" + newShot);
            Logger.Debug("Attempt to make a shot and get shot result");
            _shotState = OponentField.Shot(OponentField.CellField[newShot.I, newShot.J]);
            if (_shotState == CellStatus.Crippled)
            {
                _moveState   = MoveState.UnknownDirection;
                _oneGuessing = true;
                _firstShot   = newShot;
            }
            _currentShot = newShot;
            Logger.Debug("Attempt to make a shot and get shot result successfully completed. Shot result is " + _shotState);
            Logger.Debug("Check if player can make another shot");
            if (_shotState != CellStatus.Miss)
            {
                Logger.Debug("Make another shot");
                Move();
            }
            Logger.Debug("Transfer move to oponent");
        }