Created
February 27, 2019 21:52
-
-
Save abeldantas/6ceb9813030539fd70c017d865d43af0 to your computer and use it in GitHub Desktop.
CreateGameAsync.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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