Пример #1
0
        private void AiClickButton(string coord_tip)
        {
            Button clicked_button = (Button)PlayerShipTable.FindName(coord_tip);

            if (PlayerHitsaShip(clicked_button.Name, player1))
            {
                LastCoordThatHit = coord_tip;
                if (aiplayer.PlayerHits.Contains(clicked_button.Name))
                {
                    AiTurns();
                    return;
                }
                else
                {
                    clicked_button.Content = (Image)FindResource(partHitAi);
                    aiplayer.updatePlayerHits(clicked_button.Name);
                    player1.updateEnemyHits(clicked_button.Name);
                    lastShipHitAi.ShipPartsHit += 1;
                }
                if (lastShipHitAi.ShipPartsHit > 1)
                {
                    if (GameObjects.Functions.CheckIfAllShipCoordsHit(lastShipHitAi, player1) == null)
                    {
                        LastCoordThatHit = null;
                        GameObjects.Functions.UpdateRemainingShips(NumberofHitsEnemy, player_remaining_ships, aiplayer, player1, false);
                        CheckAiWins();
                    }
                }
            }
            else
            {
                if (clicked_button.Content != null)
                {
                    AiTurns();
                    return;
                }
                else
                {
                    clicked_button.Content = (Image)FindResource("NotHit");
                }
            }
            SetTurnData(0);
        }