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)); })); } } }
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(); } }
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); }
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(); } } }
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: () => { }); }
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); }
public static bool IsWhole(this float num) => BosUtils.IsWholeNumber(num);
public static uint ToJenkins(this string str) { return(BosUtils.JenkinsOneAtATimeHash(str)); }
public override string ToString() { return($"SUCCESS: {IsSuccess}, LOOSE VAL: {BosUtils.GetCurrencyString(LooseValue.ToCurrencyNumber())}, REMAIN VAL: {BosUtils.GetCurrencyString(RemainValue.ToCurrencyNumber())}"); }
public override string ToString() { return($"TAX: {(int)(100 * TaxPercent)}%, TAX VAL: {BosUtils.GetCurrencyString(TaxValue.ToCurrencyNumber())}, REMAIN VAL: {BosUtils.GetCurrencyString(RemainValue.ToCurrencyNumber())}"); }