Exemplo n.º 1
0
        private void Shoot(int i, int j, ref int[,] fieldArray, ref Panel[,] Field)
        {
            switch (fieldArray[i + 1, j + 1])
            {
            case (int)Battleships.State.Alive:
            {
                if (Battleships.CheckShipState(i, j, fieldArray) == true)
                {
                    Hit.Play();
                    fieldArray[i + 1, j + 1] = (int)Battleships.State.Damaged;
                }
                else
                {
                    Kill.Play();
                    Battleships.KillShip(i, j, fieldArray);
                    if (fieldArray == fieldArray1)
                    {
                        AddScore(true);
                    }
                    else
                    {
                        AddScore(false);
                    }
                }
            }
            break;

            case (int)Battleships.State.Empty:
            {
                Miss.Play();
                fieldArray[i + 1, j + 1] = (int)Battleships.State.Miss;
                turn = !turn;
            }
            break;
            }
            Draw(fieldArray1, ref Field1);
            DrawGame(fieldArray2, ref Field2);
            if (turn == false)
            {
                timer1.Enabled = true;
            }
        }