Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
    public override void Update()
    {
        if (manager != null)
        {
            if (_frameTime < 1)
            {
                _frameTime += Time.deltaTime;
                return;
            }
            _frameTime = 0;
            _now       = _now.AddSeconds(1);

            var isCanClaim = manager.NextKickBackTime < Services.TimeService.Now;

            var isHire = Services.ManagerService.IsHired(manager.Id);

            KickBackButton.gameObject.SetActive(isCanClaim && isHire);
            KickBackButtonAd.gameObject.SetActive(!isCanClaim && isHire);

            KickBackButton.interactable   = manager.CashOnHand > 0;
            KickBackButtonAd.interactable = manager.CashOnHand > 0;

            HireManager.gameObject.SetActive(!isHire);
            HireManager.interactable = Services.PlayerService.CompanyCash.Value >= manager.Cost;
            CostText.text            = Services.PlayerService.CompanyCash.Value >= manager.Cost
                ? "HIRE NOW"
                : BosUtils.GetCurrencyStringSimple(new CurrencyNumber(manager.Cost));

            Back.color = isHire ? Color.white : new Color(1, 1, 1, 0.5f);

            var diff = isCanClaim ? TimeSpan.Zero : manager.NextKickBackTime - _now;
            NextKickBackTime.SetActive(diff.TotalSeconds > 0 && isHire);
            RemainingTime.text = diff.TotalSeconds < 0 ? "00:00:00" : $"{diff.Hours:D2}:{diff.Minutes:D2}:{diff.Seconds:D2}";

            UpdateTexts();
        }
    }