Exemple #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);
    }
        public override void OnEnable()
        {
            TryReachCashContent.SetActive(false);

            if (Services.InvestorService.TriesCount > 0)
            {
                descriptionText.text = LocalizationObj.GetString("lbl_investor_lock_2");
                raiseStatusButton.Deactivate();

                double requiredCash = Services.InvestorService.GetCompanyCashRequiredToSellInvestors();
                if (requiredCash.Approximately(0.0))
                {
                    requiredCashText.text = string.Empty;
                }
                else
                {
                    requiredCashText.text = $"{BosUtils.GetCurrencyString(new CurrencyNumber(requiredCash), "#FFE759", "#FFE759")}";
                    TryReachCashContent.SetActive(true);
                }
            }
            else
            {
                descriptionText.text = LocalizationObj.GetString("lbl_investor_locked_view");
                raiseStatusButton.Activate();
                requiredCashText.text = string.Empty;
            }

            raiseStatusButton.SetListener(() => {
                //Services.ViewService.ShowDelayed(ViewType.ProductsView, BosUISettings.Instance.ViewShowDelay);
                Services.ViewService.ShowDelayed(ViewType.ProfileView, BosUISettings.Instance.ViewShowDelay, new ViewData {
                    UserData = ProfileViewTab.StatusGoods
                });
                Services.SoundService.PlayOneShot(SoundName.click);
            });
        }
Exemple #3
0
 private void UpdateText()
 {
     if (text != null)
     {
         text.text = BosUtils.GetCurrencyString(new CurrencyNumber(currentValue));
     }
 }
Exemple #4
0
        private void UpdateState()
        {
            Construct();

            //print($"megaboost state => {boostService.State}");
            switch (boostService.State)
            {
            case BoostState.FirstCharger: {
                progressFill.fillAmount = boostService.FirstChargerProgress;
                timerText.text          = BosUtils.FormatTimeWithColon(boostService.FirstChargerTimer);
            }
            break;

            case BoostState.Active: {
                //progressFill.fillAmount = boostService.AtiveProgress;
                timerText.text = BosUtils.FormatTimeWithColon(boostService.ActiveTimer);
            }
            break;

            case BoostState.Locked: {
                progressFill.fillAmount = boostService.LockedProgress;
                timerText.text          = BosUtils.FormatTimeWithColon(boostService.CooldownTimer);
            }
            break;
            }
        }
    private void LoadMechanicRemote()
    {
        var items = BosUtils.LoadMechanicsRemote();

        remoteMechanicData.Clear();
        remoteMechanicData.AddRange(items);
    }
Exemple #6
0
        private void Setup()
        {
            sellButton.SetListener(() => {
                Services.InvestorService.SellToInvestors(multiplier: 1);
                Services.SoundService.PlayOneShot(SoundName.buyGenerator);
                Services.ViewService.Remove(ViewType.InvestorsView, BosUISettings.Instance.ViewCloseDelay);
            });

            /*
             *          noButton.SetListener(() => {
             *                  Services.SoundService.PlayOneShot(SoundName.buyGenerator);
             *                  Services.ViewService.Remove(ViewType.InvestorsView, BosUISettings.Instance.ViewCloseDelay);
             *          });*/
            sellAdButton.SetListener(() => {
                sellAdButton.interactable = false;
                Services.AdService.WatchAd("x2_investor", () => {
                    StartCoroutine(SellToInvestorsForAdImpl());
                });
            });



            string securitiesCount   = BosUtils.GetCurrencyString(Services.InvestorService.GetSecuritiesCountFromInvestors().ToCurrencyNumber());
            string securitiesx2Count = BosUtils.GetCurrencyString((Services.InvestorService.GetSecuritiesCountFromInvestors() * 2).ToCurrencyNumber());

            securitiesCountText.text = BosUtils.GetCurrencyString(Services.InvestorService.GetSecuritiesCountFromInvestors().ToCurrencyNumber());
            sellButtonText.text      = securitiesCount;
            sellAdButtonText.text    = securitiesx2Count;

            updateTimer.Setup(1.0f, (deltaTime) => {
                UpdateButtonInteractability();
            }, true);
        }
    private void LoadSecretaryRemote()
    {
        var items = BosUtils.GetSecretariesRemote();

        remoteSecretaryData.Clear();
        remoteSecretaryData.AddRange(items);
    }
Exemple #8
0
 private void UpdatePlayerCash()
 {
     playerCashText1.text = BosUtils.GetCurrencyString(Services.PlayerService.CompanyCash);
     playerCashText2.text = BosUtils.GetCurrencyString(
         (Services.ResourceService.PersonalImprovements.ConvertData.OfficialConvertPercent *
          Services.PlayerService.CompanyCash.Value).ToCurrencyNumber());
 }
Exemple #9
0
        public void Load(string[] files)
        {
            if (!IsLoaded)
            {
                this.files = files;
                strings.Clear();

                foreach (string file in files)
                {
                    Debug.Log($"parse file => {file.Colored(ConsoleTextColor.yellow)}");
                    var listItems = JsonConvert.DeserializeObject <List <LocalizationStringData> >(Resources.Load <TextAsset>(file).text);

                    foreach (var item in listItems)
                    {
                        uint jenkinsID = BosUtils.JenkinsOneAtATimeHash(item.id);
                        if (strings.ContainsKey(jenkinsID))
                        {
                            Debug.LogWarning($"string => {item.id} has repeated jenkins id => {jenkinsID} at file => {file}");
                        }
                        else
                        {
                            strings.Add(jenkinsID, item.GetString(Language));
                        }
                    }
                }
                IsLoaded = true;
            }
        }
Exemple #10
0
 private void OnAccumualtionProgressChanged(GeneratorInfo targetGenerator, double timer, double interval, ProfitResult profit)
 {
     if (targetGenerator.GeneratorId == generator.GeneratorId)
     {
         OnAccumulationProgressUpdated((float)BosUtils.Clamp01(timer / interval));
         UpdateTimerText(targetGenerator.RemainTime);
     }
 }
Exemple #11
0
    public override bool Check()
    {
        var optValue = BosUtils.GetBadgeObjectiveValue(StatString);

        return(optValue.Match(() => {
            return StatsCollector.Instance[StatString] >= Min;
        }, (cnt) => {
            return cnt >= Min;
        }));
    }
Exemple #12
0
        public string GetFrequentString(string key)
        {
            uint id = BosUtils.JenkinsOneAtATimeHash(key);

            if (!frequentSubcache.Contains(id))
            {
                frequentSubcache.Add(id, GetString(id));
            }
            return(frequentSubcache.GetObject(id));
        }
Exemple #13
0
        private void OnAccumulationCompleted(GeneratorInfo targetGenerator, ProfitResult profit)
        {
            if (targetGenerator.GeneratorId == generator.GeneratorId)
            {
                AddCompanyCash(targetGenerator.AccumulatedCash);
                CreateAccumulatedText(targetGenerator.AccumulatedCash, targetGenerator.IsManual);

                OnAccumulationProgressUpdated((float)BosUtils.Clamp01(targetGenerator.GenerateTimer / targetGenerator.AccumulateInterval));
                UpdateTimerText(generator.RemainTime);
            }
        }
Exemple #14
0
        public override void OnEnable()
        {
            base.OnEnable();
            //var product = IAPManager.instance.GetProduct(productId);
            var resourceData = Services.ResourceService.Products.GetProduct(productId);

            Services.Inap.GetProductByResourceId(productId).Match(() => {
                //Clear();
                buyButton.Activate();
                buyButton.SetListener(() => Services.Inap.PurchaseProduct(resourceData));
                priceText.text = "0.00";

                return(F.None);
            }, product => {
                buyButton.Activate();
                buyButton.SetListener(() => Services.Inap.PurchaseProduct(resourceData));

                if (longDescriptionText != null)
                {
                    /*
                     * if(resourceData.UseCash || resourceData.UseSecurities || resourceData.UsePlayerCash) {
                     *  var value = Services.Currency.CreatePriceStringSeparated(GetSoldCurrencyValue(resourceData));
                     *  if(value.Length > 1) {
                     *      longDescriptionText.text = $"{value[0]} {value[1]}";
                     *  } else {
                     *      longDescriptionText.text = $"{value[0]}";
                     *  }
                     * } else {
                     *  longDescriptionText.text = string.Empty;
                     * }*/
                    longDescriptionText.text = string.Empty;
                }

                if (descriptionText != null)
                {
                    if (resourceData.UseCash || resourceData.UseSecurities || resourceData.UsePlayerCash)
                    {
                        var cost             = GetSoldCurrencyValue(resourceData);
                        CurrencyNumber num   = new CurrencyNumber(cost);
                        string costShortText = "$ " + BosUtils.GetCurrencyString(num, "#f0b03c", "#f9f7bc");
                        descriptionText.text = costShortText;
                    }
                    else
                    {
                        descriptionText.text = string.Empty;
                    }
                }

                priceText.text = product.metadata.localizedPriceString;
                return(F.Some(product));
            });

            AnimateIcon();
        }
Exemple #15
0
        public string GetString(string key)
        {
            uint id = BosUtils.JenkinsOneAtATimeHash(key);

            if (strings.ContainsKey(id))
            {
                return(strings[id]);
            }
            Debug.LogError($"not found string with key => {key}");
            return(string.Empty);
        }
    public override void Activate(Reward reward)
    {
        base.Activate(reward);

        var isBalanceReward = reward is LifetimeBalanceReward;

        Particle.SetActive(isBalanceReward);
        if (isBalanceReward)
        {
            var balanceReward = reward as LifetimeBalanceReward;
            Name.text = BosUtils.GetCurrencyString(new CurrencyNumber(balanceReward.Result()), "", "#FFDF5F");
        }
    }
Exemple #17
0
 private string GetCurrencyString(CurrencyNumber num)
 {
     /*
      * if(num != null) {
      *  string[] prettyArr = num.AbbreviationColoredComponents("", "#FFE565");
      *  string result = prettyArr[0];
      *  if (!string.IsNullOrEmpty(prettyArr[1])) {
      *      result += " " + prettyArr[1];
      *  }
      *  return result;
      * }
      * return "0";*/
     return(BosUtils.GetCurrencyString(num));
 }
Exemple #18
0
        private IEnumerator ShowMoveTextFailImpl(UnofficialTransferCashInfo info)
        {
            yield return(new WaitForSeconds(interval));

            GameObject textPrefab   = Services.ResourceService.Prefabs.GetPrefab("movetext");
            GameObject textInstance = Instantiate(textPrefab);

            Text text = textInstance.GetComponent <Text>();

            text.text = $"-{BosUtils.GetCurrencyString(info.LooseValue.ToCurrencyNumber(), "", "")}";
            //text.SetAllDirty();

            RectTransform textTransform = textInstance.GetComponent <RectTransform>();

            textTransform.SetParent(transform, false);
            textTransform.anchoredPosition = endObject.anchoredPosition;
            textTransform.localScale       = new Vector3(2, 2, 1);
            Color startColor = Color.red;
            Color endColor   = Color.red.ChangeAlpha(0.1f);
            var   colorData  = AnimUtils.GetColorAnimData(startColor, endColor, 1.5f, EaseType.EaseOutQuintic,
                                                          textTransform, BosAnimationMode.Single,
                                                          () => { });
            var positionData = new Vector2AnimationData()
            {
                StartValue = textTransform.anchoredPosition,
                EndValue   = textTransform.anchoredPosition - new Vector2(0, 300),
                Duration   = 1.5f,
                EaseType   = EaseType.EaseOutQuintic,
                Target     = textInstance,
                OnStart    = (p, o) => textTransform.anchoredPosition = p,
                OnUpdate   = (p, t, o) => textTransform.anchoredPosition = p,
                OnEnd      = (p, o) => {
                    textTransform.anchoredPosition = p;
                    Destroy(textInstance);
                }
            };
            ColorAnimator   colorAnimator    = textInstance.GetComponent <ColorAnimator>();
            Vector2Animator positionAnimator = textInstance.GetComponent <Vector2Animator>();

            colorAnimator.StartAnimation(colorData);
            positionAnimator.StartAnimation(positionData);
            Sounds.PlayOneShot(SoundName.slotFail);
            ViewService.ShowDelayed(ViewType.TransferWarningView, 0.5f, new ViewData {
                ViewDepth = ViewService.NextViewDepth,
                UserData  = info.LooseValue
            });
            animObjects.Add(textInstance);
        }
    private void SaveRemoteToLocal()
    {
        switch (analyzeType)
        {
        case AnalyzeType.Mechanic: {
            BosUtils.SaveMechanicsToLocal(remoteMechanicData);
        }
        break;

        case AnalyzeType.Secretary: {
            BosUtils.SaveSecretariesLocal(remoteSecretaryData);
        }
        break;
        }
        AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
    }
Exemple #20
0
 private void UpdateView()
 {
     levelTexts.ToList().ForEach(t => t.text = level.ToString());
     BosUtils.If(() => IsUnlocked, () => {
         unlockedView.Activate();
         BosUtils.MakeList(nextLevelView, lockedView).ForEach(v => v.Deactivate());
     }, () => {
         BosUtils.If(() => level == Services.BankService.NextLevel, () => {
             nextLevelView.Activate();
             BosUtils.MakeList(lockedView, unlockedView).ForEach(v => v.Deactivate());
         }, () => {
             lockedView.Activate();
             BosUtils.MakeList(unlockedView, nextLevelView).ForEach(v => v.Deactivate());
         });
     });
 }
Exemple #21
0
        public void UpdateView()
        {
            CachePlanetView();
            var planetLocalData = ResourceService.PlanetNameRepository.GetPlanetNameData(planetView.planetId);

            if (planetLocalData.IsModuleRequired && !Services.Modules.IsOpened(planetLocalData.module_id))
            {
                var moduleData = Services.Modules.GetModule(planetLocalData.module_id).Data;
                currencyIcon.overrideSprite = ResourceService.GetCurrencySprite(moduleData.Currency);
                priceText.text = BosUtils.GetCurrencyString(moduleData.Currency, "#FFFFFF", "FFE565");
                UpdateModuleName();
            }
            else
            {
                DeactivateAll();
            }
        }
Exemple #22
0
 public void QuickBuy()
 {
     if (Services.UpgradeService.IsQuickBuyResearched)
     {
         List <UpgradeData> dataList = cashViews.DataList.Select(d => d).ToList();
         foreach (var data in dataList)
         {
             if (Services.PlayerService.IsEnough(Bos.Data.Currency.Create(data.CurrencyType, data.Price(() => {
                 return(BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data));
             }))))
             {
                 Services.UpgradeService.BuyUpgrade(data);
             }
         }
         Services.SoundService.PlayOneShot(SoundName.buyUpgrade);
     }
 }
Exemple #23
0
        private string ConstructPriceString(UpgradeData data)
        {
            switch (data.CurrencyType)
            {
            case CurrencyType.CompanyCash: {
                return(Currencies.DefaultCurrency.CreatePriceString(data.Price(() => {
                        return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data);
                    }), false, " ").ToUpper());
            }

            case CurrencyType.Securities: {
                return(Currencies.Investors.CreatePriceString(data.Price(() => {
                        return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data);
                    }), false, " ").ToUpper());
            }
            }
            return(string.Empty);
        }
Exemple #24
0
        private string ConstructPriceShortString(UpgradeData data)
        {
            switch (data.CurrencyType)
            {
            case CurrencyType.CompanyCash: {
                return("$" + BosUtils.GetCurrencyString(new CurrencyNumber(data.Price(() => {
                        return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data);
                    })), "#FFFFFF", "#FBEF20"));
            }

            case CurrencyType.Securities: {
                return(BosUtils.GetCurrencyString(new CurrencyNumber(data.Price(() => {
                        return BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data);
                    })), "#FFFFFF", "#FBEF20"));
            }
            }
            return(string.Empty);
        }
Exemple #25
0
        private void UpdateViews()
        {
            IBankService            bankService  = Services.GetService <IBankService>();
            ILocalizationRepository localization = Services.ResourceService.Localization;

            int coinsAccumulatedCount = bankService.CoinsAccumulatedCount;

            if (coinsAccumulatedCount > 0)
            {
                TimeSpan timeSpan = TimeSpan.FromSeconds(bankService.TimerFromLastCollect);
                int      hours    = timeSpan.Hours;
                if (hours == 0)
                {
                    hours = 1;
                }

                timerFromLastCollectText.text = string.Format(localization.GetString("fmt_bank_time_from_last_collect"), hours);
                timeToFollowingCoinText.text  = string.Empty;
                //takeButton.interactable = true;
                takeButton.SetInteractableWithShader(true && isNoCollectionProcess);
                Color takeButtonTextColor;
                if (ColorUtility.TryParseHtmlString("#fbef21", out takeButtonTextColor))
                {
                    takeButtonText.color = takeButtonTextColor;
                }
            }
            else
            {
                timerFromLastCollectText.text = string.Empty;
                timeToFollowingCoinText.text  = string.Format(localization.GetString("fmt_bank_next_coin"),
                                                              BosUtils.FormatTimeWithColon(bankService.TimeToNextCoin).ToString().Colored("#fbef21"));
                //takeButton.interactable = false;
                takeButton.SetInteractableWithShader(false);
                Color takeButtonTextColor;
                if (ColorUtility.TryParseHtmlString("#b3b3b3", out takeButtonTextColor))
                {
                    takeButtonText.color = takeButtonTextColor;
                }
            }

            accumulatedCoinCount.text = bankService.CoinsAccumulatedCount.ToString();
        }
        public override void Setup(ViewData data)
        {
            base.Setup(data);
            MoveIn();
            closeButton.SetListener(() => {
                Services.ViewService.Remove(ViewType.InvestorConfirmMessageBox, 0.2f);
                Services.SoundService.PlayOneShot(SoundName.click);
                MoveOut();
            });
            if (data != null)
            {
                priceText.text = BosUtils.GetCurrencyString(((double)data.UserData).ToCurrencyNumber());
            }
            else
            {
                priceText.text = string.Empty;
            }

            Services.SoundService.PlayOneShot(SoundName.race_win);
        }
Exemple #27
0
        public void Setup(ProductData productData)
        {
            this.Data = productData;
            this.cachedProductData = productData;
            IResourceService        resourceService = Services.ResourceService;
            ILocalizationRepository localization    = resourceService.Localization;

            nameText.text   = localization.GetString(productData.name_id);
            pointsText.text = "profile_status".GetLocalizedString();

            var points = BosUtils.GetCurrencyStringSimple(new CurrencyNumber(productData.status_points));

            pointsCountText.text = $"+{points}";

            if (Services.PlayerService.IsProductPurchased(productData.id))
            {
                checkObject.Activate();
                buyButton.Deactivate();
            }
            else
            {
                checkObject.Deactivate();
                buyButton.Activate();
                var price = productData.price; //Services.GenerationService.CalculateProfit20Minute(productData.transport_Id, productData.transport_count, productData.planet_Id);
                priceText.text = BosUtils.GetCurrencyStringSimple(Bos.Data.Currency.CreatePlayerCash(price));
            }

            buyButton.SetListener(() => {
                if (Services.PlayerService.PurchaseProduct(productData) == TransactionState.Success)
                {
                    Services.GetService <ISoundService>().PlayOneShot(SoundName.buyUpgrade);
                    //playe buy effect
                    CreateParticles();
                    ScaleEffect();
                }
            });

            updateTimer.Setup(0.3f, (deltaTime) => {
                UpdateButtonState(productData);
            }, invokeImmediatly: true);
        }
Exemple #28
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");
                });
            });
        }
Exemple #29
0
        private void UpdateButtonInteractability()
        {
            int currentTime = Services.TimeService.UnixTimeInt;
            int allowTime   = Services.InvestorService.AllowSellTime;
            var states      = Services.InvestorService.SellState;

            bool isSellStateOk = ViewService.Utils.IsInvestorSellStateOk(states);

            sellButton.interactable   = isSellStateOk;
            sellAdButton.interactable = isSellStateOk;

            if (IsCooldown(states))
            {
                allowSellTimerParent.Activate();
                cooldownTimerText.text = BosUtils.FormatTimeWithColon(Mathf.Abs(allowTime - currentTime));
            }
            else
            {
                allowSellTimerParent.Deactivate();
            }
        }
Exemple #30
0
        public override void Start()
        {
            base.Start();

            toggle.onValueChanged.RemoveAllListeners();
            bool isOnValue = Services.TimeChangeService.IsEnabled;

            toggle.isOn = isOnValue;
            UpdateToggleText(toggle.isOn);

            toggle?.SetListener(isOn => {
                Services.TimeChangeService.SetEnabled(isOn);
                Services.SoundService.PlayOneShot(SoundName.click);
                UpdateToggleText(isOn);
            });

            realUpdateTimer.Setup(1, dt => realtimeText.text = BosUtils.FormatTimeWithColon(Services.TimeChangeService.RealTime), true);

#if !BOSDEBUG
            gameObject.Deactivate();
#endif
        }