//need tow ait for the GameManager to Start(), otherwise it causes problems with the player spawning private IEnumerator TimeOut(MatchInfo responseData) { float timeout = 5.0f; // 3 seconds you can change this to //to whatever you want float totalTime = 0; while (totalTime < timeout) { totalTime += Time.deltaTime; yield return(null); } //NetManager.matchMaker.DropConnection(responseData.networkId, responseData.nodeId, 0, NetManager.OnDropConnection); //NetManager.StopHost(); ApplicationData.ServerTimeout = true; MatchInfo matchInfo = NetManager.matchInfo; NetManager.matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, 0, NetManager.OnDropConnection); NetManager.StopHost(); NetworkManager.Shutdown(); SceneManager.LoadScene(0); FindMatchButton.enabled = true; StartMatchButton.enabled = true; }
/// <summary> /// When the server is shut down /// </summary> /// <param name="connection"></param> public override void OnClientDisconnect(NetworkConnection connection) { ApplicationData.ServerClosed = true; NetworkGameManager NetManager = NetworkGameManager.GetInstance(); MatchInfo matchInfo = NetManager.matchInfo; NetManager.matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, 0, NetManager.OnDropConnection); NetManager.StopHost(); NetworkGameManager.Shutdown(); SceneManager.LoadScene(0); base.OnClientDisconnect(connection); }
/// <summary> /// Quits the application. /// </summary> public void Quit() { ApplicationData.ServerClosed = false; NetworkGameManager NetManager = NetworkGameManager.GetInstance(); MatchInfo matchInfo = NetManager.matchInfo; NetManager.matchMaker.DropConnection(matchInfo.networkId, matchInfo.nodeId, 0, NetManager.OnDropConnection); NetManager.StopHost(); NetworkGameManager.Shutdown(); SceneManager.LoadScene(0); //SceneManager.LoadScene(0); }