Example #1
0
    public override void Start()
    {
        _man = GetComponent <Manager>();

        //guard from setting teleport manager before mars
        if (_man.GeneratorIdToManage.IsTeleport() && !Planets.IsMarsOpened)
        {
            gameObject.SetActive(false);
            return;
        }

        _buttonAnimator = BuyButton.GetComponent <Animator>();

        var generator = Services.ResourceService.Generators.GetGeneratorData(_man.GeneratorIdToManage); //GameData.instance.GetGenerator(_man.GeneratorIdToManage);

        DescriptionView.text = generator.Name.GetLocalizedString().ToUpper() + " " + "Manager".GetLocalizedString().ToUpper();

        if (Services.ManagerService.IsHired(_man.GeneratorIdToManage))
        {
            BuyButton.gameObject.SetActive(false);
            Checkmark.SetActive(true);
            _bought.Value = true;
        }

        Services.ViewService.Utils.ApplyManagerIcon(Icon, Services.GenerationService.GetGetenerator(_man.GeneratorIdToManage), true);
        NameView.SetManagerName(_man.GeneratorIdToManage);

        PriceView.text = BosUtils.GetStandardCurrencyString(_man.Cost);
        _hireText      = BuyButton.GetComponentInChildren <Text>();
        _bought.Subscribe(val => { UpdateState(Services.PlayerService.CompanyCash.Value); });
        OnCompanyCashChanged(new CurrencyNumber(), Services.PlayerService.CompanyCash);
    }
Example #2
0
        public override void Setup(ViewData data)
        {
            base.Setup(data);
            BackToGameData backToGameData = data.UserData as BackToGameData;

            if (backToGameData == null)
            {
                throw new System.ArgumentException(nameof(data.UserData));
            }

            /*
             * string[] cashStrings = Services.Currency.CreatePriceStringSeparated(backToGameData.Cash);
             * string[] doubleCashStrings = Services.Currency.CreatePriceStringSeparated(backToGameData.Cash * 2);
             *
             * offlineBalanceText.text = cashStrings[0];
             * BosUtils.If(() => cashStrings.Length > 1, () => offlineBalanceWordText.text = cashStrings[1], () => offlineBalanceWordText.text = string.Empty);
             *
             * doubleBalanceText.text = doubleCashStrings[0];
             * BosUtils.If(() => doubleCashStrings.Length > 1, () => doubleBalanceWordText.text = doubleCashStrings[1], () => doubleBalanceWordText.text = string.Empty);
             */

            offlineBalanceText.text = BosUtils.GetStandardCurrencyString(backToGameData.Cash);
            doubleBalanceText.text  = BosUtils.GetStandardCurrencyString(backToGameData.Cash * 2);

            TimeSpan ts = TimeSpan.FromSeconds(backToGameData.Interval);

            offlineTimeText.text = $"{(int)ts.TotalHours:D2}:{ts.Minutes:D2}:{ts.Seconds:D2}";

            continueButton.SetListener(() => {
                Sounds.PlayOneShot(SoundName.click);
                ViewService.Remove(ViewType.BackToGameView, BosUISettings.Instance.ViewCloseDelay);
            });

            watchAdButton.SetListener(() => {
                ViewService.Remove(ViewType.BackToGameView, BosUISettings.Instance.ViewCloseDelay);
                Services.AdService.WatchAd("WellcomeBack", () => {
                    Player.AddGenerationCompanyCash(backToGameData.Cash);
                    FacebookEventUtils.LogADEvent("WellcomeBack");
                });
            });
        }