diff --git a/Reversi/Assets/BoardEventsHandler.cs b/Reversi/Assets/BoardEventsHandler.cs index e5a441d..25fae13 100644 --- a/Reversi/Assets/BoardEventsHandler.cs +++ b/Reversi/Assets/BoardEventsHandler.cs @@ -129,10 +129,7 @@ private void handleTapOnCell(GameObject cellCube) if (IS_OPPONENT_PLAYER_AI) { - while (this.IsTurnOfAI) - { - this.makeTurnByAI(); - } + StartCoroutine("coroutineMakeTurnByAI"); } } @@ -154,6 +151,15 @@ private void makeTurn(IReversiTurn turn) } #endregion + private IEnumerator coroutineMakeTurnByAI() + { + while (this.IsTurnOfAI) + { + yield return new WaitForSeconds(TURN_ANIMATION_DELAY); + this.makeTurnByAI(); + } + } + private void makeTurnByAI() { IReversiTurn selectedTurn = @@ -468,6 +474,7 @@ private void populateLabels() private const int BOARD_SIZE = 8; private const string CELL_TAG = "FieldCell"; private const string BALL_TAG = "Ball"; + private const float TURN_ANIMATION_DELAY = 0.5f; private IEnumerable _validTurns ; bool _isGameOver;