/// <summary>
/// Start the connection process.
/// - If already connected, we attempt joining a random room
/// - if not yet connected, Connect this application instance to Photon Cloud Network
/// </summary>
public void Connect()
{
// we want to make sure the log is clear everytime we connect, we might have several failed attempted if connection failed.
feedbackText.text = "";
// keep track of the will to join a room, because when we come back from the game we will get a callback that we are connected, so we need to know what to do then
isConnecting = true;
// hide the Play button for visual consistency
controlPanel.SetActive(false);
// start the loader animation for visual effect.
if (loaderAnime != null)
{
loaderAnime.StartLoaderAnimation();
}
// we check if we are connected or not, we join if we are , else we initiate the connection to the server.
if (PhotonNetwork.IsConnected)
{
LogFeedback("Joining Room...");
// #Critical we need at this point to attempt joining a Random Room. If it fails, we'll get notified in OnJoinRandomFailed() and we'll create one.
PhotonNetwork.JoinRandomRoom();
}
else
{
LogFeedback("Connecting...");
// #Critical, we must first and foremost connect to Photon Online Server.
PhotonNetwork.GameVersion = this.gameVersion;
PhotonNetwork.ConnectUsingSettings();
}
}