Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void Setup(int managerId)
        {
            IMechanicService        mechanicService = Services.GetService <IMechanicService>();
            ILocalizationRepository localization    = Services.ResourceService.Localization;

            manager = Services.GetService <IManagerService>().GetManager(managerId);
            tempMechanicView.Setup(Services.GenerationService.GetGetenerator(managerId));
            UpdateBrokenedAndIncomeTexts();

            buyMechanicButton.SetListener(() => {
                BosError error = BosError.Ok;
                if (mechanicService.IsAllowBuyMechanic(manager.Id, out error))
                {
                    BosError status = mechanicService.BuyMechanic(manager.Id);
                    if (status == BosError.Ok)
                    {
                        Services.GetService <ISoundService>().PlayOneShot(SoundName.buyCoins);
                    }
                    else
                    {
                        Services.GetService <ISoundService>().PlayOneShot(SoundName.slotFail);
                    }
                }
                else if (error == BosError.NoEnoughCoins)
                {
                    ViewService.Show(ViewType.CoinRequiredView, new ViewData {
                        UserData  = mechanicService.GetNextMechanicPrice(manager.Id),
                        ViewDepth = ViewService.NextViewDepth
                    });
                    Sounds.PlayOneShot(SoundName.click);
                }
                else
                {
                    Debug.LogError("some error");
                }
            });
            UpdateBuyButtonState();
            UpdateMechanicPriceText();
            UpdateMechanicCountText();


            speedUpRepairx2Text.text = string.Format(
                localization.GetString("fmt_speed_up_x2"),
                "x".Colored("#FDEE21").Size(24),
                "2".Colored("#F9F7BC").Size(36));

            CreateConstMechanicAnimObject();
        }
Ejemplo n.º 3
0
        public void Setup(int managerId)
        {
            ISecretaryService       secretaryService = Services.GetService <ISecretaryService>();
            ILocalizationRepository localization     = Services.ResourceService.Localization;

            this.manager = Services.GetService <IManagerService>().GetManager(managerId);
            auditorView.Setup(Services.GenerationService.GetGetenerator(managerId));
            UpdateReportsCountText(managerId);
            UpdateManagerEfficiency();
            UpdateSecretaryCountText();

            buySecretaryButton.SetListener(() => {
                BosError error = BosError.Ok;

                if (Services.SecretaryService.IsAllowBuySecretary(manager.Id, out error))
                {
                    BosError status = secretaryService.BuySecretary(manager.Id);
                    if (status == BosError.Ok)
                    {
                        Services.GetService <ISoundService>().PlayOneShot(SoundName.buyGenerator);
                    }
                    else
                    {
                        Services.GetService <ISoundService>().PlayOneShot(SoundName.slotFail);
                    }
                }
                else
                {
                    if (error == BosError.NoEnoughCoins)
                    {
                        Services.ViewService.Show(ViewType.CoinRequiredView, new ViewData {
                            UserData  = Services.SecretaryService.GetNextSecretaryPrice(manager.Id),
                            ViewDepth = ViewService.NextViewDepth,
                        });
                        Sounds.PlayOneShot(SoundName.click);
                    }
                }
            });
            UpdateBuyButtonState();
            UpdateSecretaryPriceText();
            CreateConstSecretaryAnimObject();

            if (!isInitialized)
            {
                isInitialized = true;
            }
        }
Ejemplo n.º 4
0
        public bool IsAllowBuySecretary(int managerId, out BosError error)
        {
            bool isManagerHired = Services.ManagerService.IsHired(managerId);

            if (!isManagerHired)
            {
                error = BosError.ManagerNotHired;
                return(false);
            }

            int planetId = Services.PlanetService.CurrentPlanet.Id;

            Bos.Data.Currency price = Bos.Data.Currency.CreateCoins(GetNextSecretaryPrice(managerId));
            bool isEnoughCurrency   = Services.PlayerService.IsEnough(price);

            if (!isEnoughCurrency)
            {
                error = BosError.NoEnoughCoins;
                return(false);
            }
            error = BosError.Ok;
            return(isManagerHired && isEnoughCurrency);
        }
Ejemplo n.º 5
0
        public bool IsAllowBuyMechanic(int generatorId, out BosError error)
        {
            bool isManagerHired = Services.ManagerService.IsHired(generatorId);
            int  planetId       = Services.PlanetService.CurrentPlanet.Id;

            if (!isManagerHired)
            {
                error = BosError.ManagerNotHired;
                return(false);
            }

            int      price            = GetNextMechanicPrice(generatorId);
            Currency currencyPrice    = Currency.CreateCoins(price);
            bool     isEnoughCurrency = Services.PlayerService.IsEnough(currencyPrice);

            if (!isEnoughCurrency)
            {
                error = BosError.NoEnoughCoins;
                return(false);
            }

            error = BosError.Ok;
            return(isManagerHired && isEnoughCurrency);
        }