Esempio n. 1
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());
 }
Esempio n. 2
0
 private void UpdateText()
 {
     if (text != null)
     {
         text.text = BosUtils.GetCurrencyString(new CurrencyNumber(currentValue));
     }
 }
Esempio n. 3
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);
        }
        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);
            });
        }
Esempio n. 5
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();
        }
Esempio n. 6
0
    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");
        }
    }
Esempio n. 7
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));
 }
Esempio n. 8
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);
        }
Esempio n. 9
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();
            }
        }
Esempio n. 10
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);
        }
        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);
        }
Esempio n. 12
0
        public void Setup(HistoryEntry entry)
        {
            this.Data = entry;
            var planetNameData = Services.ResourceService.PlanetNameRepository.GetPlanetNameData(entry.PlanetId);

            backImage.overrideSprite  = Services.ResourceService.GetSprite(planetNameData.history_back);
            nameText.text             = Services.ResourceService.Localization.GetString(planetNameData.name);
            planetIcon.overrideSprite = Services.ResourceService.GetSprite(planetNameData.ui_icon);
            countText.text            = BosUtils.GetCurrencyString(entry.Securities.ToCurrencyNumber());
            trigger.SetListener(() => {
                Vector3AnimationData data1 = new Vector3AnimationData {
                    AnimationMode = BosAnimationMode.Single,
                    Duration      = 0.3f,
                    EaseType      = EaseType.EaseInOutQuad,
                    StartValue    = Vector3.one,
                    EndValue      = new Vector3(1, 1.15f, 1),
                    Target        = backImage.gameObject,
                    OnStart       = (s, go) => BackImageRectTransform.localScale = s,
                    OnUpdate      = (s, t, go) => BackImageRectTransform.localScale = s,
                    OnEnd         = (s, go) => {
                        BackImageRectTransform.localScale = s;
                        Vector3AnimationData data2        = new Vector3AnimationData {
                            AnimationMode = BosAnimationMode.Single,
                            Duration      = 0.3f,
                            EaseType      = EaseType.EaseInOutQuad,
                            Target        = backImage.gameObject,
                            StartValue    = new Vector3(1, 1.15f, 1),
                            EndValue      = Vector3.one,
                            OnStart       = (s2, go2) => BackImageRectTransform.localScale = s2,
                            OnUpdate      = (s2, t2, go2) => BackImageRectTransform.localScale = s2,
                            OnEnd         = (s2, go2) => BackImageRectTransform.localScale = s2
                        };
                        backImage.gameObject.GetOrAdd <Vector3Animator>().StartAnimation(data2);
                    }
                };
                backImage.gameObject.GetOrAdd <Vector3Animator>().StartAnimation(data1);
            });
        }
Esempio n. 13
0
        private void Setup()
        {
            if (moduleService == null)
            {
                moduleService = Services.GetService <IShipModuleService>();
            }
            if (module == null)
            {
                module = moduleService.GetModule(moduleId);
            }

            if (moduleNameData == null)
            {
                moduleNameData = Services.ResourceService.ModuleNameRepository.GetModuleNameData(moduleId);
            }

            nameText.text            = Services.ResourceService.Localization.GetString(moduleNameData.name);
            iconImage.overrideSprite = Services.ResourceService.GetSpriteByKey(moduleNameData.icon);

            currencyIconImage.overrideSprite = Services.ResourceService.GetCurrencySprite(module.Data.Currency);
            currencyText.text = BosUtils.GetCurrencyString(module.Data.Currency);

            ModuleTransactionState status;
            bool isAllowedToBuy = moduleService.IsAllowBuyModule(moduleId, out status);

            if (isAllowedToBuy)
            {
                requirementText.text   = string.Empty;
                buyButton.interactable = true;
            }
            else
            {
                switch (status)
                {
                case ModuleTransactionState.NotEnoughCurrency: {
                    requirementText.text   = string.Empty;
                    currencyText.text      = BosUtils.GetCurrencyString(module.Data.Currency, "#FF0000");
                    buyButton.interactable = false;
                }
                break;

                case ModuleTransactionState.NotValidState: {
                    var planetData = Services.ResourceService.Planets.GetPlanet(module.Data.PlanetId);
                    if (planetData == null)
                    {
                        Debug.LogError($"not found planet for upgrade level => {module.Data.PlanetId}");
                        return;
                    }
                    PlanetNameData planetNameData = Services.ResourceService.PlanetNameRepository.GetPlanetNameData(planetData.Id);
                    requirementText.text = string.Format(Services.ResourceService.Localization.GetString("fmt_module_requirement"),
                                                         Services.ResourceService.Localization.GetString(planetNameData.name));
                    buyButton.interactable = false;
                    buyText.color          = Color.grey;
                }
                break;
                }
            }

            buyButton.SetListener(() => {
                var buyStatus = moduleService.BuyModule(moduleId);
                if (buyStatus == ModuleTransactionState.Success)
                {
                    Services.GetService <ISoundService>().PlayOneShot(SoundName.Poof);
                    buyParticles?.Play();
                }
                else
                {
                    Services.GetService <ISoundService>().PlayOneShot(SoundName.click);
                }
            });

            switch (module.State)
            {
            case ShipModuleState.Opened: {
                checkObject.Activate();
                buyButton.Deactivate();
                requirementText.text = string.Empty;
            }
            break;

            default: {
                checkObject.Deactivate();
                buyButton.Activate();
            }
            break;
            }
        }
Esempio n. 14
0
        public void Setup(double cashCount, int coinCount, bool success)
        {
            //var colorAnimator = backgroundImage.gameObject.GetOrAdd<ColorAnimator>();
            //var scaleAnimator = backFrameTransform.gameObject.GetOrAdd<Vector3Animator>();

            /*
             * Vector3AnimationData scaleData = new Vector3AnimationData {
             *  StartValue = Vector3.zero,
             *  EndValue = Vector3.one,
             *  Duration = 0.2f,
             *  AnimationMode = BosAnimationMode.Single,
             *  EaseType = EaseType.EaseInOutQuintic,
             *  Target = backFrameTransform.gameObject,
             *  OnStart = (s, o) => backFrameTransform.localScale = s,
             *  OnUpdate = (s, t, o) => backFrameTransform.localScale = s,
             *  OnEnd = (s, o) => {
             *      backFrameTransform.localScale = s;
             *  }
             * };
             *
             * ColorAnimationData colorData = new ColorAnimationData {
             *  StartValue = new Color(0, 0, 0, 0),
             *  EndValue = new Color(0, 0, 0, 0.7f),
             *  Duration = 0.5f,
             *  AnimationMode = BosAnimationMode.Single,
             *  EaseType = EaseType.EaseInOutQuad,
             *  Target = backgroundImage.gameObject,
             *  OnStart = (c, o) => backgroundImage.color = c,
             *  OnUpdate = (c, t, o) => backgroundImage.color = c,
             *  OnEnd = (c, o) => {
             *      backgroundImage.color = c;
             *      scaleAnimator.StartAnimation(scaleData);
             *  }
             * };
             * colorAnimator.StartAnimation(colorData);*/


            FloatAnimationData alphaData = new FloatAnimationData {
                StartValue    = 0,
                EndValue      = 1,
                Duration      = 0.3f,
                AnimationMode = BosAnimationMode.Single,
                EaseType      = EaseType.Linear,
                Target        = gameObject,
                OnStart       = (v, o) => canvasGroup.alpha = v,
                OnUpdate      = (v, t, o) => canvasGroup.alpha = v,
                OnEnd         = (v, o) => canvasGroup.alpha = v
            };

            GetComponent <FloatAnimator>().StartAnimation(alphaData);

            cashText.text = BosUtils.GetCurrencyString(new CurrencyNumber(cashCount), "#FFFFFF", "#FFDF5F");
            coinText.text = coinCount.ToString();

            if (!success)
            {
                contentParent.Deactivate();
                failText.Activate();
            }
            else
            {
                failText.Deactivate();
            }

            okButton.SetListener(() => {
                if (Services != null)
                {
                    Services.SoundService.PlayOneShot(SoundName.click);
                    backgroundImage.Deactivate();

                    if (success)
                    {
                        Services.PlayerService.AddGenerationCompanyCash(cashCount);
                        if (coinCount > 0)
                        {
                            Services.PlayerService.AddCoins(coinCount);
                        }
                    }

                    SceneManager.UnloadSceneAsync(6);
                }
                else
                {
                    backgroundImage.Deactivate();
                }
            });
        }
Esempio n. 15
0
        public void Setup(ShipModuleInfo module)
        {
            this.module = module;
            ModuleNameData moduleNameData = Services.ResourceService.ModuleNameRepository.GetModuleNameData(module.Id);

            moduleNameText.text = Services.ResourceService.Localization.GetString(moduleNameData.name);
            switch (module.State)
            {
            case ShipModuleState.Opened: {
                currencyIconImage.Deactivate();
                currencyText.Deactivate();
                planetImage.Deactivate();
                buyButton.Deactivate();
            }
            break;

            case ShipModuleState.Available: {
                currencyIconImage.Activate();
                currencyText.Activate();
                planetImage.Deactivate();
                buyButton.Activate();
            }
            break;

            case ShipModuleState.Locked: {
                currencyIconImage.Activate();
                currencyText.Activate();
                planetImage.Activate();
                buyButton.Activate();
            }
            break;
            }
            currencyIconImage.overrideSprite = Services.ResourceService.GetCurrencySprite(module.CurrencyType);
            currencyText.text = BosUtils.GetCurrencyString(Currency.Create(module.CurrencyType, module.Price));

            PlanetNameData planetNameData = Services.ResourceService.PlanetNameRepository.GetPlanetNameData(module.Data.PlanetId);

            if (planetNameData != null)
            {
                planetImage.overrideSprite = Services.ResourceService.GetSpriteByKey(planetNameData.icon);
            }
            else
            {
                planetImage.overrideSprite = Services.ResourceService.Sprites.FallbackSprite;
            }

            buyButton.SetListener(() => {
                var status = Services.GetService <IShipModuleService>().BuyModule(module.Id);
                switch (status)
                {
                case ModuleTransactionState.Success: {
                    Services.SoundService.PlayOneShot(SoundName.buyUpgrade);
                    Setup(module);
                }
                break;

                case ModuleTransactionState.NotEnoughCurrency:
                    {
                        if (module.CurrencyType == CurrencyType.Coins)
                        {
                            Services.ViewService.Show(ViewType.CoinRequiredView, new ViewData {
                                UserData = (int)module.Price
                            });
                        }
                    }
                    break;
                }
            });

            IShipModuleService moduleService = Services.GetService <IShipModuleService>();

            updateTimer.Setup(0.5f, (deltaTime) => {
                ModuleTransactionState moduleTransactionState;
                if (moduleService.IsAllowBuyModule(module.Id, out moduleTransactionState))
                {
                    buyButton.interactable = true;
                }
                else if (moduleTransactionState == ModuleTransactionState.NotEnoughCurrency && module.CurrencyType == CurrencyType.Coins)
                {
                    buyButton.interactable = true;
                }
                else
                {
                    buyButton.interactable = false;
                }
            }, true);

            MoveObject(module);
        }
Esempio n. 16
0
        public override void Setup(ViewData data)
        {
            base.Setup(data);

            ISpecialOfferService specialOfferService = Services.GetService <ISpecialOfferService>();

            playerCashRewardCountText.text = "$" + BosUtils.GetCurrencyString(specialOfferService.PlayerCashReward.ToCurrencyNumber(), string.Empty, string.Empty);
            playerCashMaxBalanceText.text  = MaxBalanceFormattedString(specialOfferService.MaxBalanceBonus);
            coinsRewardText.text           = string.Format(LocalizationObj.GetString("fmt_coins_2"), specialOfferService.CoinsReward);
            companyCashRewardText.text     = "$" + BosUtils.GetCurrencyString(specialOfferService.ComplanyCashReward.ToCurrencyNumber(), string.Empty, string.Empty);
            companyCashMaxBalanceText.text = MaxBalanceFormattedString(specialOfferService.MaxBalanceBonus);
            UpdateAvailable();
            Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(_ => {
                UpdateAvailable();
                UpdateParticles();
            }).AddTo(gameObject);



            buyButton.SetListener(() => {
                buyButton.SetInteractableWithShader(false);
                specialOfferService.BuyOffer();
            });

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

            var    planetNameData = ResourceService.PlanetNameRepository.GetPlanetNameData(Planets.CurrentPlanetId.Id);
            string planetName     = LocalizationObj.GetString(planetNameData.name);

            welcomText.text = string.Format(LocalizationObj.GetString("fmt_welcome"), planetName);
            SetPlanetSkin();
            StartCoroutine(PlusAnimatorsImpl());

            GameEvents.StoreProductPurchasedObservable.Subscribe(prod => {
                if (prod.Id == SpecialOfferService.kOfferProductId)
                {
                    closeButton.interactable = false;
                    //start emitting
                    EmitEffect(playerCashEffect, 5, playerCashEffectPoints[0], playerCashEffectPoints[1], "playercash", 0);
                    EmitEffect(companyCashEffect, 5, companyCashEffectPoints[0], companyCashEffectPoints[1], "companycash", 1);
                    EmitEffect(coinsEffect, 5, coinsEffectPoints[0], coinsEffectPoints[1], "coins", 2);
                }
            }).AddTo(gameObject);
            UpdateParticles();

            try {
                //IAPManager iapManager = FindObjectOfType<IAPManager>();
                Services.Inap.GetProductByResourceId(SpecialOfferService.kOfferProductId).Match(() => {
                    priceText.text = string.Empty;
                    return(F.None);
                }, (prod) => {
                    priceText.text = prod.metadata.localizedPriceString;
                    return(F.Some(prod));
                });
            } catch (Exception exception) {
                Debug.Log(exception.Message);
                Debug.Log(exception.StackTrace);
            }
        }
Esempio n. 17
0
 private void UpdateCompanyCash()
 {
     companyCashText1.text = companyCashText2.text = BosUtils.GetCurrencyString(Services.PlayerService.CompanyCash);
 }
Esempio n. 18
0
 private void UpdatePlayerCash()
 {
     playerCash1Text.text     =
         playerCash2Text.text =
             BosUtils.GetCurrencyString(Services.PlayerService.PlayerCash);
 }