public bool AIMove() { Vector2Int shotPos = new Vector2Int(Random.Range(0, 9), Random.Range(0, 9)); while (shots.ContainsKey(shotPos)) { shotPos = new Vector2Int(Random.Range(0, 9), Random.Range(0, 9)); } shots[shotPos] = 1; if (player.CheckIfShotHit(shotPos)) { boardDisplay[shotPos.x][shotPos.y].DisplayHit(); bool win2 = player.IsBattleshipDestroyed(); //AI check if win if (win2) { Debug.Log("AI wins"); //currentPhase = (int)phase.TITLE; } return(true); } else { boardDisplay[shotPos.x][shotPos.y].DisplayMiss(); } bool win = player.IsBattleshipDestroyed(); //AI check if win if (win) { Debug.Log("AI wins"); ///quit(); //currentPhase = (int)phase.TITLE; } return(true); }
public bool isHit(Vector2Int shotPos) { Debug.Log(shotPos.x + " " + shotPos.y); ///return true; bool shotResult = AI.CheckIfShotHit(shotPos); //Debug.Log(shotResult); if (shotResult == true) { boardDisplayAI[shotPos.x][shotPos.y].DisplayHit(); bool win1 = AI.IsBattleshipDestroyed(); //AI check if win if (win1) { Debug.Log("player wins"); //currentPhase = (int)phase.TITLE; } return(true); } boardDisplayAI[shotPos.x][shotPos.y].DisplayMiss(); bool win = AI.IsBattleshipDestroyed(); //AI check if win if (win) { Debug.Log("player wins"); //currentPhase = (int)phase.TITLE; } return(false); }