Skip to content

Instantly share code, notes, and snippets.

@abeldantas
Created February 27, 2019 21:52
Show Gist options
  • Save abeldantas/6ceb9813030539fd70c017d865d43af0 to your computer and use it in GitHub Desktop.
Save abeldantas/6ceb9813030539fd70c017d865d43af0 to your computer and use it in GitHub Desktop.
CreateGameAsync.cs
IEnumerator CreateGameAsync()
{
StartCoroutine( GetUsernameFromIdAsync( OpponentName.text, (id, isUsernameValid) =>
{
if ( !isUsernameValid )
{
FadeScreen.FadeBack();
GameCreationError.SetActive( true );
StartCoroutine( CoroutineHelper.WaitAndDo( 3.5f, () => { ShowMenu.OnClick(); } ) );
}
else
{
GameConfiguration.Instance.PlayerUserId = new int[GameManager.NumPlayers];
GameConfiguration.Instance.PlayerUserId[0] = GameConfiguration.Instance.UserId;
GameConfiguration.Instance.PlayerUserId[1] = id;
if ( MultiplayerManager.CreateGame() )
{
SceneManager.LoadScene( SceneManager.SceneKey.Game );
}
else
{
Debug.LogError( "Fail to create game on server" );
}
}
} ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment