private bool IsNeedShowDependView() { int researchPrice = generator.ResearchPrice(Planets); if (Services.PlayerService.IsEnoughCoins(researchPrice)) { if (generator.IsDependent) { var requiredGenerator = Services.GenerationService.Generators.GetGeneratorInfo(generator.RequiredGeneratorId); if (requiredGenerator != null) { if (requiredGenerator.State != GeneratorState.Active) { return(true); } } } } return(false); }
public void Setup(int generatorId) { generator = Services.GenerationService.Generators.GetGeneratorInfo(generatorId); int researchPrice = generator.ResearchPrice(Planets); researchButton.SetListener(() => { IPlayerService playerService = Services.PlayerService; if (IsNeedShowDependView()) { Sounds.PlayOneShot(SoundName.click); ViewService.Show(ViewType.DependGeneratorView, new ViewData { ViewDepth = ViewService.NextViewDepth, UserData = generator }); } else if (playerService.IsEnoughCoins(researchPrice)) { playerService.RemoveCoins(researchPrice); Services.GenerationService.Research(generator.GeneratorId); transitionParticles.Play(); Analytics.CustomEvent(AnalyticsStrings.RESEARCH_ZEPPELIN); Services.GetService <ISoundService>().PlayOneShot(SoundName.Poof); } else { //notEnoughCoinsPopup.GetComponent<NotEnoughCoinsScreen>().Show(generator.Data.CoinPrice); Sounds.PlayOneShot(SoundName.click); Services.ViewService.Show(ViewType.CoinRequiredView, new ViewData { UserData = researchPrice }); } }); /* * if(generator.Data.Type == GeneratorType.Planet ) { * PlanetNameData planetNameData = Services.ResourceService.PlanetNameRepository.GetPlanetNameData(generator.PlanetId); * generatorNameText.text = Services.ResourceService.Localization.GetString(planetNameData?.name) ?? string.Empty; * generatorIconImage.overrideSprite = Services.ResourceService.Sprites.GetObject(planetNameData.icon); * } else { * generatorNameText.text = Services.ResourceService.Localization.GetString(generator.Data.Name); * * }*/ ViewService.Utils.ApplyGeneratorName(generatorNameText, generator); if (generator.Data.Type == GeneratorType.Normal) { UpdateGeneratorIcon(); } var currentPlanetData = Services.ResourceService.PlanetNameRepository.GetPlanetNameData(Services.PlanetService.CurrentPlanet.Id); bg.overrideSprite = Services.ResourceService.GetSpriteByKey(currentPlanetData.research_bg); priceText.text = (researchPrice != 0) ? researchPrice.ToString() : string.Empty; if (researchPrice != 0) { coinIconObject?.Activate(); } else { coinIconObject.Deactivate(); } UpdateResearchButtonInteractability(); //autoresearch planets if (generator.Data.Type == GeneratorType.Planet) { AutoResearch(); } }