Beispiel #1
0
        public void Setup(GeneratorInfo generator)
        {
            this.generator    = generator;
            this.mechanicData = Services.ResourceService.MechanicDataRepository.GetMechanicData(Services.PlanetService.CurrentPlanet.Id);
            UpdateViews();
            buyButton.SetListener(() => {
                BosError error = Services.TempMechanicService.Buy(generator);
                Debug.Log($"Purhase temp mechanic result =>{error}");
                if (error == BosError.Ok)
                {
                    Services.SoundService.PlayOneShot(SoundName.buyGenerator);
                }
            });
            adButton.SetListener(() => {
                Services.AdService.WatchAd("SpeedUpMechanic", () => {
                    //Services.TempMechanicService.ApplyAd(generator.GeneratorId);
                    Services.MechanicService.ForceRepair(generator.GeneratorId, CountToAdRepair());
                });
            });
            adTimer.Setup(.5f, dt => UpdateAdButton(), invokeImmediatly: true);
            buyButtonStateTimer.Setup(0.167f, dt => UpdateBuyButtonState());

            //adButtonText.text = string.Format(
            //    Services.ResourceService.Localization.GetString("btn_fmt_speed_up_x_2"),
            //    "x".Colored("#FDEE21").Size(45),
            //    "2".Colored("white").Size(54));

            SetupTempMechanicsView();
            updateTimer.Setup(1, dt => AddMissedMechanics());
            SetBuyButtonSprite(true);
        }
    public override void Start()
    {
        PlayGame.SetListener(PlayNormalF);

        WatchAd.SetListener(GetFreeSpins);
        buyTryButton.SetListener(BuyTries);

        buyCoinsButton.SetListener(() => {
            Services.SoundService.PlayOneShot(SoundName.buyGenerator);
            Services.ViewService.Show(ViewType.UpgradesView, new ViewData {
                UserData = new UpgradeViewData {
                    TabName = UpgradeTabName.Shop, StoreSection = StoreItemSection.Coins
                }
            });
        });

        upgradeButton.SetListener(() =>
        {
            var isMax = Services.SplitService.IsMaxLevel();
            if (!isMax)
            {
                var nextLevel       = Services.SplitService.GetLevel() + 1;
                var nextUpgradeData = ResourceService.RocketUpgradeRepository.GetUpgrade(nextLevel);
                if (Services.PlayerService.IsEnoughCoins(nextUpgradeData.cost))
                {
                    Services.SoundService.PlayOneShot(SoundName.buyGenerator);
                    Services.SplitService.UpgradeLevel();
                }
                else
                {
                    Services.ViewService.Show(ViewType.CoinRequiredView, new ViewData {
                        UserData = nextUpgradeData.cost
                    });
                }
            }
        });

        UpdateControls();

        updateTimer.Setup(1, (dt) => {
            var splitService = Services.SplitService;
            var isNoTries    = !splitService.HasTries;

            if (splitService.NextTriesUpdateTime > Services.TimeService.UnixTimeInt)
            {
                var tDisplay =
                    System.TimeSpan.FromSeconds(splitService.NextTriesUpdateTime - Services.TimeService.UnixTimeInt);
                var answer       = $"{tDisplay.Minutes:D2}:{tDisplay.Seconds:D2}";
                TimeDisplay.text = answer;
            }
            else
            {
                if (isNoTries)
                {
                    Services.SplitService.SetTries(Services.SplitService.MaxTries);
                    TimeDisplay.text = "00:00";
                }
            }
        }, true);
    }
Beispiel #3
0
 public void Setup(GeneratorInfo gen)
 {
     this.generator = gen;
     UpdateCountText();
     UpdatePriceTexts();
     UpdateBuyButtonState();
     buyButton.SetListener(() => {
         var error = Services.AuditorService.Buy(generator);
         Debug.Log($"purchase auditor result => {error}");
         if (error == BosError.Ok)
         {
             Services.SoundService.PlayOneShot(SoundName.buyGenerator);
         }
     });
     buyButtonTimer.Setup(0.167f, dt => {
         UpdateBuyButtonState();
     });
     adButton.SetListener(() => {
         Services.AdService.WatchAd("SpeedUpSecretary", () => {
             //Services.AuditorService.ApplyAd(generator.GeneratorId);
             Services.SecretaryService.ForceHandle(generator.GeneratorId, CountToHandleWithAd());
         });
     });
     adTimer.Setup(0.5f, dt => UpdateAdButton(), invokeImmediatly: true);
     SetupAuditorViews();
     missedTimer.Setup(1, dt => AddMissedAuditors());
     SetBuyButtonSprite(true);
 }
Beispiel #4
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);
        }
Beispiel #5
0
    public override void Start()
    {
        base.Start();
        var x2Service = Services.X2ProfitService;

        updateTimer.Setup(.5f, dt => {
            int adsRemaining       = x2Service.FreeSlotsCount;
            RemainingAdsLabel.text = adsRemaining.ToString();
            int interval           = x2Service.AvailableAfterInterval; //x2Service.ResetTime - TimeService.UnixTimeInt;
            if (interval < 0)
            {
                interval = 0;
            }
            UpdateWatchButtonState(adsRemaining);
            if (interval == 0)
            {
                RemainingTime.text = "00:00:00";
            }
            else
            {
                TimeSpan ts        = TimeSpan.FromSeconds(interval);
                RemainingTime.text = $"{ts.Hours:D2}:{ts.Minutes:D2}:{ts.Seconds:D2}";
            }
            boostAllprofits.text = "AD.BOOST.DESC".GetLocalizedString();
        }, true);
        WatchAddButon.SetListener(() => {
            Services.AdService.WatchX2Ad();
        });
        int ads = x2Service.FreeSlotsCount;

        UpdateWatchButtonState(ads);
        UpdateInteractability(WatchAddButon.interactable);
    }
Beispiel #6
0
        public override void Setup(ViewData data)
        {
            base.Setup(data);

            enhancedManagerData = data.UserData as EnhanceManagerData;
            normalGeneratorIconImage.overrideSprite   = enhancedManagerData.normalGeneratorSprite;
            upgradedGeneratorIconImage.overrideSprite = enhancedManagerData.enhancedGeneratorSprite;
            managerIconImage.overrideSprite           = enhancedManagerData.managerSprite;
            upgradedManagerIconImage.overrideSprite   = enhancedManagerData.managerSprite;
            normalGeneratorNameText.text       =
                upgradedGeneratorNameText.text = enhancedManagerData.generatorName;
            enhancePriceText.text = enhancedManagerData.generator.Data.EnhancePrice.ToString();
            timer.Setup(0.3f, dt => UpdateButtonInteractability(), true);
            UnityAction simpleClose = () => {
                Services.ViewService.Remove(ViewType.EnahnceManagerView);
                Services.SoundService.PlayOneShot(SoundName.click);
            };
            UnityAction closeAction = () => {
                simpleClose();
                Analytics.CustomEvent($"ENHANCE_WINDOW_{enhancedManagerData.generator.GeneratorId}_CLOSE");
            };

            closeButton.SetListener(closeAction);
            closeBigButton.SetListener(closeAction);

            var soundService = Services.SoundService;

            enhanceButton.SetListener(() => {
                soundService.PlayOneShot(SoundName.buyUpgrade);
                Services.ManagerService.Enhance(enhancedManagerData.generator);
                simpleClose();
            });

            Analytics.CustomEvent($"ENHANCE_WINDOW_{enhancedManagerData.generator.GeneratorId}_OPEN");
        }
Beispiel #7
0
        public void Setup()
        {
            messageList.Setup();
            wishlistView.Setup();
            var chatService = engine.GetService <IChatService>();

            sendButton.SetListener(() => {
                if (messageInput.text.IsValid() && chatService.IsCanChat)
                {
                    chatService.SendMessage(
                        engine.GetService <INetService>().LocalPlayer,
                        messageInput.text,
                        new List <IAttachment>(),
                        MessageType.Normal
                        );
                }
            }, engine.GetService <IAudioService>());

            inputUpdater.Setup(1, (delay) => {
                if (chatService.IsCanChat)
                {
                    messageInput.interactable = true;
                    sendButton.interactable   = true;
                }
                else
                {
                    messageInput.interactable = false;
                    sendButton.interactable   = false;
                }
            });
        }
Beispiel #8
0
 public override void Awake()
 {
     _now = Services.TimeService.Now;
     updateTimer.Setup(1, (deltaTime) => {
         _now = _now.AddSeconds(1);
         UpdateView();
     }, invokeImmediatly: true);
 }
 public override void OnEnable()
 {
     base.OnEnable();
     rectTransform = GetComponent <RectTransform>();
     updateTimer.Setup(0.3f, dt => {
         rectTransform.SetAsLastSibling();
     }, true);
 }
Beispiel #10
0
 public override void Setup(object objdata = null)
 {
     base.Setup(objdata);
     roomMode = objdata as IRoomMode;
     UpdateProgress();
     UpdateText();
     updateTimer.Setup(1, (delay) => {
         UpdateText();
         UpdateProgressValue();
     });
 }
Beispiel #11
0
 public override void Start()
 {
     base.Start();
     Setup();
     UpdateState();
     updateTimer.Setup(0.5f, (realDelta) => {
         UpdateState();
     });
     Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(args => {
         UpdateHelpFinger();
     }).AddTo(gameObject);
 }
Beispiel #12
0
        public void Setup()
        {
            IBankService            bankService  = Services.GetService <IBankService>();
            ILocalizationRepository localization = Services.ResourceService.Localization;

            updateControlsTimer.Setup(1.0f, (deltaTime) => UpdateViews(), invokeImmediatly: true);
            takeButton.SetListener(() => {
                //takeButton.interactable = false;
                //takeButton.SetInteractable
                //takeButton.image.material.SetFloat("_Enabled", 1);
                takeButton.SetInteractableWithShader(false);
                Services.RunCoroutine(AccumulateImpl(bankService.CoinsAccumulatedCount));
            });

            UpdateNextLevelControls();
        }
Beispiel #13
0
        public void Setup(object data)
        {
            officialTaxPercentText.text = $"TAX: {(int)(100 * Services.ResourceService.PersonalImprovements.ConvertData.OfficialConvertPercent)}%";
            looseChanceText.text        = $"LOOSE CHANCE: {(int)(100 * Services.ResourceService.PersonalImprovements.ConvertData.UnofficialConvertPercent)}%";

            UpdateCompanyCash();
            UpdatePlayerCash();

            officialTransferButton.SetListener(() => {
                var result = Services.PlayerService.StartTransferCashOfficially();
                Debug.Log(result.ToString());
                Services.GetService <ISoundService>().PlayOneShot(SoundName.buyGenerator);
                Services.ViewService.Show(ViewType.LoadingView, new ViewData()
                {
                    UserData = new LoadSceneData()
                    {
                        BuildIndex = 7,
                        Mode       = LoadSceneMode.Additive,
                        LoadAction = () => { FindObjectOfType <TransferGameController>()?.Setup(result); }
                    }
                });
            });

            unofficialTransferButton.SetListener(() => {
                var result = Services.PlayerService.TransferIlegally(null);
                Debug.Log(result.ToString());
                if (result.IsSuccess)
                {
                    Services.GetService <ISoundService>().PlayOneShot(SoundName.buyGenerator);
                }
                else
                {
                    Services.GetService <ISoundService>().PlayOneShot(SoundName.click);
                }
            });

            updateTimer.Setup(0.25f, (deltaTime) => {
                officialTransferButton.interactable       =
                    unofficialTransferButton.interactable = (Services.PlayerService.CompanyCash.Value > 0.0);
            }, invokeImmediatly: true);

            closeButton.SetListener(() => {
                //Services.ViewService.Remove(ViewType.CashConvertView, BosUISettings.Instance.ViewCloseDelay);
                closeButton.interactable = false;
                Services.GetService <ISoundService>().PlayOneShot(SoundName.click);
            });
        }
Beispiel #14
0
        private void Setup()
        {
            UpdateCompanyCash();
            UpdatePlayerCash();

            officialTransferButton.SetListener(() => {
                var result = Services.PlayerService.StartTransferCashOfficially();
                Debug.Log(result.ToString());
                Services.GetService <ISoundService>().PlayOneShot(SoundName.buyGenerator);

                /*
                 * Services.ViewService.Show(ViewType.LoadingView, new ViewData() {
                 *  UserData = new LoadSceneData() {
                 *      BuildIndex = 7,
                 *      Mode = LoadSceneMode.Additive,
                 *      LoadAction = () => { FindObjectOfType<TransferGameController>()?.Setup(result); }
                 *  }
                 * });*/
            });

            nonOfficialTransferButton.SetListener(() => {
                var result = IllegalTransfer(); //Services.PlayerService.TransferIlegally(null);
                Debug.Log(result.ToString());
                if (result.IsSuccess)
                {
                    Services.GetService <ISoundService>().PlayOneShot(SoundName.buyGenerator);
                }
                else
                {
                    Services.GetService <ISoundService>().PlayOneShot(SoundName.click);
                }
            });

            updateTimer.Setup(0.25f, (deltaTime) => {
                bool isEnabled = (Services.PlayerService.CompanyCash.Value > 0);
                if (isEnabled && !officialTransferButton.interactable)
                {
                    UpdateButtons();
                }
                else if (!isEnabled && officialTransferButton.interactable)
                {
                    UpdateButtons();
                }
            }, true);
            UpdateButtons();
            GameEvents.OnTutorialEvent(new TutorialEventData(TutorialEventName.TransferTabOpened));
        }
Beispiel #15
0
        public override void Setup(BuffInfo buff)
        {
            base.Setup(buff);

            this.buff = buff;
            this.name = buff.Id;

            iconImage.overrideSprite = resourceService.GetSprite(buff.Data);
            updateTimer.Setup(1.0f, (delay) => {
                UpdateTimer();
            });
            trigger.SetEventTriggerClick(p => {
                PointerEventData ped = p as PointerEventData;
                if (ped.pointerCurrentRaycast.isValid)
                {
                    if (ped.GetPointerObjectName() == this.name)
                    {
                        iconImage.gameObject.GetOrAdd <RectTransformAnimScale>().StartAnim(new MCFloatAnimData {
                            start           = 1,
                            end             = 1.1f,
                            duration        = 0.15f,
                            overwriteEasing = new OverwriteEasing {
                                type = MCEaseType.EaseInOutCubic
                            },
                            endAction = () => {
                                iconImage.gameObject.GetOrAdd <RectTransformAnimScale>().StartAnim(new MCFloatAnimData {
                                    start           = 1.1f,
                                    end             = 1,
                                    duration        = 0.15f,
                                    overwriteEasing = new OverwriteEasing {
                                        type = MCEaseType.EaseInOutCubic
                                    },
                                    endAction = () => {
                                        viewService.ShowView(RavenhillViewType.hint_view, new HintView.ItemData {
                                            data           = buff.Data,
                                            offsetType     = HintView.OffsetType.Left,
                                            screenPosition = engine.Input.lastPointerPosition
                                        });
                                    }
                                });
                            }
                        });
                    }
                }
            }, engine.GetService <IAudioService>());
        }
Beispiel #16
0
 public void Setup(object data)
 {
     reconnectTimer.Setup(10, (delay) => {
         GameModeName gameModeName = ravenhillGameModeService?.gameModeName ?? GameModeName.loading;
         if (gameModeName == GameModeName.map || gameModeName == GameModeName.hallway)
         {
             if (Client != null && Client.IsDisconnected && IsNetworkReachable)
             {
                 Client.Connect(engine.GetService <INetService>().LocalPlayer.id);
             }
             Debug.Log($"Client not null: {Client != null}");
             if (Client != null)
             {
                 Debug.Log($"Is Disconnected: {Client.IsDisconnected}");
                 Debug.Log($"Is Network Reachanble: {IsNetworkReachable}");
             }
         }
     });
 }
Beispiel #17
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);
        }
Beispiel #18
0
        public override void OnEnable()
        {
            base.OnEnable();
            GameEvents.AvailableRewardsChanged += OnAvailableRewardsChanged;
            GameEvents.CoinsChanged            += OnCoinsChanged;

            investorButton.SetListener(() => {
                Services.ViewService.ShowDelayed(ViewType.InvestorsView, BosUISettings.Instance.ViewShowDelay);
                Services.SoundService.PlayOneShot(SoundName.click);
            });

            upgradeButton.SetListener(() => {
                //Services.LegacyGameUI.ShowUpgrades();
                //Services.SoundService.PlayOneShot(SoundName.click);
            });

            leaderboardButton.SetListener(() => {
                Services.LegacyGameManager.GetComponent <UnityLeaderboardMediator>().ShowLeaderboardUI_Score();
                Services.SoundService.PlayOneShot(SoundName.click);
            });

            managersButton.SetListener(() => {
                //Services.LegacyGameUI.ShowManagers(0);
                //Services.SoundService.PlayOneShot(SoundName.click);
            });

            shopButton.SetListener(() => {
                //Services.LegacyGameUI.ShowIAP();
                //Services.ViewService.ShowDelayed(ViewType.StoreView, BosUISettings.Instance.ViewShowDelay);
                Services.SoundService.PlayOneShot(SoundName.click);
            });

            upgradeTimer.Setup(1, (dt) => Services.ViewService.Utils.UpdateUpgradeAlert(upgradeAlertObject), true);
            managerTimer.Setup(1, dt => Services.ViewService.Utils.UpdateManagerAlert(managerAlertObject), true);
            investorTimer.Setup(1, dt => Services.ViewService.Utils.UpdateInvestorAlert(investorAlertObject), true);

            //force update
            OnAvailableRewardsChanged(0, 0);
            OnCoinsChanged(0, 0);
        }
Beispiel #19
0
        public void Setup(ChargerData data, CollectionData collectionData)
        {
            this.data           = data;
            this.collectionData = collectionData;

            nameText.text            = resourceService.GetName(data);
            iconImage.overrideSprite = resourceService.GetSprite(data);

            int requiredCount = collectionData.GetChargerCount(data.id);
            int playerCount   = playerService.GetItemCount(data);

            if (playerCount >= requiredCount)
            {
                buyButton.DeactivateSelf();
                availableLabel.ActivateSelf();
            }
            else
            {
                buyButton.ActivateSelf();
                availableLabel.DeactivateSelf();
                priceImage.overrideSprite = resourceService.GetPriceSprite(data.price);
                priceText.text            = data.price.price.ToString();

                buyButton.SetListener(() => {
                    playerService.Buy(data);
                }, engine.GetService <IAudioService>());
            }

            countText.text = $"You have {playerCount} from {requiredCount}";

            wishlistUpdateTimer.Setup(.5f, UpdateWishlistButton);
            wishlistButton.SetListener(() => {
                if (!playerService.IsWishlistContains(data) && !playerService.IsWishlistFull)
                {
                    playerService.AddToWishlist(data);
                    Resetup();
                }
            }, engine.GetService <IAudioService>());
        }
Beispiel #20
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
        }
Beispiel #21
0
        public void Setup(ManagerInfo manager)
        {
            this.manager = manager;


            GeneratorInfo generator = Services.GenerationService.GetGetenerator(manager.Id);

            updateTimer.Setup(1.0f, (delta) => {
                ProfitResult profitResult = generator.ConstructProfitResult(Services.GenerationService.Generators); //Services.GenerationService.CalculateProfitPerSecond(generator,Services.TransportService.GetUnitLiveCount(manager.Id));
                CurrencyNumber number     = profitResult.ValuePerSecond.ToCurrencyNumber();
                profitText.text           = FormatProfit(profitResult.ValuePerSecond.ToCurrencyNumber());
                UpdateEfficiencyText();
            }, invokeImmediatly: true);

            UpdateManagerIcon();
            UpdateMegaTextObject();
            UpdateRollbackChanged();

            if (!isInitialized)
            {
                isInitialized = true;
            }
        }
Beispiel #22
0
        public override void Setup(ViewData data)
        {
            base.Setup(data);
            Data = data.UserData as WaitAdData;

            updateTimer.Setup(.3f, dt => {
                if (!isAdLoaded)
                {
                    if (Appodeal.isLoaded(Appodeal.REWARDED_VIDEO))
                    {
                        isAdLoaded = true;
                        ViewService.Remove(ViewType.WaitAdView);
                        if (Data != null)
                        {
                            Services.AdService.WatchAd(Data.ContentType, Data.Action);
                        }
                    }
                }
            });
            closeButton.SetListener(() => {
                Sounds.PlayOneShot(SoundName.click);
                ViewService.Remove(ViewType.WaitAdView);
            });
        }
Beispiel #23
0
        public override void Setup(IconData objdata)
        {
            base.Setup(objdata);

            data = objdata as IngredientData;
            if (data == null)
            {
                throw new ArgumentException(typeof(IngredientData).Name);
            }

            int       playerCount   = playerService.GetItemCount(data);
            BonusData bonusData     = resourceService.GetBonus(data.bonusId);
            int       requiredCount = bonusData.GetIngredientCount(data.id);
            Color     color         = Color.black;

            if (playerCount < requiredCount)
            {
                color = Color.red;
            }
            countText.text  = $"{playerCount}/{requiredCount}";
            countText.color = color;

            if (playerCount < requiredCount)
            {
                iconImage.color = new Color(1, 1, 1, 0.5f);
            }
            else
            {
                iconImage.color = Color.white;
            }

            buyButton.SetListener(() => {
                PriceData price = data.price;
                if (playerService.HasCoins(price))
                {
                    playerService.RemoveCoins(price);
                    playerService.AddItem(new InventoryItem(data, 1));
                }
                else
                {
                    viewService.ShowView(RavenhillViewType.bank);
                }
            }, engine.GetService <IAudioService>());

            wishButtonTimer.Setup(0.5f, (delta) => {
                if (data != null)
                {
                    wishButton.interactable = (!playerService.IsWishlistFull && !playerService.IsWishlistContains(data));
                }
                else
                {
                    wishButton.interactable = false;
                }
            });


            wishButton.SetListener(() => {
                playerService.AddToWishlist(data);
                wishButton.interactable = false;
            }, engine.GetService <IAudioService>());
        }
Beispiel #24
0
        public override void Setup(object objdata = null)
        {
            base.Setup(objdata);

            if (source == null)
            {
                source = resourceService.bonusList;
            }
            if (objdata == null)
            {
                index = 0;
            }
            else
            {
                BonusData data = objdata as BonusData;
                if (data == null)
                {
                    throw new ArgumentException(typeof(BonusData).Name);
                }
                index = source.FindIndex(b => b.id == data.id);
                if (index < 0)
                {
                    index = 0;
                }
            }

            BonusData     bonusData     = source[index];
            List <string> ingredientIds = bonusData.ingredientList;

            wishlistView.Setup();
            for (int i = 0; i < ingredientIds.Count; i++)
            {
                IngredientData ingredientData = resourceService.GetIngredient(ingredientIds[i]);
                if (i < ingredientViews.Length)
                {
                    ingredientViews[i].Setup(ingredientData);
                }
            }

            bonusView.Setup(bonusData);

            nextButton.SetListener(() => {
                if (source != null)
                {
                    index++;
                    if (index >= source.Count)
                    {
                        index = 0;
                    }
                    BonusData nextData = source[index];
                    Setup(nextData);
                }
            }, engine.GetService <IAudioService>());

            prevButton.SetListener(() => {
                if (source != null)
                {
                    index--;
                    if (index < 0)
                    {
                        index = source.Count - 1;
                    }
                    BonusData prevData = source[index];
                    Setup(prevData);
                }
            }, engine.GetService <IAudioService>());


            combineButton.SetListener(() => {
                if (ravenhillGameModeService.IsAlchemyReadyToCharge(bonusData))
                {
                    ravenhillGameModeService.ChargeAlchemy(bonusData);
                }
            }, engine.GetService <IAudioService>());

            combineUpdateTimer.Setup(0.5f, (delta) => {
                if (bonusData != null)
                {
                    combineButton.interactable = ravenhillGameModeService.IsAlchemyReadyToCharge(bonusData);
                }
            });
        }
Beispiel #25
0
        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);
        }
Beispiel #26
0
        public override void Setup(ViewData data)
        {
            base.Setup(data);
            bankButton.SetListener(() => {
                Services.SoundService.PlayOneShot(SoundName.click);
                Services.ViewService.ShowDelayed(ViewType.BankView, BosUISettings.Instance.ViewShowDelay);
            });
            miniGamesButton.SetListener(() => {
                Services.SoundService.PlayOneShot(SoundName.click);
                Services.ViewService.Show(ViewType.MiniGameView);
            });
            empireButton.SetListener(() => {
                Services.SoundService.PlayOneShot(SoundName.click);
                Services.ViewService.Show(ViewType.MainView);
                //FindObjectOfType<GameUI>()?.ToggleMenu();
            });
            shopButton.SetListener(() => {
                //Services.ViewService.ShowDelayed(ViewType.StoreView, BosUISettings.Instance.ViewShowDelay);
                Services.ViewService.Show(ViewType.UpgradesView, new ViewData {
                    UserData = new UpgradeViewData {
                        TabName = UpgradeTabName.Shop, StoreSection = StoreItemSection.CompanyCash
                    }
                });
                Services.SoundService.PlayOneShot(SoundName.click);
                //FindObjectOfType<GameUI>()?.ShowIAP();
            });

            UpdateBankButtonView();
            UpdatePrizeWheelAlertObject();
            UpdateTreasureHuntAlertObject();
            UpdateSplitAlertObject();
            UpdateUpgradeAlertObject();
            UpdateManagerAlert();
            UpdateAvailableRewardAlertObject();
            UpdateInvestorAlertObject();
            UpdateAlertShopObject();

            upgradeAlertTimer.Setup(3.0f, (dt) => UpdateUpgradeAlertObject(), true);
            managerAlertTimer.Setup(3.0f, dt => UpdateManagerAlert(), true);
            investorAlertTimer.Setup(3.0f, dt => UpdateInvestorAlertObject(), true);
            StartCoroutine(UnhideImpl());

            IViewService viewService = Services.ViewService;

            visibilityTimer.Setup(.5f, dt => {
                if (Services.GameModeService.GameModeName == GameModeName.Game)
                {
                    if (isHided)
                    {
                        if (viewService.LegacyCount == 0 && viewService.ModalCount == 0)
                        {
                            if (!isAnimating)
                            {
                                Unhide();
                            }
                        }
                    }
                    else
                    {
                        if (viewService.LegacyCount != 0 || viewService.ModalCount != 0)
                        {
                            if (!isAnimating)
                            {
                                Hide();
                            }
                        }
                    }
                }
            });

            if (!isInitialized)
            {
                Observable.Interval(TimeSpan.FromSeconds(2)).Subscribe(_ => {
                    UpdateSplitAlertObject();
                    UpdateBankAlert();
                }).AddTo(gameObject);

                isInitialized = true;
            }
        }
Beispiel #27
0
        public void Setup(int generatorId)
        {
            textPull.Setup(10, AccumulatedTextPrefab, transform);

            generator = Services.GenerationService.Generators.GetGeneratorInfo(generatorId);
            updateProfitTimer.Setup(0.3f, (delta) => {
                UpdateProfitValues();
            }, true);

            updateBuyGeneratorCountControls.Setup(0.5f, (deltaTime) => {
                if (generatorCountButton.State == GeneratorButtonState.MAX)
                {
                    UpdateBuyGeneratorControls(generatorCountButton.GetBuyInfo());
                }
            });

            generatorCountButton.Setup(generatorId);
            UpdateBuyGeneratorControls(generatorCountButton.GetBuyInfo());
            UpdateGeneratorLevelProgress();
            buyManagerButton.SetListener(() => {
                Services.ViewService.Show(ViewType.ManagementView, new ViewData()
                {
                    UserData = generator.GeneratorId
                });
                Services.GetService <ISoundService>().PlayOneShot(SoundName.click);
            });

            //disable buy manager button for planet transport
            if (generator.Data.Type == GeneratorType.Planet)
            {
                buyManagerButton.interactable = false;
                buyManagerButton.Deactivate();
            }

            updateBuyManagerTimer.Setup(1.0f, (delta) => {
                UpdateBuyManagerButton();
            }, true);

            Vector3Animator buyButtonAnimator = buyGeneratorButton.gameObject.GetOrAdd <Vector3Animator>();

            buyGeneratorButton.SetListener(() => {
                if (generator.IsGenerationStarted)
                {
                    generator.ForceFinalization();
                }
                if (Services.GenerationService.BuyGenerator(generator, generatorCountButton.GetBuyInfo().Count) > 0)
                {
                    UpdateGeneratorLevelProgress();
                    UpdateBuyGeneratorControls(generatorCountButton.GetBuyInfo());
                }
                buyGeneratorParticlesTrigger.TriggerAnimation();
                Services.GetService <ISoundService>().PlayOneShot(SoundName.buyGenerator);
                buyButtonAnimator.StartAnimation(BuyGeneratorButtonAnimationData);
            });

            generateButton.SetListener(() => {
                if (generator.IsManual)
                {
                    if (!generator.IsGenerationStarted)
                    {
                        generator.StartGeneration();
                        Services.GetService <ISoundService>().PlayOneShot(SoundName.click);
                        if (generator.IsEnhanced)
                        {
                            enhancedParticles.Activate();
                        }
                        GameEvents.OnTutorialEvent(new TutorialEventData(TutorialEventName.GenerationButtonClicked, generatorId));
                    }
                }
            });

            if (IsAlwaysProgressFull)
            {
                progressImage.fillAmount = 1;
                //isAccumulationStarted = true;
                generator.SetGenerationStarted(true);
            }
            else
            {
                progressImage.fillAmount = 0;
                if (generator.IsAutomatic)
                {
                    generator.SetGenerationStarted(true);
                    //isAccumulationStarted = true;
                }
            }

            UpdateUnitCountText();

            /*
             * if(generator.Data.Type == GeneratorType.Planet ) {
             *  PlanetNameData planetNameData =
             *      Services.ResourceService.PlanetNameRepository.GetPlanetNameData(
             *          generator.PlanetId);
             *  nameText.text = Services.ResourceService.Localization.GetString(
             *      planetNameData.name);
             * } else {
             *  nameText.text = Services.ResourceService.Localization.GetString(generator.Data.Name);
             * }*/
            //var generatorLocalData = Services.res

            Services.ViewService.Utils.ApplyGeneratorName(nameText, generator);

            UpdateGeneratorLevelProgress();

            UpdateEnhancementViews(generator);
            UpdateAutomaticParticles();

            var soundService = Services.SoundService;

            enhanceButton.SetListener(() => {
                if (generator.Data.Type == GeneratorType.Normal)
                {
                    StartEnhance();
                    soundService.PlayOneShot(SoundName.click);
                }
            });
            UpdateTimerText(generator.RemainTime);

            //make automatic planet transport and hire manager
            if (generator.IsManual && generator.Data.Type == GeneratorType.Planet)
            {
                Services.GetService <IManagerService>().Hire(generator.GeneratorId);
                Services.GetService <IGenerationService>().Generators.SetAutomatic(generator.GeneratorId, true);
            }

            UpdateGeneratorIcon();
            UpdateManagerIcon();
            UpdateMegaObject();

            automaticParticlesUpdater.Setup(2, (dt) => UpdateAutomaticParticles(), true);

            if (generator.Data.Type == GeneratorType.Normal)
            {
                UpdateReportObject(Services.SecretaryService.GetReportCount(generator.GeneratorId));
                UpdateToolObject(Services.TransportService.GetUnitBrokenedCount(generator.GeneratorId));
                if (reportButton != null)
                {
                    reportButton.OnClickAsObservable().Subscribe(_ => {
                        ShowManagementView();
                    }).AddTo(gameObject);
                }
                if (toolButton != null)
                {
                    toolButton.OnClickAsObservable().Subscribe(_ => {
                        ShowManagementView();
                    }).AddTo(gameObject);
                }
            }
        }
Beispiel #28
0
        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);
        }
Beispiel #29
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);
        }