private IEnumerator LoadNetResourcesImpl() { if (isLoadFromLocalFiles) { LoadPlanetsLocal(); LoadShipModulesLocal(); LoadMechanicsLocal(); LoadSecretariesLocal(); LoadTransportStrengthLocal(); LoadBankLocal(); LoadPlanetTransportLocal(); LoadPersonalImprovementsLocal(); LoadManagerImprovementsLocal(); isManagersLoaded = isGeneratorsLoaded = true; Debug.Log($"Resources is loade => {IsLoaded}".Colored(ConsoleTextColor.orange)); Debug.Log(GetResourceLoadingStateString()); } else { Services.GetService <IServerBalanceService>().GetBalanceFromServer(); yield return(new WaitUntil(() => isManagersLoaded && isGeneratorsLoaded)); INetService netService = Services.GetService <INetService>(); netService.GetBalance(planets => { PlanetRepository.SetFromExternalDataSource(planets); Debug.Log("planets setted from external data source".Colored(ConsoleTextColor.yellow)); GameEvents.OnPlanetsReceivedFromServer(); GameEvents.OnNetResourceLoaded("planets"); isPlanetsLoaded = true; }, error => { Debug.Log(error.Colored(ConsoleTextColor.red)); LoadPlanetsLocal(); }); yield return(new WaitUntil(() => isPlanetsLoaded)); netService.GetBalanceShip(modules => { ShipModuleRepository.SetFromExternalDataSource(modules); //Debug.Log("modules setted from external data source".Colored(ConsoleTextColor.yellow)); isShipModulesLoaded = true; GameEvents.OnNetResourceLoaded("space ship modules"); }, error => { LoadShipModulesLocal(); }); yield return(new WaitUntil(() => isShipModulesLoaded)); netService.GetBalanceMechanic(mechanics => { MechanicDataRepository.SetFromExternalDataSource(mechanics); isMechanicsLoaded = true; GameEvents.OnNetResourceLoaded("mechanics"); }, error => { LoadMechanicsLocal(); }); yield return(new WaitUntil(() => isMechanicsLoaded)); netService.GetSecretaryBalance(secretaries => { SecretaryDataRepository.SetFromExternalDataSource(secretaries); isSecretariesLoaded = true; GameEvents.OnNetResourceLoaded("secretaries"); }, error => { LoadSecretariesLocal(); }); yield return(new WaitUntil(() => isSecretariesLoaded)); netService.GetTransportStrength(strengs => { UnitStrengthDataRepository.SetFromExternalSource(strengs); isUnitStrengthLoaded = true; GameEvents.OnNetResourceLoaded("transport strength"); }, error => { LoadTransportStrengthLocal(); }); yield return(new WaitUntil(() => isUnitStrengthLoaded)); netService.GetBank(bankLevels => { BankLevelRepository.SetFromExternalDataSource(bankLevels); isBankLoaded = true; GameEvents.OnNetResourceLoaded("bank"); }, error => { LoadBankLocal(); }); yield return(new WaitUntil(() => isBankLoaded)); netService.GetPlanetsTransport(generators => { Generators.Append(generators, GeneratorType.Planet); isPlanetGeneratorsLoaded = true; GameEvents.OnNetResourceLoaded("planet generators"); }, (error) => { LoadPlanetTransportLocal(); }); yield return(new WaitUntil(() => isPlanetGeneratorsLoaded)); /* * netService.GetPersonalImprovements(personalImprovements => { * PersonalImprovements.SetFromExternalSource(personalImprovements); * isPersonalImprovementsLoaded = true; * GameEvents.OnNetResourceLoaded("personal_improvements"); * * }, error => { * LoadPersonalImprovementsLocal(); * });*/ LoadPersonalImprovementsLocal(); netService.GetManagerImprovements(improvements => { ManagerImprovements.SetFromExternalSource(improvements); isManagerImprovementsLoaded = true; GameEvents.OnNetResourceLoaded("manager improvements"); }, error => { LoadManagerImprovementsLocal(); }); yield break; } }
private void LoadBankLocal() { BankLevelRepository.Load(kBankFile); Debug.Log($"bank setted from local file"); isBankLoaded = true; }