public async Task JoinMeetingAsync(string meetingId, string meetingPassword, string userName)
        {
            var controller = await this.ShowProgressAsync("Anmeldung", "Meeting wird verbunden...");

            controller.SetIndeterminate();
            controller.SetCancelable(true);
            controller.Canceled += (e, s) => {
                ZoomService.LeaveMeeting();
            };
            ZoomService.JoinMeeting(ulong.Parse(meetingId.Trim().Replace(" ", "")), meetingPassword, userName, this.VideoCanvas);
            await TaskEx.WaitUntil(() => {
                controller.SetMessage(ZoomConstants.MeetingStatusDecoder(ZoomService.MeetingStatus));
                return(controller.IsCanceled || ZoomService.InMeeting);
            });

            await controller.CloseAsync();
        }
        /// <inheritdoc cref="IServiceConnector.StartPublishingAsync(CancellationToken)" />
        public async Task StartPublishingAsync(CancellationToken cancellationToken)
        {
            while (!cancellationToken.IsCancellationRequested)
            {
                await TaskEx.WaitUntil(() => _networkConnectors.Count != 0, cancellationToken : cancellationToken);

                cancellationToken.ThrowIfCancellationRequested();
                IMessage message = await _messageQueue.DequeueAsync(cancellationToken);

                INetworkConnector networkConnector = null;
                while (networkConnector == null)
                {
                    networkConnector = GetNetworkConnector();
                    cancellationToken.ThrowIfCancellationRequested();
                }
                _ = Task.Run(() => networkConnector.SendMessageAsync(message, cancellationToken), cancellationToken);
            }
        }
示例#3
0
        public static async void Load(string saveName)
        {
            Debug.Log($"--- Loading Save File: {saveName} ---");

            isCurrentlyLoadingSave = true;

            if (LevelManager.instance.IsCurrentlyLoadingScenes || LevelManager.instance.isCurrentlySwitchingScenes)
            {
                Debug.Log("Waiting for in-progress scene loading to finish before starting load...");
                await TaskEx.WaitUntil(() => !LevelManager.instance.IsCurrentlyLoadingScenes && !LevelManager.instance.isCurrentlySwitchingScenes);
            }

            MainCanvas.instance.blackOverlayState = MainCanvas.BlackOverlayState.On;
            Time.timeScale = 0f;

            // Clear out existing DynamicObjects so they don't stick around when the new save file is loaded
            DynamicObjectManager.DeleteAllExistingDynamicObjectsAndClearState();

            // Get the save file from disk
            SaveFile save = SaveFile.RetrieveSaveFileFromDisk(saveName);

            // Create a SaveManager for ManagerScene and restore its state
            SaveManagerForScene saveManagerForManagerScene = GetOrCreateSaveManagerForScene(LevelManager.ManagerScene);

            saveManagerForManagerScene.LoadSaveableObjectsStateFromSaveFile(save.managerScene);

            Debug.Log("Waiting for scenes to be loaded...");
            await TaskEx.WaitUntil(() => !LevelManager.instance.IsCurrentlyLoadingScenes);

            Debug.Log("All scenes loaded into memory, loading save...");

            // Load records of all DynamicObjects from disk
            save.dynamicObjects.LoadSaveFile();

            // Load all DynamicObjects for each scene
            foreach (var kv in save.scenes)
            {
                string              sceneName        = kv.Key;
                SaveFileForScene    saveFileForScene = kv.Value;
                SaveManagerForScene saveManager      = GetOrCreateSaveManagerForScene(sceneName);
                saveManager.LoadDynamicObjectsStateFromSaveFile(saveFileForScene);
            }

            Dictionary <string, SaveFileForScene> loadedScenes = save.scenes
                                                                 .Where(kv => LevelManager.instance.loadedSceneNames.Contains(kv.Key))
                                                                 .ToDictionary();
            Dictionary <string, SaveFileForScene> unloadedScenes = save.scenes
                                                                   .Except(loadedScenes)
                                                                   .ToDictionary();

            // Restore state for all unloaded scenes from the save file
            foreach (var kv in unloadedScenes)
            {
                string              sceneName        = kv.Key;
                SaveFileForScene    saveFileForScene = kv.Value;
                SaveManagerForScene saveManager      = GetOrCreateSaveManagerForScene(sceneName);
                saveManager.LoadSaveableObjectsStateFromSaveFile(saveFileForScene);
            }

            // Load data for every object in each loaded scene (starting with the ManagerScene)
            saveManagerForManagerScene.LoadSaveableObjectsStateFromSaveFile(save.managerScene);
            foreach (var kv in loadedScenes)
            {
                string              sceneName        = kv.Key;
                SaveFileForScene    saveFileForScene = kv.Value;
                SaveManagerForScene saveManager      = GetOrCreateSaveManagerForScene(sceneName);
                saveManager.LoadSaveableObjectsStateFromSaveFile(saveFileForScene);
            }

            // Play the level change banner and remove the black overlay
            LevelChangeBanner.instance.PlayBanner(LevelManager.instance.ActiveScene);
            Time.timeScale = 1f;
            MainCanvas.instance.blackOverlayState = MainCanvas.BlackOverlayState.FadingOut;
            isCurrentlyLoadingSave = false;
        }
示例#4
0
        /// <summary>
        /// Switches the active scene, loads the connected scenes as defined by worldGraph, and unloads all other currently loaded scenes.
        /// </summary>
        /// <param name="levelName">Name of the scene to become active</param>
        /// <param name="playBanner">Whether or not to play the LevelBanner. Defaults to true.</param>
        /// <param name="saveDeactivatedScenesToDisk">Whether or not to save any scenes that deactivated to disk. Defaults to true</param>
        /// <param name="loadActivatedScenesFromDisk">Whether or not to load any scenes from disk that become activated. Defaults to true</param>
        /// <param name="checkActiveSceneName">If true, will skip loading the scene if it's already the active scene. False will force it to load the scene. Defaults to true.</param>
        async void SwitchActiveSceneNow(
            string levelName,
            bool playBanner = true,
            bool saveDeactivatedScenesToDisk = true,
            bool loadActivatedScenesFromDisk = true,
            bool checkActiveSceneName        = true
            )
        {
            if (!levels.ContainsKey(levelName))
            {
                debug.LogError("No level name found in world graph with name " + levelName);
                return;
            }

            if (checkActiveSceneName && activeSceneName == levelName)
            {
                debug.LogWarning("Level " + levelName + " already the active scene.");
                return;
            }

            isCurrentlySwitchingScenes = true;
            // Immediately turn on the loading icon instead of waiting for a frame into the loading
            LoadingIcon.instance.state = LoadingIcon.State.Loading;

            Debug.Log($"Switching to level {levelName}");

            BeforeActiveSceneChange?.Invoke(levelName);

            activeSceneName = levelName;

            if (playBanner)
            {
                LevelChangeBanner.instance.PlayBanner(enumToSceneName[activeSceneName]);
            }

            // First unload any scene no longer needed
            DeactivateUnrelatedScenes(levelName, saveDeactivatedScenesToDisk);

            List <string> scenesToBeLoadedFromDisk = new List <string>();

            // Then load the level if it's not already loaded
            if (!(loadedSceneNames.Contains(levelName) || currentlyLoadingSceneNames.Contains(levelName)))
            {
                currentlyLoadingSceneNames.Add(levelName);

                BeforeSceneLoad?.Invoke(levelName);

                scenesToBeLoadedFromDisk.Add(levelName);
                if (ShouldLoadScene(levelName))
                {
                    SceneManager.LoadSceneAsync(levelName, LoadSceneMode.Additive);
                }
            }
            else
            {
                if (!hasLoadedDefaultPlayerPosition)
                {
                    LoadDefaultPlayerPosition();
                }
            }

            // Then load the adjacent scenes if they're not already loaded
            var connectedSceneNames = levels[levelName].connectedLevels.Select(l => enumToSceneName[l]);

            foreach (string connectedSceneName in connectedSceneNames)
            {
                if (!(loadedSceneNames.Contains(connectedSceneName) ||
                      currentlyLoadingSceneNames.Contains(connectedSceneName)))
                {
                    currentlyLoadingSceneNames.Add(connectedSceneName);

                    BeforeSceneLoad?.Invoke(connectedSceneName);

                    scenesToBeLoadedFromDisk.Add(connectedSceneName);
                    if (ShouldLoadScene(connectedSceneName))
                    {
                        SceneManager.LoadSceneAsync(connectedSceneName, LoadSceneMode.Additive);
                    }
                }
            }

            debug.Log("Waiting for scenes to be loaded...");
            await TaskEx.WaitUntil(() => !LevelManager.instance.IsCurrentlyLoadingScenes);

            debug.Log("All scenes loaded into memory" + (loadActivatedScenesFromDisk ? ", loading save..." : "."));

            if (loadActivatedScenesFromDisk && scenesToBeLoadedFromDisk.Count > 0)
            {
                foreach (string sceneToBeLoaded in scenesToBeLoadedFromDisk)
                {
                    BeforeSceneRestoreDynamicObjects?.Invoke(sceneToBeLoaded);
                }

                foreach (string sceneToBeLoaded in scenesToBeLoadedFromDisk)
                {
                    SaveManagerForScene saveManagerForScene = SaveManager.GetOrCreateSaveManagerForScene(sceneToBeLoaded);
                    saveManagerForScene.RestoreDynamicObjectStateForScene();
                }

                foreach (string sceneToBeLoaded in scenesToBeLoadedFromDisk)
                {
                    BeforeSceneRestoreState?.Invoke(sceneToBeLoaded);
                }

                foreach (string sceneToBeLoaded in scenesToBeLoadedFromDisk)
                {
                    SaveManagerForScene saveManagerForScene = SaveManager.GetOrCreateSaveManagerForScene(sceneToBeLoaded);
                    saveManagerForScene.RestoreSaveableObjectStateForScene();
                }

                foreach (string sceneToBeLoaded in scenesToBeLoadedFromDisk)
                {
                    AfterSceneRestoreState?.Invoke(sceneToBeLoaded);
                }
            }

            isCurrentlySwitchingScenes = false;
        }