public override void Initialize(IGameSystemArgs args)
        {
            base.Initialize(args);
            GameSystemType = GameSystemType.Hacking;
            this.StartGameCoroutine(SetCanvasCameraAsync());
            var groupAssetLoader = GroupAssetLoader.Init(this.gameObject);

            groupAssetLoader.Add(Arguments.RoomName, (rO) =>
            {
                _currentRoom = rO.GetComponent <HackRoom>();
                if (!string.IsNullOrEmpty(_currentRoom.DialogueAudioName))
                {
                    groupAssetLoader.Load <DialogueRoomAudio>(_currentRoom.DialogueAudioName, (r1) =>
                    {
                        Arguments.Services.Sound.SetDialogueAudio(r1);
                    });
                }
            });
            groupAssetLoader.LoadAssets().OnCompleted += finishedLoading;
            _hackWindow.Initialize(Arguments);
            void finishedLoading()
            {
                OnLoadingFinished?.Invoke();
            }
        }
        private IEnumerator LoadAdditiveScene(SceneIndex scene, SceneModel model)
        {
            OnLoadingStart?.Invoke();
            IsLoading = true;

            AsyncOperation loadSceneJob = SceneManager.LoadSceneAsync(scene.ToString(), LoadSceneMode.Additive);

            while (!loadSceneJob.isDone)
            {
                yield return(null);

                // Callback to update based on the async task progress
                OnLoadingUpdate?.Invoke(loadSceneJob.progress);
            }

            // Scene was done loading
            Scene loadedScene = SceneManager.GetSceneByName(scene.ToString());

            if (loadedScene.isLoaded)
            {
                SceneManager.MergeScenes(loadedScene, SceneManager.GetActiveScene());

                bool controllerFound = false;
                // Get the scene object to initialize the scene using the ISceneController interface
                GameObject[] rootObjects = loadedScene.GetRootGameObjects();
                foreach (GameObject rootObject in rootObjects)
                {
                    // Try to get the scene controller so we can initialize the scene
                    SceneController <SceneModel> sceneController = rootObject.GetComponent <SceneController <SceneModel> >();

                    // This object didn't have the scene controller
                    if (sceneController == null)
                    {
                        continue;
                    }

                    sceneController.BaseModel = model;

                    LoadedScene managedLoadedScene = new LoadedScene(sceneController, model, rootObject, scene);
                    _loadedScenes.Add(managedLoadedScene);

                    yield return(sceneController.Initialization());

                    sceneController.AfterInitialization();

                    controllerFound = true;
                }

                if (!controllerFound)
                {
                    Debug.LogError("[SceneTransitionManager] Could not find any object with component ISceneController in scene: "
                                   + loadedScene.name);
                }
            }

            OnLoadingFinished?.Invoke();
            IsLoading = false;
        }
示例#3
0
        void OnFail(string error)
        {
            loadingState = LoadState.LOADING_FAILED;

            if (OnLoadingFinished != null)
            {
                OnLoadingFinished.Invoke(this);
            }
        }
        public void LoginAndGoOnline()
        {
            PopulateLists();

            GoOnline();

            ChatEventsManager = new ChatEventsManager(ChatHandler, TimeSpan.FromSeconds(2), 10);
            ChatEventsManager.ChatMessageReceived += OnMessage;

            Loaded += FriendsListWindow_Loaded;
            Closed += FriendsListWindow_Closed;
            OnLoadingFinished?.Invoke(this, new EventArgs());
        }
示例#5
0
        void OnComplete(AudioClip clip)
        {
            if (clip != null)
            {
                this.audioClip = clip;
                loadingState   = LoadState.LOADING_COMPLETED;
            }
            else
            {
                loadingState = LoadState.LOADING_FAILED;
            }

            if (OnLoadingFinished != null)
            {
                OnLoadingFinished.Invoke(this);
            }
        }
        private IEnumerator LoadMainScene(SceneIndex scene, SceneModel model)
        {
            OnLoadingStart?.Invoke();
            IsLoading = true;

            // Make sure to clean up the current active scene before destroying it
            if (_activeScene != null)
            {
                _activeScene.Controller.BeforeDestroy();
            }

            // Start the scene loading asyncronous operation
            AsyncOperation loadSceneJob = SceneManager.LoadSceneAsync(scene.ToString());

            while (!loadSceneJob.isDone)
            {
                yield return(null);

                // Callback to update based on the async task progress
                OnLoadingUpdate?.Invoke(loadSceneJob.progress);
            }

            _loadedScenes.Clear();

            GC.Collect();

            Scene loadedScene = SceneManager.GetSceneByName(scene.ToString());

            if (loadedScene.isLoaded)
            {
                bool controllerFound = false;
                // Get the scene object to initialize the scene using the ISceneController interface
                GameObject[] rootObjects = loadedScene.GetRootGameObjects();
                foreach (GameObject rootObject in rootObjects)
                {
                    // Try to get the scene controller so we can initialize the scene
                    ISceneController sceneController = rootObject.GetComponent <ISceneController>();

                    // This object didn't have the scene controller
                    if (sceneController == null)
                    {
                        continue;
                    }

                    // Create a loaded scene handle
                    LoadedScene managedLoadedScene = new LoadedScene(sceneController, model, rootObject, scene);
                    _loadedScenes.Add(managedLoadedScene);

                    _activeScene = managedLoadedScene;
                    sceneController.BaseModel = model;
                    yield return(sceneController.Initialization());

                    sceneController.AfterInitialization();
                    controllerFound = true;
                }

                if (!controllerFound)
                {
                    Debug.LogError("[SceneTransitionManager] Could not find any object with component SceneController in scene: "
                                   + loadedScene.name);
                }
            }

            yield return(new WaitForSeconds(1));

            OnLoadingFinished?.Invoke();
            IsLoading = false;
        }
 private void NotifyLoadingFinished()
 {
     IsLoading = false;
     OnLoadingFinished?.Invoke();
 }