IEnumerator GameCoroutine() { while (isGameStart) { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 clickPosition = figureStack.InverseTransformPoint(ray.GetPoint(0)); Vector2 yourIndexes; Vector2 enemyIndexes; yourIndexes = placeFigure.ClickPostionToIndexes(clickPosition); if (yourIndexes.x == -1 || yourIndexes.y == -1) { yield return(new WaitForEndOfFrame()); continue; } if (field[(int)yourIndexes.x, (int)yourIndexes.y] == -1) { placeFigure.Put(whichGame.YourFigure, yourIndexes); field[(int)yourIndexes.x, (int)yourIndexes.y] = (int)whichGame.YourFigure; if (IsWinSituation(whichGame.YourFigure)) { winPanel.Appear("Вы выйграли!"); isGameStart = false; break; } if (!HasFieldPlace()) { winPanel.Appear("Ничья!"); isGameStart = false; break; } enemyIndexes = bot.NextTurn(); placeFigure.Put(whichGame.EnemyFigure, enemyIndexes); field[(int)enemyIndexes.x, (int)enemyIndexes.y] = (int)whichGame.EnemyFigure; if (IsWinSituation(whichGame.EnemyFigure)) { winPanel.Appear("Бот выйграл!"); isGameStart = false; break; } if (!HasFieldPlace()) { winPanel.Appear("Ничья!"); isGameStart = false; break; } } else { if (!HasFieldPlace()) { winPanel.Appear("Ничья!"); isGameStart = false; break; } } } yield return(null); } }