rematch use the same leave function, added a grace period for connection disconnect
This commit is contained in:
@@ -808,10 +808,22 @@ public class GameManager : NetworkBehaviour
|
||||
// LevelLoadManager.LoadLevel("MainMenu");
|
||||
}
|
||||
|
||||
public void Leave(){
|
||||
public void Leave(string levelName = "MainMenu"){
|
||||
NetManager.MarkIntentionalClientDisconnect();
|
||||
StopClient();
|
||||
LevelLoadManager.LoadLevel("MainMenu");
|
||||
|
||||
StartCoroutine(CoroutineWaitTillDisconnection(levelName));
|
||||
}
|
||||
|
||||
IEnumerator CoroutineWaitTillDisconnection(string levelName){
|
||||
LevelLoadManager.instance.Show(); //Load the UI until the level is loaded
|
||||
while(NetworkClient.isConnected){
|
||||
yield return null;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(1f); //Just to make sure
|
||||
|
||||
LevelLoadManager.LoadLevel(levelName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -530,8 +530,7 @@ public class NetPlayer : NetworkBehaviour
|
||||
Cupid.RoomPort = branch.Port;
|
||||
LoginManager.SetMatchYourTeam(branch.your_team);
|
||||
|
||||
GameManager.instance.StopClient();
|
||||
LevelLoadManager.LoadLevel("Game");
|
||||
GameManager.instance.Leave("Game");
|
||||
}
|
||||
|
||||
void OnRematchCancelledServer(){
|
||||
|
||||
@@ -87,6 +87,7 @@ public class LevelLoadManager : MonoBehaviour
|
||||
|
||||
|
||||
public void Show(){
|
||||
if(isShowing){return;} //already is showing
|
||||
canvasGroup.blocksRaycasts=true;
|
||||
canvasGroup.interactable=true;
|
||||
contentImage.fillOrigin = 0;
|
||||
|
||||
Reference in New Issue
Block a user