private void InnerGenerateLevelMessage(GenerateLevelMessage generateLevelMessage) { UIManager.Instance.ShowLevelLoadScreen(generateLevelMessage.reconnecting); DungeonDict.Instance.ClearRooms(); MiniMapManager.Instance.OnLevelDeleted(); RegionSceneLoader loader = RegionSceneLoader.Instance; new ExtendedCoroutine(this, loader.LoadScene(generateLevelMessage), loader.LoadLevel, true); }
private void OnGenerateLevelMessage(GenerateLevelMessage generateLevelMessage) { // We need to wait a frame if we are reconnecting. This is quite ugly but i dont know how else you // can delay code just a frame. if (generateLevelMessage.reconnecting == true) { StartCoroutine(GenerateLevelAfterFrame(generateLevelMessage)); } else { InnerGenerateLevelMessage(generateLevelMessage); } }
private void JoinReconnect(NetworkConnection connection, Player oldPlayer) { NetworkServer.AddPlayerForConnection(connection, oldPlayer.gameObject); oldPlayer.playerId = connection.connectionId; StartGameMessage sgm = new StartGameMessage() { gameMode = GameManager.gameMode, levelSeed = GameManager.gameMode.seed }; connection.Send(sgm); GenerateLevelMessage glm = new GenerateLevelMessage() { levelNumber = GameManager.currentLevel, reconnecting = true, region = RegionDict.Instance.Region }; connection.Send(glm); }
/// <summary> /// Loads new regions and unloads the old scenes. /// </summary> public IEnumerator LoadScene(GenerateLevelMessage generateLevelMessage) { this.generateLevelMessage = generateLevelMessage; yield return(LoadScene(generateLevelMessage.region)); }
private IEnumerator GenerateLevelAfterFrame(GenerateLevelMessage generateLevelMessage) { yield return(null); InnerGenerateLevelMessage(generateLevelMessage); }