Пример #1
0
    public override void EventEnter()
    {
        foreach (var x in Services.GenerationService.Generators.Generators.Values)
        {
            //Services.GenerationService.Generators.SetEfficiencyMult(x.GeneratorId, 1.0 - ProfitReduction);
            //Services.GenerationService.Generators.SetSpeedMult(x.GeneratorId, 1.0 + SpeedReduction);
            Generators.AddProfitBoost(x.GeneratorId, BoostInfo.CreateTemp(GetType().FullName, 1.0 - ProfitReduction));
            Generators.AddTimeBoost(x.GeneratorId,
                                    BoostInfo.CreateTemp(GetType().FullName, 1.0f - Mathf.Clamp01(SpeedReduction)));
        }

        StartCoroutine(ShowImpl());
    }
Пример #2
0
    public override void Update()
    {
        if (frameTime < 1.13f)
        {
            frameTime += Time.deltaTime;
            return;
        }
        frameTime = 0;

        foreach (var x in Achievements)
        {
            if (x.IsCompleted)
            {
                continue;
            }

            if (Services.TransportService.HasUnits(x.TargetGeneratorId))
            {
                var tCount = Services.TransportService.GetUnitTotalCount(x.TargetGeneratorId); //_pdata.OwnedGenerators[x.TargetGeneratorId];
                if (tCount >= x.TargetCount)
                {
                    Services.GetService <IAchievmentServcie>().AddCompletedAchievment(x.Id.ToString());
                    Services.AchievmentService.AddAchievmentPoints(x.Points);
                    Points       += x.Points;
                    x.IsCompleted = true;

                    switch (x.RewardType)
                    {
                    case RewardType.SpeedUpgrade:
                        //Services.GenerationService.Generators.ApplyTime(x.TargetGeneratorId, x.RewardValue);
                        Services.GenerationService.Generators.AddTimeBoost(x.TargetGeneratorId, BoostInfo.CreateTemp(BosUtils.PrefixedId("speed_achiv_"), x.RewardValue));
                        break;

                    case RewardType.ProfitUpgrade:
                        Services.GenerationService.Generators.AddProfitBoost(x.TargetGeneratorId, BoostInfo.CreateTemp(BosUtils.PrefixedId("profit_achiv_"), x.RewardValue));
                        //Services.GenerationService.Generators.ApplyProfit(x.TargetGeneratorId, ProfitMultInfo.Create(x.RewardValue));
                        break;

                    default:
                        break;
                    }

                    //Proc.Invoke(x);
                    GameEvents.OnAchievmentCompleted(new AchievmentInfo(x.Id, x.Name));
                    StatsCollector.Instance[Stats.REWARDS_UNLOCKED]++;
                    ChangeGeneratorIcon(x);
                    Player.LegacyPlayerData.Save();
                }
            }
        }
    }