public override void Setup(ViewData data) { base.Setup(data); closeButton.SetListener(() => { Services.ViewService.Remove(ViewType.SocialView); Services.SoundService.PlayOneShot(SoundName.click); }); closeBigButton.SetListener(() => { Services.ViewService.Remove(ViewType.SocialView); Services.SoundService.PlayOneShot(SoundName.click); }); UpdatePromoButton(); promoButton.SetListener(() => { ViewService.Show(ViewType.PromoInputView, new ViewData { ViewDepth = ViewService.NextViewDepth }); Sounds.PlayOneShot(SoundName.click); }); if (!IsInitialized) { GameEvents.PromoReceived.Subscribe(info => { UpdatePromoButton(); }).AddTo(gameObject); IsInitialized = true; } }
public override void Start() { IX2ProfitService service = Services.GetService <IX2ProfitService>(); button.SetListener(() => { Sounds.PlayOneShot(SoundName.click); ViewService.Show(ViewType.X2ProfitView); }); Material buttonMaterial = button.GetComponent <Image>().material; int _enabledPropId = Shader.PropertyToID("_Enabled"); UpdateTimer(service, buttonMaterial, _enabledPropId); Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(_ => { UpdateTimer(service, buttonMaterial, _enabledPropId); }).AddTo(gameObject); Observable.Interval(TimeSpan.FromSeconds(4)).Subscribe(_ => { if (service.AvailableAfterInterval == 0) { parentAnimator.SetTrigger("effect"); } }).AddTo(gameObject); }
private void UpdateNextLevelControls() { IBankService bankService = Services.GetService <IBankService>(); ILocalizationRepository localization = Services.ResourceService.Localization; int currentLevel = bankService.CurrentBankLevel; if (bankService.IsMaxLevel(currentLevel)) { nextLevelControlsParent.Deactivate(); maxLevelText.Activate(); } else { nextLevelControlsParent.Activate(); maxLevelText.Deactivate(); openBankNextLevelLabel.text = string.Format(localization.GetString("lbl_next_level_bank_desc"), bankService.NextLevel); BankLevelData bankLevelData = Services.ResourceService.BankLevelRepository.GetBankLevelData(bankService.NextLevel); ProfitInterval profitInterval = AdjustProfitInterval(bankLevelData.Profit, (int)bankLevelData.ProfitInterval); string profitString = profitInterval.Profit.ToString().Size(72).Colored("#fde090"); string intervalString = UpdateTimeText(profitInterval.Interval).Size(72).Colored("#00fdf7"); nextLevelProfit.text = profitString + " " + intervalString; /* * if (bankLevelData.Profit.IsWhole()) { * string profitString = ((int)bankLevelData.Profit).ToString().Size(80).Colored("#fde090"); * int hours = TimeSpan.FromSeconds(bankLevelData.ProfitInterval).Hours; * string intervalString = UpdateTimeText(hours).Size(72).Colored("#00fdf7"); * nextLevelProfit.text = profitString + " " + intervalString; * } else { * string profitString = ((int)(bankLevelData.Profit * 2)).ToString().Size(80).Colored("#fde090"); * int hours = TimeSpan.FromSeconds(bankLevelData.ProfitInterval * 2).Hours; * string intervalString = UpdateTimeText(hours).Size(72).Colored("#00fdf7"); * nextLevelProfit.text = profitString + " " + intervalString; * }*/ openNextLevelPriceText.text = bankLevelData.LevelPriceCoins.ToString(); openNextLevelButton.SetListener(() => { if (IsAllowBuyNextLevel(bankLevelData)) { StartCoroutine(OpenEffectImpl()); Services.GetService <ISoundService>().PlayOneShot(SoundName.buyCoins); } else { ViewService.Show(ViewType.CoinRequiredView, new ViewData { UserData = bankLevelData.LevelPriceCoins, ViewDepth = GetComponentInParent <BankView>().ViewDepth + 1 }); Sounds.PlayOneShot(SoundName.click); } }); openNextLevelButton.interactable = (!bankService.IsMaxLevel(bankService.CurrentBankLevel)); } }
private void ShowFlyingModuleView() { ViewService.Show(ViewType.BuyModuleView, new ViewData { ViewDepth = ViewService.NextViewDepth, UserData = new ModuleViewModel { ScreenType = ModuleScreenType.Flight } }); }
private void ShowManagementView() { if (!ViewService.Exists(ViewType.ManagementView)) { ViewService.Show(ViewType.ManagementView, new ViewData { UserData = generator.GeneratorId }); Sounds.PlayOneShot(SoundName.click); } }
public override void Start() { base.Start(); GetComponent <Button>().SetListener(() => { ViewService.Show(ViewType.DebugView, new ViewData { ViewDepth = ViewService.NextViewDepth }); Sounds.PlayOneShot(SoundName.click); }); #if !BOSDEBUG gameObject.Deactivate(); #endif }
public void Setup(int managerId) { IMechanicService mechanicService = Services.GetService <IMechanicService>(); ILocalizationRepository localization = Services.ResourceService.Localization; manager = Services.GetService <IManagerService>().GetManager(managerId); tempMechanicView.Setup(Services.GenerationService.GetGetenerator(managerId)); UpdateBrokenedAndIncomeTexts(); buyMechanicButton.SetListener(() => { BosError error = BosError.Ok; if (mechanicService.IsAllowBuyMechanic(manager.Id, out error)) { BosError status = mechanicService.BuyMechanic(manager.Id); if (status == BosError.Ok) { Services.GetService <ISoundService>().PlayOneShot(SoundName.buyCoins); } else { Services.GetService <ISoundService>().PlayOneShot(SoundName.slotFail); } } else if (error == BosError.NoEnoughCoins) { ViewService.Show(ViewType.CoinRequiredView, new ViewData { UserData = mechanicService.GetNextMechanicPrice(manager.Id), ViewDepth = ViewService.NextViewDepth }); Sounds.PlayOneShot(SoundName.click); } else { Debug.LogError("some error"); } }); UpdateBuyButtonState(); UpdateMechanicPriceText(); UpdateMechanicCountText(); speedUpRepairx2Text.text = string.Format( localization.GetString("fmt_speed_up_x2"), "x".Colored("#FDEE21").Size(24), "2".Colored("#F9F7BC").Size(36)); CreateConstMechanicAnimObject(); }
public override void Start() { GetCoins.SetListener(() => { Sounds.PlayOneShot(SoundName.click); GetCoins.SetInteractable(false); ViewService.Show(ViewType.BankView); ViewService.Remove(ViewType.BankNotify, BosUISettings.Instance.ViewCloseDelay); }); closeButton.SetListener(() => { Sounds.PlayOneShot(SoundName.click); closeButton.SetInteractable(false); ViewService.Remove(ViewType.BankNotify, BosUISettings.Instance.ViewCloseDelay); }); CoinCount.text = Services.BankService.CoinsAccumulatedCount.ToString(); }
public void Setup() { BankLevelData bankLevelData = Services.ResourceService.BankLevelRepository.GetBankLevelData(1); if (bankLevelData.Profit.IsWhole()) { countText.text = ((int)bankLevelData.Profit).ToString(); int hours = TimeSpan.FromSeconds(bankLevelData.ProfitInterval).Hours; UpdateTimeText(hours); } else { countText.text = ((int)(bankLevelData.Profit * 2)).ToString(); int hours = TimeSpan.FromSeconds(bankLevelData.ProfitInterval * 2).Hours; UpdateTimeText(hours); } openButtonText.text = bankLevelData.LevelPriceCoins.ToString(); openButton.SetListener(() => { if (IsAllowOpenBank(bankLevelData)) { StartCoroutine(OpenEffectImpl()); Sounds.PlayOneShot(SoundName.buyCoins); } else { ViewService.Show(ViewType.CoinRequiredView, new ViewData { UserData = bankLevelData.LevelPriceCoins, ViewDepth = GetComponentInParent <BankView>().ViewDepth + 1 }); Sounds.PlayOneShot(SoundName.click); } }); //UpdateOpenButtonState(bankLevelData); }
public override void Start() { base.Start(); if (debugButton != null) { debugButton.SetListener(() => ViewService.Show(ViewType.DebugView)); } gameScroll = FindObjectOfType <GameScrollView>(); totalCountActiveGenerators = gameScroll.GetComponentsInChildren <PlanetGeneratorView>().Length; if (totalCountActiveGenerators == 0) { totalCountActiveGenerators = 1; } //Debug.Log($"founded total count of active generators => {totalCountActiveGenerators}".BoldItalic().Colored(ConsoleTextColor.navy)); Color startColor = rectangularBackgroundImage.color; leftModuleFrameInData = new Vector2AnimationData { StartValue = new Vector2(-641, -380), EndValue = new Vector2(-1056, -380), Duration = duration * 0.5f, EaseType = easeType, Target = leftModuleTransform.gameObject, OnStart = (pos, go) => leftModuleTransform.anchoredPosition = pos, OnEnd = (pos, go) => { leftModuleTransform.anchoredPosition = pos; Vector2AnimationData smallData = new Vector2AnimationData { StartValue = new Vector2(-1053, -253.4f), EndValue = new Vector2(-903, -253.4f), Duration = duration * 0.5f, EaseType = easeType, Target = leftModuleSmallTransform.gameObject, OnStart = (pos2, go2) => leftModuleSmallTransform.anchoredPosition = pos2, OnEnd = (pos2, go2) => leftModuleSmallTransform.anchoredPosition = pos2, OnUpdate = (pos2, t2, go2) => leftModuleSmallTransform.anchoredPosition = pos2 }; leftModuleSmallTransform.GetComponent <Vector2Animator>().StartAnimation(new List <Vector2AnimationData> { smallData }); }, OnUpdate = (pos, t, go) => leftModuleTransform.anchoredPosition = pos }; leftModuleFrameSmallOutData = new Vector2AnimationData { StartValue = new Vector2(-903, -253.4f), EndValue = new Vector2(-1053, -253.4f), Duration = duration * 0.5f, EaseType = easeType, Target = leftModuleSmallTransform.gameObject, OnStart = (pos, go) => leftModuleSmallTransform.anchoredPosition = pos, OnEnd = (pos, go) => { leftModuleSmallTransform.anchoredPosition = pos; Vector2AnimationData leftData = new Vector2AnimationData { StartValue = new Vector2(-1056, -380), EndValue = new Vector2(-641, -380), EaseType = EaseType.EaseOutCubic, Duration = duration, OnStart = (pos2, go2) => leftModuleTransform.anchoredPosition = pos2, OnEnd = (pos2, go2) => leftModuleTransform.anchoredPosition = pos2, OnUpdate = (pos2, t2, go2) => leftModuleTransform.anchoredPosition = pos2 }; leftModuleTransform.GetComponent <Vector2Animator>().StartAnimation(new List <Vector2AnimationData> { leftData }); }, OnUpdate = (pos, t, go) => leftModuleSmallTransform.anchoredPosition = pos, }; rightPlanetFrameInData = new Vector2AnimationData { StartValue = new Vector2(640, -380), EndValue = new Vector2(1050, -380), Duration = duration * 0.5f, EaseType = easeType, OnStart = (pos, go) => rightPlanetFrameTransform.anchoredPosition = pos, OnEnd = (pos, go) => { rightPlanetFrameTransform.anchoredPosition = pos; Vector2AnimationData smallData = new Vector2AnimationData { StartValue = new Vector2(1056, -253.4f), EndValue = new Vector2(900, -253.4f), Duration = 0.5f * duration, EaseType = easeType, OnStart = (pos2, go2) => rightPlanetSmallTransform.anchoredPosition = pos2, OnEnd = (pos2, go2) => rightPlanetSmallTransform.anchoredPosition = pos2, OnUpdate = (pos2, t2, go2) => rightPlanetSmallTransform.anchoredPosition = pos2, Target = rightPlanetSmallTransform.gameObject }; rightPlanetSmallTransform.GetComponent <Vector2Animator>().StartAnimation(new List <Vector2AnimationData> { smallData }); }, OnUpdate = (pos, t, go) => rightPlanetFrameTransform.anchoredPosition = pos, Target = rightPlanetFrameTransform.gameObject }; rightPlanetFrameSmallOutData = new Vector2AnimationData { StartValue = new Vector2(900, -253.4f), EndValue = new Vector2(1056, -253.4f), Duration = 0.5f * duration, EaseType = easeType, OnStart = (pos2, gos2) => rightPlanetSmallTransform.anchoredPosition = pos2, OnEnd = (pos2, go2) => { rightPlanetSmallTransform.anchoredPosition = pos2; Vector2AnimationData rightData = new Vector2AnimationData { StartValue = new Vector2(1050, -380), EndValue = new Vector2(640, -380), Duration = duration, EaseType = EaseType.EaseOutCubic, Target = rightPlanetFrameTransform.gameObject, OnStart = (pos, go) => rightPlanetFrameTransform.anchoredPosition = pos, OnEnd = (pos, go) => rightPlanetFrameTransform.anchoredPosition = pos, OnUpdate = (pos, t, go) => rightPlanetFrameTransform.anchoredPosition = pos }; rightPlanetFrameTransform.GetComponent <Vector2Animator>().StartAnimation(new List <Vector2AnimationData> { rightData }); }, OnUpdate = (pos2, t2, go2) => rightPlanetSmallTransform.anchoredPosition = pos2 }; rectangularBackgroundInData = new Vector2AnimationData { StartValue = new Vector2(0, 0), EndValue = new Vector2(0, 383), Duration = duration, EaseType = easeType, Target = rectangularBackgroundTransform.gameObject, OnStart = (pos, go) => { rectangularBackgroundTransform.anchoredPosition = pos; rightPlanetFrameTransform.GetComponent <Vector2Animator>().StartAnimation(new List <Vector2AnimationData> { rightPlanetFrameInData }); leftModuleTransform.GetComponent <Vector2Animator>().StartAnimation(new List <Vector2AnimationData> { leftModuleFrameInData }); }, OnEnd = (pos, go) => { State = HeaderState.Collapsed; isAnimating = false; rectangularBackgroundTransform.anchoredPosition = pos; }, OnUpdate = (pos, t, go) => { rectangularBackgroundTransform.anchoredPosition = pos; }, Events = new List <AnimationEvent <Vector2> > { new AnimationEvent <Vector2> { Mode = AnimationEventMode.Single, IsValid = (pos, t, go) => { if (pos.y >= 0f) { return(true); } return(false); }, OnEvent = (pos, t, go) => { Color sourceColor = rectangularBackgroundImage.color; ColorAnimationData colorData = new ColorAnimationData { Duration = duration * Mathf.Clamp01(60 / rectangularBackgroundTransform.sizeDelta.y) * 0.2f, EaseType = easeType, StartValue = sourceColor, EndValue = new Color(sourceColor.r, sourceColor.g, sourceColor.b, 0), Target = rectangularBackgroundImage.gameObject, OnStart = (c, go2) => rectangularBackgroundImage.color = c, OnEnd = (c, go2) => rectangularBackgroundImage.color = c, OnUpdate = (c, t2, go2) => rectangularBackgroundImage.color = c }; rectangularBackgroundImage.GetComponent <ColorAnimator>().StartAnimation(new List <ColorAnimationData> { colorData }); } } } }; rectangularBackgroundOutData = new Vector2AnimationData { StartValue = new Vector2(0, 383), EndValue = new Vector2(0, 0), Duration = duration, EaseType = easeType, OnStart = (pos, go) => { rectangularBackgroundTransform.anchoredPosition = pos; /* * rightPlanetFrameTransform.GetComponent<Vector2Animator>().StartAnimation(new List<Vector2AnimationData> { * rightPlanetFrameOutData * });*/ rightPlanetSmallTransform.GetComponent <Vector2Animator>().StartAnimation(new List <Vector2AnimationData> { rightPlanetFrameSmallOutData }); leftModuleSmallTransform.GetComponent <Vector2Animator>().StartAnimation(new List <Vector2AnimationData> { leftModuleFrameSmallOutData }); }, OnEnd = (pos, go) => { State = HeaderState.Expanded; isAnimating = false; rectangularBackgroundTransform.anchoredPosition = pos; }, OnUpdate = (pos, t, go) => rectangularBackgroundTransform.anchoredPosition = pos, Target = rectangularBackgroundTransform.gameObject, Events = new List <AnimationEvent <Vector2> > { new AnimationEvent <Vector2> { Mode = AnimationEventMode.Single, IsValid = (pos, t, go) => { if (pos.y <= 60) { return(true); } return(false); }, OnEvent = (pos, t, go) => { ColorAnimationData colorData = new ColorAnimationData { Duration = (1.0f - t) * duration, EaseType = easeType, StartValue = new Color(0, 0, 0, 0), EndValue = startColor, Target = rectangularBackgroundImage.gameObject, OnStart = (c, go2) => rectangularBackgroundImage.color = c, OnEnd = (c, go2) => rectangularBackgroundImage.color = c, OnUpdate = (c, t2, go2) => rectangularBackgroundImage.color = c }; rectangularBackgroundImage.GetComponent <ColorAnimator>().StartAnimation(new List <ColorAnimationData> { colorData }); } } } }; updateTimer.Setup(0.4f, (delta) => { if (gameScroll.VerticalNormalizedPosition >= MaxVerticalNormalizedPositionWhenEnableHiding) { if (State == HeaderState.Collapsed && !isAnimating) { Expand(); } } else { if (State == HeaderState.Expanded && !isAnimating) { Collapse(); } } }, true); }
public override void Setup(ViewData data) { base.Setup(data); closeButton.SetListener(() => { Services.ViewService.Remove(ViewType.MainView, BosUISettings.Instance.ViewCloseDelay); Services.SoundService.PlayOneShot(SoundName.click); }); soundToggle.onValueChanged.RemoveAllListeners(); soundToggle.isOn = Services.SoundService.IsMute; soundToggle.SetListener(isOn => { Services.SoundService.SetMute(isOn); }); helpToggle.onValueChanged.RemoveAllListeners(); helpToggle.isOn = Services.TutorialService.IsPaused; helpToggle.SetListener(isOn => { Services.TutorialService.SetPaused(isOn); Sounds.PlayOneShot(SoundName.click); }); /* * helpButton.SetListener(() => { * Services.ViewService.Show(ViewType.HelpView, new ViewData { * ViewDepth = ViewDepth + 1 * }); * Services.SoundService.PlayOneShot(SoundName.click); * });*/ achievmentsButton.SetListener(() => { //FindObjectOfType<StoreAchievement>()?.ShowAchievementUI(); Services.AchievmentService.ShowAchievementUI(); Services.SoundService.PlayOneShot(SoundName.click); }); profileButton.SetListener(() => { Services.ViewService.Show(ViewType.ProfileView, new ViewData { ViewDepth = ViewDepth + 1, UserData = ProfileViewTab.Office }); Services.SoundService.PlayOneShot(SoundName.click); }); leaderBoardButton.SetListener(() => { Services.LegacyGameManager.GetComponent <UnityLeaderboardMediator>().ShowLeaderboardUI_Score(); Services.SoundService.PlayOneShot(SoundName.click); }); managersButton.SetListener(() => { Services.ViewService.Show(ViewType.ManagersView, new ViewData { UserData = 0, ViewDepth = ViewDepth + 1 }); Services.SoundService.PlayOneShot(SoundName.click); }); investorButton.SetListener(() => { Services.ViewService.ShowDelayed(ViewType.InvestorsView, BosUISettings.Instance.ViewShowDelay, new ViewData { ViewDepth = ViewDepth + 1 }); Services.SoundService.PlayOneShot(SoundName.click); }); rewardsButton.SetListener(() => { Services.ViewService.Show(ViewType.RewardsView, new ViewData { ViewDepth = ViewDepth + 1 }); Services.SoundService.PlayOneShot(SoundName.click); }); spaceshipButton.SetListener(() => { Services.ViewService.ShowDelayed(ViewType.BuyModuleView, BosUISettings.Instance.ViewShowDelay, new ViewData { ViewDepth = ViewDepth + 1, UserData = new ModuleViewModel { ScreenType = ModuleScreenType.Normal, ModuleId = 0 } }); Services.SoundService.PlayOneShot(SoundName.click); }); upgradeButton.SetListener(() => { Services.ViewService.Show(ViewType.UpgradesView, new ViewData { ViewDepth = ViewDepth + 1 }); Services.SoundService.PlayOneShot(SoundName.click); }); shopButton.SetListener(() => { Services.ViewService.ShowDelayed(ViewType.UpgradesView, BosUISettings.Instance.ViewShowDelay, new ViewData { ViewDepth = ViewDepth + 1, UserData = new UpgradeViewData { TabName = UpgradeTabName.Shop, StoreSection = StoreItemSection.CompanyCash } }); Services.SoundService.PlayOneShot(SoundName.click); }); socialButton.SetListener(() => { Services.ViewService.Show(ViewType.SocialView, new ViewData { ViewDepth = ViewDepth + 1 }); Services.SoundService.PlayOneShot(SoundName.click); }); adButton.SetListener(() => { //Services.LegacyGameUI.ShowWatchAd(); ViewService.Show(ViewType.X2ProfitView, new ViewData { ViewDepth = ViewDepth + 1 }); Services.SoundService.PlayOneShot(SoundName.click); }); managerTimer.Setup(1, dt => Services.ViewService.Utils.UpdateManagerAlert(managerAlertObject), true); investorTimer.Setup(1, dt => Services.ViewService.Utils.UpdateInvestorAlert(investorAlertObject), true); rewardButtonTimer.Setup(0.5f, (dt) => rewardsButton.interactable = (Services.RewardsService.AvailableRewards > 0)); upgradeTimer.Setup(1, (dt) => Services.ViewService.Utils.UpdateUpgradeAlert(upgradeAlertObject), true); OnAvailableRewardsChanged(0, 0); OnCoinsChanged(0, 0); }
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(); } }