Beispiel #1
0
 private void BuyTimeUpgrade(Upgrade up, bool free, int id)
 {
     if (Services.GenerationService.Generators.Contains(id))
     {
         int count = GetSpeedUpgradeLevel(id);
         //Services.GenerationService.Generators.ApplyTime(id, up.TimeMultiplier);
         Services.GenerationService.Generators.AddTimeBoost(
             generatorId: id,
             boost: BoostInfo.CreateTemp(
                 id: $"upgrade_time_{up.GeneratorIdToUpgrade}_".GuidSuffix(5),
                 value: up.TimeMultiplier));
         AddSpeedUpgradeLevel(id, 1);
         if (!free)
         {
             RemoveCost(Services, up.CostType, up.CalculateCost(count));
         }
     }
     else
     {
         //Services.GenerationService.Generators.ApplyTime(id, up.TimeMultiplier);
         Services.GenerationService.Generators.AddTimeBoost(
             generatorId: id,
             boost: BoostInfo.CreateTemp(
                 id: $"upgrade_time_{up.GeneratorIdToUpgrade}_".GuidSuffix(5),
                 value: up.TimeMultiplier));
         AddSpeedUpgradeLevel(id, 1);
         if (!free)
         {
             RemoveCost(Services, up.CostType, up.CalculateCost(0));
         }
     }
 }
Beispiel #2
0
 public void Enhance()
 {
     if (!IsEnhanced)
     {
         IsEnhanced = true;
         AddTimeBoost(BoostInfo.CreateTemp(kEnhanceBoostName, 10));
         GameEvents.OnGeneratorEnhanced(this);
     }
 }
 public void Load(BoostCollectionSave save)
 {
     save.Guard();
     Boosts.Clear();
     foreach (var kvp in save.boosts)
     {
         BoostInfo boost = new BoostInfo(kvp.Value);
         Add(boost);
     }
 }
Beispiel #4
0
 public void ApplyTimeDenominatorToAllGenerators(BoostInfo boost)
 {
     GeneratorInfo[] generatorInfoArray = Generators.Generators.Values.ToArray();
     for (int i = 0; i < generatorInfoArray.Length; i++)
     {
         Generators.AddTimeBoost(
             generatorId: generatorInfoArray[i].GeneratorId,
             boost: new BoostInfo(boost.Id, boost.Value, boost.IsPersist, 0, BoostSourceType.Unknown));
     }
 }
Beispiel #5
0
 public void Setup(object data = null)
 {
     Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(value => {
         if (IsLoaded && GameMode.GameModeName == GameModeName.Game && Services.GenerationService.IsLoaded)
         {
             Services.GenerationService.Generators.AddProfitBoost(BoostInfo.CreateTemp(
                                                                      "x2_profit_service",
                                                                      ProfitMult));
             //UnityEngine.Debug.Log($"update x2 profit service boost to: {ProfitMult}");
         }
     }).AddTo(gameObject);
 }
Beispiel #6
0
        public GeneratorInfo(int generatorId, BoostInfo profitBoost, BoostInfo timeBoost, GeneratorData data, GeneratorLocalData localData)
        {
            this.GeneratorId = generatorId;
            this.ProfitBoosts.Add(profitBoost);
            this.TimeBoosts.Add(timeBoost);

            this.IsEnhanced          = false;
            this.Data                = data;
            this.LocalData           = localData;
            this.GenerateTimer       = 0f;
            this.BuyCountButtonState = 1;
            this.IsResearched        = generatorId.IsRickshawOrTaxi();
        }
Beispiel #7
0
        private System.Collections.IEnumerator UpdateManagerProfitMult(ManagerInfo manager)
        {
            yield return(new WaitUntil(() => IsLoaded));

            if (manager.IsHired)
            {
                Generators.AddProfitBoost(
                    generatorId: manager.Id,
                    boost: BoostInfo.CreateTemp(manager.ManagerProfitMultId, manager.Efficiency(Services)));

                double boostValue = Generators.GetGeneratorInfo(manager.Id).GetProfitBoostValue(manager.ManagerProfitMultId);
                UDebug.Log($"Update generator {manager.Id} efficiency mult to => {boostValue}".Attrib(bold: true, italic: true, color: "y"));
            }
        }
Beispiel #8
0
 private void UpgradeTime(BosCoinUpgradeData data)
 {
     if (data.GeneratorId < 0)
     {
         if (data.IsPermanent)
         {
             //Generators.ApplyPermanent(GeneratorBonusMult.CreateTimeMult(data.TimeMultiplier));
             Generators.AddTimeBoost(
                 boost: BoostInfo.CreatePersist(
                     id: BoostIds.GetPersistCoinUpId(data.Id),
                     value: data.TimeMultiplier,
                     sourceType: (int)BoostSourceType.CoinUpgrade));
         }
         else
         {
             //Generators.ApplyGlobal(GeneratorBonusMult.CreateTimeMult(data.TimeMultiplier));
             Generators.AddTimeBoost(
                 boost: BoostInfo.CreateTemp(
                     id: BoostIds.GetTempCoinUpId(data.Id),
                     value: data.TimeMultiplier,
                     sourceType: (int)BoostSourceType.CoinUpgrade));
         }
     }
     else
     {
         if (data.IsPermanent)
         {
             //Generators.ApplyPermanent(data.GeneratorId, GeneratorBonusMult.CreateTimeMult(data.TimeMultiplier));
             Generators.AddTimeBoost(
                 generatorId: data.GeneratorId,
                 boost: BoostInfo.CreatePersist(
                     id: BoostIds.GetPersistCoinUpId(data.Id),
                     value: data.TimeMultiplier,
                     sourceType: (int)BoostSourceType.CoinUpgrade));
         }
         else
         {
             //Generators.ApplyTime(data.GeneratorId, data.TimeMultiplier);
             Generators.AddTimeBoost(
                 generatorId: data.GeneratorId,
                 boost: BoostInfo.CreateTemp(
                     id: BoostIds.GetTempCoinUpId(data.Id),
                     value: data.TimeMultiplier,
                     sourceType: (int)BoostSourceType.CoinUpgrade));
         }
     }
     //Services.GetService<IPlayerDataUpgrader>().Upgrade(new UpgradeItem(data.GeneratorId, data.TimeMultiplier, data.IsPermanent, data.UpgradeType));
 }
 public void ApplyBoost()
 {
     if (State == BoostState.Active)
     {
         if (!isTempBoostRunning)
         {
             isTempBoostRunning = true;
             tempProfitBoostId  = Guid.NewGuid().ToString();
             profitMultTimer    = kProfitBoostInterval;
             //Services.GenerationService.Generators.AddTempProfitMult(new GeneratorMult(tempProfitBoostId, 20));
             Services.GenerationService.Generators.AddProfitBoost(
                 boost: BoostInfo.CreateTemp(
                     id: "x20boost",
                     value: 20));
             GameEvents.OnX20BoostMultStarted(true);
         }
     }
 }
Beispiel #10
0
 private void UpgradeProfit(BosCoinUpgradeData data)
 {
     if (data.GeneratorId < 0)
     {
         if (data.IsPermanent)
         {
             //Generators.ApplyPermanent(GeneratorBonusMult.CreateProfitMult(data.ProfitMutlitplier));
             Generators.AddProfitBoost(
                 boost: BoostInfo.CreatePersist(BoostIds.GetPersistCoinUpgradeId(data.Id), data.ProfitMutlitplier, (int)BoostSourceType.CoinUpgrade));
         }
         else
         {
             //Generators.ApplyGlobal(GeneratorBonusMult.CreateProfitMult(data.ProfitMutlitplier));
             Generators.AddProfitBoost(
                 boost: BoostInfo.CreateTemp(BoostIds.GetTempCoinUpgradeId(data.Id), data.ProfitMutlitplier, (int)BoostSourceType.CoinUpgrade));
         }
     }
     else
     {
         if (data.IsPermanent)
         {
             //Generators.ApplyPermanent(data.GeneratorId, GeneratorBonusMult.CreateProfitMult(data.ProfitMutlitplier));
             Generators.AddProfitBoost(
                 generatorId: data.GeneratorId,
                 boost: BoostInfo.CreatePersist(BoostIds.GetPersistLocalCoinUpId(data.Id), data.ProfitMutlitplier, (int)BoostSourceType.CoinUpgrade));
         }
         else
         {
             //Generators.ApplyProfit(data.GeneratorId, ProfitMultInfo.Create(data.ProfitMutlitplier));
             Generators.AddProfitBoost(
                 generatorId: data.GeneratorId,
                 boost: BoostInfo.CreateTemp(BoostIds.GetTempLocalCoinUpId(data.Id), data.ProfitMutlitplier, (int)BoostSourceType.CoinUpgrade));
         }
     }
     //Services.GetService<IPlayerDataUpgrader>().Upgrade(new UpgradeItem(data.GeneratorId, data.ProfitMutlitplier, data.IsPermanent, data.UpgradeType));
 }
 public void AddProfitBoost(BoostInfo boost)
 => ProfitBoosts.Add(boost);
 public void AddProfitBoost(int generatorId, BoostInfo boost)
 {
     GetGeneratorInfo(generatorId).AddProfitBoost(boost);
 }
 public void AddTimeBoost(BoostInfo boost)
 => TimeBoosts.Add(boost);
 public void Add(BoostInfo boost)
 {
     Boosts[boost.Id] = boost;
     Recompute();
 }
Beispiel #15
0
        private IEnumerator CorrectOldSavesImpl(Update1Data data, int coins)
        {
            yield return(new WaitUntil(() => Services.PlayerService.IsLoaded));

            Services.PlayerService.SetCompanyCash(data.StoredBalance);
            Services.PlayerService.SetSecurities(data.Investors);
            Services.PlayerService.SetCoins(coins);


            yield return(new WaitUntil(() => Services.GenerationService.IsLoaded));

            Services.GenerationService.Generators.AddProfitBoost(
                boost: BoostInfo.CreatePersist(
                    id: "legacy_profit",
                    value: data.PermanentProfitMultiplier));
            Services.GenerationService.Generators.AddTimeBoost(
                boost: BoostInfo.CreatePersist(
                    id: "legacy_time",
                    value: data.PermanentSpeedMultiplier));

            //Services.GenerationService.Generators.SetPermanentProfit(data.PermanentProfitMultiplier);
            //Services.GenerationService.Generators.SetPermanentTime(data.PermanentSpeedMultiplier);
            if (data.PermanentProfitMultipliers != null)
            {
                foreach (var kvp in data.PermanentProfitMultipliers)
                {
                    //Services.GenerationService.Generators.SetPermanentProfit(kvp.Key, kvp.Value);
                    Services.GenerationService.Generators.AddProfitBoost(
                        generatorId: kvp.Key,
                        boost: BoostInfo.CreatePersist(
                            id: "legacy_profit",
                            value: kvp.Value));
                }
            }
            if (data.PermanentTimeMultipliers != null)
            {
                foreach (var kvp in data.PermanentTimeMultipliers)
                {
                    //Services.GenerationService.Generators.SetPermanentTime(kvp.Key, kvp.Value);
                    Services.GenerationService.Generators.AddTimeBoost(
                        generatorId: kvp.Key,
                        boost: BoostInfo.CreatePersist(
                            id: "legacy_time",
                            value: kvp.Value));
                }
            }

            if (data.EnhancedGenerators != null)
            {
                foreach (var generator in data.EnhancedGenerators)
                {
                    Services.GenerationService.Enhance(generator);
                }
            }

            if (data.HasMicromanager && !Services.PlayerService.IsHasMicromanager)
            {
                Services.PlayerService.SetHasMicromanager(true);
            }

            if (data.IsQuickBuyResearched && !Services.UpgradeService.IsQuickBuyResearched)
            {
                Services.UpgradeService.SetQuickBuyResearched(true);
            }

            Services.RewardsService.AddAvailableRewards(data.AvailableRewards);

            if (data.EarnedBadges != null)
            {
                foreach (var badgeId in data.EarnedBadges)
                {
                    var badge = Services.BadgeService.GetUniqueData(badgeId);
                    if (badge != null && !Services.BadgeService.IsBadgeEarned(badge))
                    {
                        Services.BadgeService.EarnBadge(badge);
                    }
                }
            }

            var globalProfit = data.GlobalProfitMultiplier < 1 ? 1 : data.GlobalProfitMultiplier;
            var globalTime   = data.GlobalTimeMultiplier < 1 ? 1 : data.GlobalTimeMultiplier;

            Services.GenerationService.Generators.AddProfitBoost(
                boost: BoostInfo.CreateTemp("global_legacy_profit", globalProfit));
            Services.GenerationService.Generators.AddTimeBoost(
                boost: BoostInfo.CreateTemp("global_legacy_time", globalTime));
            //var generatorBonusMult = new GeneratorBonusMult(globalProfit, globalTime);
            //Services.GenerationService.Generators.ApplyGlobal(generatorBonusMult);

            UnityEngine.Debug.Log("Update1 complete");
        }