M
M
Michael07092021-06-17 09:55:43
C++ / C#
Michael0709, 2021-06-17 09:55:43

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();
        }


Thanks to all the kind people!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2021-06-17
@GavriKos

This is a task, not a question. freelance for you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question