Last active
July 8, 2016 16:31
-
-
Save glitchersgames/afa6ae838b2f0cf2e55471dc0a21bf96 to your computer and use it in GitHub Desktop.
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
private List<Player> m_ClientPlayerObjects = new List<Player>(); | |
private bool m_HasSentGameSceneReady = false; | |
private bool ShouldSendGameSceneReady | |
{ | |
get | |
{ | |
return | |
AllPlayersReady && // are all the clients created + ready? | |
Player.LocalPlayer != null && // and we exist as a local player | |
m_HasSentGameSceneReady == false; // and we haven't already sent the message | |
} | |
} | |
private bool AllPlayersReady | |
{ | |
get | |
{ | |
return m_ClientPlayerObjects.Count == numberOfPlayers; | |
} | |
} | |
// called from Player.OnStartClient | |
public void OnCreatedClientPlayerObject( Player clientPlayer ) | |
{ | |
m_ClientPlayerObjects.Add( clientPlayer ); | |
if( ShouldSendGameSceneReady ) | |
{ | |
SendLocalPlayerGameSceneReady(); | |
} | |
} | |
// called from Player.OnStartLocalPlayer | |
public void OnCreatedLocalPlayerObject( Player localPlayer ) | |
{ | |
if( ShouldSendGameSceneReady ) | |
{ | |
SendLocalPlayerGameSceneReady(); | |
} | |
} | |
private void SendLocalPlayerGameSceneReady() | |
{ | |
m_HasSentGameSceneReady = true; | |
// send your game scene ready message to the server here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment