using System.Collections.Generic; using UnityEngine; public class CrazyBotAI : IBotAI { private Queue targetShipCoords = new Queue(); public Vector2Int MakeMove(GamePole pole) { if (targetShipCoords.Count > 0) { // Добиваем по заранее найденным координатам return targetShipCoords.Dequeue(); } var shots = pole.GetAvailableShots(); if (shots.Count == 0) return new Vector2Int(-1, -1); // Нет куда стрелять var shot = shots[Random.Range(0, shots.Count)]; return new Vector2Int(shot.x, shot.y); } // Метод для обновления очереди добивания после успешного выстрела, вызываемый снаружи public void OnHitShip(GamePole pole, int x, int y) { var cell = pole.Pole[x, y].GetComponent(); if (cell != null && cell.deck != null) { var ship = cell.deck.GetComponentInParent(); if (ship != null) { foreach (Vector2Int coord in ship.deckCoords) { if ((coord.x != x || coord.y != y) && pole.PoleShot[coord.x, coord.y] == 0) { if (!targetShipCoords.Contains(coord)) targetShipCoords.Enqueue(coord); } } } } } }