예제 #1
0
 private void BuyTimeUpgradeVM(UpgradeData vm, bool free, int id, bool isInvestor)
 {
     if (id == -1)
     {
         GenerationService.Generators.AddTimeBoost(BoostInfo.CreateTemp(id: $"time_upgrade_{vm.Id}_".GuidSuffix(5), value: vm.Value));
     }
     else
     {
         GenerationService.Generators.AddTimeBoost(
             generatorId: id,
             boost: BoostInfo.CreateTemp(
                 id: $"time_upgrade_{vm.Id}_".GuidSuffix(5),
                 value: vm.Value));
     }
     if (!free)
     {
         if (isInvestor)
         {
         }
         else
         {
             Player.RemoveCompanyCash(vm.Price(() => {
                 return(BosUtils.GetUpgradePriceMult(ResourceService.Planets.GetPlanet(Planets.CurrentPlanet.Id), vm));
             }));
         }
     }
 }
예제 #2
0
        public override void LoadSave(object obj)
        {
            UpgradeServiceSave save = obj as UpgradeServiceSave;

            if (save != null)
            {
                save.CheckNotNullFields();

                boughtCashUpgrades.Clear();
                boughtSecuritiesUpgrades.Clear();
                boughtCoinsUpgrades.Clear();
                upgradedGeneratorsIds.Clear();

                boughtCashUpgrades.AddRange(save.boughtCashUpgrades);
                boughtSecuritiesUpgrades.AddRange(save.boughtSecuritiesUpgrades);
                boughtCoinsUpgrades.AddRange(save.boughtCoinsUpgrades);
                upgradedGeneratorsIds.AddRange(save.upgradedGeneratorIds);
                IsQuickBuyResearched             = save.isQuickBuyResearched;
                UpgradeCoinsScreenOpenedLastTime = save.upgradeCoinsScreenOpenedLastTime;

                BosUtils.CopyDictionary(save.profitUpgradeLevels, ProfitUpgradeLevels);
                BosUtils.CopyDictionary(save.speedUpgradeLevels, SpeedUpgradeLevels);

                IsLoaded = true;
            }
            else
            {
                LoadDefaults();
            }
        }
예제 #3
0
        public bool IsAllowBuy(UpgradeData data)
        {
            if (data.CurrencyType == CurrencyType.CompanyCash && IsBoughtCashUpgrade(data.Id))
            {
                return(false);
            }
            if (data.CurrencyType == CurrencyType.Securities && IsBoughtSecurityUpgrade(data.Id))
            {
                return(false);
            }
            Currency priceCurrency = Currency.Create(data.CurrencyType, data.Price(() => {
                return(BosUtils.GetUpgradePriceMult(Planets.CurrentPlanet.Data, data));
            }));

            if (data.GeneratorId >= 0)
            {
                if (Services.PlayerService.IsEnough(priceCurrency) &&
                    Services.TransportService.HasUnits(data.GeneratorId))
                {
                    return(true);
                }
            }
            else
            {
                return(Services.PlayerService.IsEnough(priceCurrency));
            }
            return(false);
        }
예제 #4
0
        private IEnumerator SendRequest(string url, string authorization)
        {
            var www = UnityWebRequest.Get(url);

            www.SetRequestHeader(kAuth, authorization);
            var op = www.SendWebRequest();

            yield return(op);

            if (op.isDone)
            {
                var token = op.webRequest.downloadHandler.text;
                try {
                    var jsonPayload = JWT.JsonWebToken.Decode(token, kSecretKey);
                    //print($"TIME JSON => {jsonPayload}".Colored(ConsoleTextColor.green));
                    var date = GetDateTimeFromJson(jsonPayload);
                    unixTime       = BosUtils.GetUnixTimeFor(date);
                    deltaServer    = 0;
                    IsValid        = true;
                    isTimerUpdated = true;
                    timerFail.SetSuccess();
                } catch (Exception e) {
                    UnityEngine.Debug.Log(e.Message);
                    timerFail.SetFail();
                }
            }
        }
예제 #5
0
        public override void OnEvent(IBosServiceCollection context, TutorialEventData data)
        {
            Func <bool> isValid = () => IsActive && isDialogShowed && data.EventName == TutorialEventName.ViewOpened;

            BosUtils.If(isValid,
                        trueAction: () => {
                if ((ViewType)data.UserData == ViewType.PlanetsView)
                {
                    RemoveFinger(context, "planets");
                    ForceTutorialDialog(context, new TutorialDialogData {
                        Texts = GetLocalizationStrings(context, "lbl_tut_37"),
                        OnOk  = () => {
                            Finger(context, "moon", 10);
                        }
                    });
                }
            },
                        falseAction: () => {
            });

            BosUtils.If(() => IsActive && isDialogShowed && data.EventName == TutorialEventName.OpenPlanetClicked,
                        trueAction: () => {
                if ((int)data.UserData == 1)
                {
                    RemoveFinger(context, "moon");
                    CompleteSelf(context);
                }
            },
                        falseAction: () => { });
        }
예제 #6
0
        private void BuyFreeGenerators(UpgradeData vm, int id)
        {
            ITransportUnitsService transportService = GameServices.Instance.TransportService;

            if (transportService.HasUnits(id))
            {
                transportService.AddLiveUnits(id, (int)vm.Value);
                GlobalRefs.LevelManager.AddXP(XPSources.BuyUpgrade);
            }
            else
            {
                transportService.AddLiveUnits(id, (int)vm.Value);
                GlobalRefs.LevelManager.AddXP(XPSources.BuyGenerator * 10);
            }


            //PlayerData.Investors -= vm.Price;
            GameServices.Instance.PlayerService.RemoveSecurities(vm.Price(() => {
                return(BosUtils.GetUpgradePriceMult(ResourceService.Planets.GetPlanet(Planets.CurrentPlanet.Id), vm));
            }));
            GlobalRefs.LevelManager.AddXP(XPSources.BuyUpgrade);
        }
예제 #7
0
 public static bool IsWhole(this float num)
 => BosUtils.IsWholeNumber(num);
예제 #8
0
 public static uint ToJenkins(this string str)
 {
     return(BosUtils.JenkinsOneAtATimeHash(str));
 }
예제 #9
0
 public override string ToString()
 {
     return($"SUCCESS: {IsSuccess}, LOOSE VAL: {BosUtils.GetCurrencyString(LooseValue.ToCurrencyNumber())}, REMAIN VAL: {BosUtils.GetCurrencyString(RemainValue.ToCurrencyNumber())}");
 }
예제 #10
0
 public override string ToString()
 {
     return($"TAX: {(int)(100 * TaxPercent)}%, TAX VAL: {BosUtils.GetCurrencyString(TaxValue.ToCurrencyNumber())}, REMAIN VAL: {BosUtils.GetCurrencyString(RemainValue.ToCurrencyNumber())}");
 }