Esempio n. 1
0
        private async Task LoadingCycle()
        {
            var services      = _diContainer.ResolveAll <ILoading>();
            int servicesCount = services.Count;

            while (true)
            {
                if (services.All(val => val.LoadingState == LoadingState.Loaded))
                {
                    break;
                }

                ILoading loading = services.FirstOrDefault(val => val.LoadingState == LoadingState.Loading);

                if (loading != null)
                {
                    int   doneCount = services.Count(val => val.LoadingState == LoadingState.Loaded);
                    float progress  = doneCount / (float)servicesCount;
                    Update(new LoadingData(progress, $"Loading {loading.GetType().Name}"));
                }

                await Task.Delay(100);
            }

            await _sceneService.Load(SceneName.MainScene);

            _gameStateService.ChangeState(new GameplayGameState());
        }