예제 #1
0
        public new void UpdateDuration(long ms)
        {
            foreach (GeneratorUpgrade current in this.Upgrades)
            {
                current.UpdateDuration(ms);
            }
            CDouble leftSide = 0;
            int     num      = 0;

            if (this.IsBuilt && this.ShadowCloneCount > 0)
            {
                Creation creation = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == Creation.CreationType.Stone);
                if (creation != null)
                {
                    CDouble rightSide = ms * (long)App.State.ClonesDifGenMod / 20L;
                    CDouble cDouble   = this.ShadowCloneCount * rightSide;
                    if (creation.Count < cDouble)
                    {
                        cDouble = creation.Count;
                    }
                    CDouble cDouble2 = this.Capacity - this.FilledCapacity;
                    CDouble cDouble3 = cDouble * creation.BuyCost;
                    if (cDouble3 > cDouble2)
                    {
                        leftSide = cDouble3 - cDouble2;
                        cDouble3 = cDouble2;
                    }
                    if (leftSide > 0)
                    {
                        cDouble -= leftSide / creation.BuyCost;
                        num      = (leftSide / 962500000).ToInt();
                    }
                    this.FilledCapacity += cDouble3;
                    creation.Count      -= cDouble;
                }
            }
            if (this.FilledCapacity > 0)
            {
                CDouble cDouble4 = this.ConvertSec * ms / 1000;
                if (this.FilledCapacity > cDouble4)
                {
                    this.FilledCapacity -= cDouble4;
                }
                else
                {
                    cDouble4            = this.FilledCapacity;
                    this.FilledCapacity = 0;
                }
                CDouble cDouble5 = cDouble4 * this.DivinityEachCapacity;
                this.DivinitySec = cDouble5 * 1000 / ms;
                if (num > 400)
                {
                    num = 400;
                }
                cDouble5 = cDouble5 * (num + 100) / 100;
                this.DivinitySecWithWorker = cDouble5 * 1000 / ms;
                if (App.State.PremiumBoni.CrystalBonusDivinity > 0)
                {
                    cDouble5 = cDouble5 * (100 + App.State.PremiumBoni.CrystalBonusDivinity) / 100;
                    this.DivinitySecWithWorkerCrystal = cDouble5 * 1000 / ms;
                }
                App.State.Money += cDouble5;
            }
            else
            {
                this.DivinitySecWithWorker = 0;
                this.DivinitySec           = 0;
            }
            if (this.ShadowCloneCount == 0 || this.IsBuilt)
            {
                return;
            }
            if (!this.IsPaid)
            {
                bool          flag          = false;
                StringBuilder stringBuilder = new StringBuilder("You still need:\n");
                using (List <CreationCost> .Enumerator enumerator2 = this.RequiredCreations.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        CreationCost cost      = enumerator2.Current;
                        Creation     creation2 = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                        if (!CreationCost.HasCreations(App.State, cost, App.State.GameSettings.AutoBuyCreationsForDivGen))
                        {
                            flag = true;
                            stringBuilder.Append(creation2.Name).Append(" x ").Append((cost.CountNeeded - creation2.Count).ToGuiText(true)).Append("\n");
                        }
                    }
                }
                if (flag)
                {
                    stringBuilder.Append("to build ").Append(this.Name).ToString();
                    if (!App.State.GameSettings.StickyClones)
                    {
                        GuiBase.ShowToast(stringBuilder.ToString());
                        App.State.Clones.RemoveUsedShadowClones(this.ShadowCloneCount);
                        this.ShadowCloneCount = 0;
                    }
                    else
                    {
                        this.MissingItems = "\n\n" + stringBuilder.ToString();
                    }
                    return;
                }
                using (List <CreationCost> .Enumerator enumerator3 = this.RequiredCreations.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        CreationCost cost      = enumerator3.Current;
                        Creation     creation3 = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                        creation3.Count -= cost.CountNeeded;
                    }
                }
                this.IsPaid = true;
            }
            this.MissingItems     = string.Empty;
            this.CurrentDuration += (ms * (long)this.ShadowCloneCount.ToInt() * (long)App.State.PremiumBoni.MonumentBuildTimeDivider * (100 + App.State.PremiumBoni.BuildingSpeedUpPercent(true)) / 100).ToLong();
            Log.Info(string.Concat(new object[]
            {
                this.Name,
                ", Duration: ",
                this.CurrentDuration,
                " / ",
                this.DurationInMS(1)
            }));
            if (this.CurrentDuration > this.DurationInMS(1))
            {
                this.IsPaid          = false;
                this.CurrentDuration = 0L;
                this.IsBuilt         = true;
                App.State.Clones.RemoveUsedShadowClones(this.ShadowCloneCount);
                this.ShadowCloneCount = 0;
            }
        }
예제 #2
0
 public new bool UpdateDuration(long ms)
 {
     if (this.ShadowCloneCount == 0)
     {
         return(false);
     }
     if (this.StopAt != 0 && this.StopAt <= this.Level)
     {
         App.State.Clones.RemoveUsedShadowClones(this.ShadowCloneCount);
         this.ShadowCloneCount = 0;
         return(false);
     }
     if (!this.IsPaid)
     {
         bool          flag          = false;
         StringBuilder stringBuilder = new StringBuilder("You still need:\n");
         using (List <CreationCost> .Enumerator enumerator = this.RequiredCreations.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 CreationCost cost     = enumerator.Current;
                 Creation     creation = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                 if (!CreationCost.HasCreations(App.State, cost, App.State.GameSettings.AutoBuyCreationsForDivGen))
                 {
                     flag = true;
                     stringBuilder.Append(creation.Name).Append(" x ").Append((cost.CountNeeded - creation.Count).ToGuiText(true)).Append("\n");
                 }
             }
         }
         if (flag)
         {
             if (!App.State.GameSettings.StickyClones)
             {
                 stringBuilder.Append("to upgrade ").Append(this.Name).ToString();
                 GuiBase.ShowToast(stringBuilder.ToString());
                 App.State.Clones.RemoveUsedShadowClones(this.ShadowCloneCount);
                 this.ShadowCloneCount = 0;
             }
             else
             {
                 this.MissingItems = "\n\n" + stringBuilder.ToString();
             }
             return(false);
         }
         using (List <CreationCost> .Enumerator enumerator2 = this.RequiredCreations.GetEnumerator())
         {
             while (enumerator2.MoveNext())
             {
                 CreationCost cost      = enumerator2.Current;
                 Creation     creation2 = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                 creation2.Count -= cost.CountNeeded;
             }
         }
         this.IsPaid = true;
     }
     this.MissingItems     = string.Empty;
     this.CurrentDuration += (ms * (long)this.ShadowCloneCount.ToInt() * (long)App.State.PremiumBoni.MonumentBuildTimeDivider * (100 + App.State.PremiumBoni.BuildingSpeedUpPercent(true)) / 100).ToLong();
     if (this.CurrentDuration > this.DurationInMS(1))
     {
         this.IsPaid          = false;
         this.CurrentDuration = 0L;
         this.Level           = ++this.Level;
         if (App.State.GameSettings.StopDivinityGenBuilding)
         {
             App.State.Clones.RemoveUsedShadowClones(this.ShadowCloneCount);
             this.ShadowCloneCount = 0;
         }
         return(true);
     }
     return(false);
 }