Exemplo n.º 1
0
        protected void Fire(int row, int col, Player otherPlayer)
        {
            int damagedIndex;
            bool isSunk;
            SquareType newType = otherPlayer.FiredAt(row, col, out damagedIndex, out isSunk);
            EnemyGrid[row][col].ShipIndex = damagedIndex;

            if (isSunk)
                EnemySunk(damagedIndex);
            else
                EnemyGrid[row][col].Type = newType;
        }
Exemplo n.º 2
0
        public void TakeTurnAutomated(Player otherPlayer)
        {
            bool takenShot = false;
            while (!takenShot)
            {
                int row = rnd.Next(GRID_SIZE);
                int col = rnd.Next(GRID_SIZE);

                if (EnemyGrid[row][col].Type == SquareType.Unknown)
                {
                    Fire(row, col, otherPlayer);
                    takenShot = true;
                }
            }
        }
Exemplo n.º 3
0
 public void TakeTurn(Player otherPlayer)
 {
     TakeTurnAutomated(otherPlayer);
 }
Exemplo n.º 4
0
 public void TakeTurn(int row, int col, Player otherPlayer)
 {
     Fire(row, col, otherPlayer);
 }
        protected void Fire(int row, int col, Player otherPlayer)
        {
            //incrase number of shots and set number of enemy units
            _shots++;
            MainWindow._mainWindow.UpdateTb(_shots, _enemyUnits);

            int damagedIndex;
            bool isDestroyed;
            SquareType newType = otherPlayer.FiredAt(row, col, out damagedIndex, out isDestroyed);
            EnemyGrid[row][col].SquareIndex = damagedIndex;

            if (isDestroyed)
                EnemyDestroyed(damagedIndex);
            else
                EnemyGrid[row][col].Type = newType;
        }