Answer the question
In order to leave comments, you need to log in
How to rewrite this little function?
Good afternoon.
I really ask for help.
In general, I create a WebGl project. Everything works fine in unity itself, but when I build for WebGL, one function does not work, which causes the whole game to crash.
Please help rewrite the function below, because I do not understand asynchronous functions (initially, this code snippet was made by another person with whom there is no connection anymore)
It is desirable that IEnumerator be used, but any implementation is fine, as long as it works already
So, the ill-fated function:
private async void StartGame()
{
while (true)
{
OnTurn = Players[(int)Board.OnTurn];
if (NoPossibleMoves()) break;
Move move = await OnTurn.CalculateNextMove();
if (OnTurn is Bot)
{
Bot bot = OnTurn as Bot;
UiController.ShowSearchInfoText(bot.LastSearchResult);
SelectPiece((int)move.FromSq);
DoMove((int)move.ToSq);
}
else
{
await OnTurn.SelectPiece();
if (SelectedPiece == null) continue;
await OnTurn.DoMove();
}
}
EndGame();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question