Пример #1
0
 private void CalcMonuments(long timeMS, StringBuilder infoBuilder)
 {
     foreach (Monument current in this.State.AllMonuments)
     {
         if (current.ShadowCloneCount > 0)
         {
             int     num     = current.ShadowCloneCount.ToInt();
             CDouble cDouble = timeMS * (long)num * (long)this.State.PremiumBoni.MonumentBuildTimeDivider * (100 + this.State.PremiumBoni.BuildingSpeedUpPercent(true)) / 100;
             long    num2    = current.DurationInMS(1);
             long    num3    = num2 / (current.Level.ToLong() + 1L);
             if (num2 < 30L)
             {
                 num2 = 30L;
             }
             if (num3 < 30L)
             {
                 num3 = 30L;
             }
             CDouble rightSide = current.Level * (num2 - num3) / 2;
             CDouble leftSide  = cDouble + rightSide;
             CDouble cDouble2  = Math.Sqrt((leftSide / num3).Double) * 1.414215;
             cDouble2.Floor();
             if (cDouble2 < current.Level)
             {
                 cDouble2 = current.Level;
             }
             if (cDouble2 > current.StopAt && current.StopAt != 0)
             {
                 cDouble2 = current.StopAt;
             }
             if (this.State.GameSettings.StopMonumentBuilding && cDouble2 > current.Level)
             {
                 cDouble2 = current.Level + 1;
             }
             int num4 = (cDouble2 - current.Level).ToInt();
             if (num4 > 20000)
             {
                 num4 = 20000;
             }
             CDouble cDouble3 = 1;
             if (num4 == 0)
             {
                 current.CurrentDuration += cDouble.ToLong();
             }
             else
             {
                 bool    flag     = false;
                 CDouble cDouble4 = cDouble2;
                 if ((num4 + current.Level).ToInt() == current.StopAt && current.StopAt != 0)
                 {
                     current.CurrentDuration = 0L;
                     cDouble4 = --cDouble4;
                 }
                 if (num4 > 1)
                 {
                     cDouble3 = cDouble4 * cDouble4 / 2 + cDouble4 / 2;
                     cDouble3 = cDouble3 - current.Level * current.Level / 2 + current.Level / 2;
                     foreach (CreationCost current2 in current.RequiredCreations(cDouble3))
                     {
                         if (!CreationCost.HasCreations(this.State, current2, this.State.GameSettings.AutoBuyCreationsForMonuments))
                         {
                             flag    = true;
                             cDouble = 0;
                             break;
                         }
                     }
                     while (flag)
                     {
                         flag     = false;
                         num4    /= 2;
                         cDouble2 = num4 + current.Level;
                         if (num4 < 1)
                         {
                             break;
                         }
                         cDouble3 = cDouble2 * cDouble2 / 2 + cDouble2 / 2;
                         cDouble3 = cDouble3 - current.Level * current.Level / 2 + current.Level / 2;
                         foreach (CreationCost current3 in current.RequiredCreations(cDouble3))
                         {
                             if (!CreationCost.HasCreations(this.State, current3, this.State.GameSettings.AutoBuyCreationsForMonuments))
                             {
                                 flag    = true;
                                 cDouble = 0;
                                 break;
                             }
                         }
                     }
                 }
                 if (!flag)
                 {
                     if (num4 > 1)
                     {
                         using (List <CreationCost> .Enumerator enumerator4 = current.RequiredCreations(cDouble3).GetEnumerator())
                         {
                             while (enumerator4.MoveNext())
                             {
                                 CreationCost cost     = enumerator4.Current;
                                 Creation     creation = this.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                                 creation.Count -= cost.CountNeeded;
                                 if (creation.count < 0)
                                 {
                                     creation.count = 0;
                                 }
                             }
                         }
                     }
                     current.Level += num4;
                     this.State.Statistic.MonumentsCreated += num4;
                     current.AddStatBoni();
                     if (this.State.GameSettings.StopMonumentBuilding)
                     {
                         this.State.Clones.RemoveUsedShadowClones(current.ShadowCloneCount);
                         current.ShadowCloneCount = 0;
                         current.CurrentDuration  = 0L;
                         cDouble = 0;
                     }
                     if (current.TypeEnum == Monument.MonumentType.temple_of_god)
                     {
                         this.State.Generator.IsAvailable = true;
                     }
                 }
             }
             if (current.CurrentDuration < 0L)
             {
                 current.CurrentDuration = 0L;
             }
             if (num4 > 0)
             {
                 infoBuilder.Append("- monument: ").Append(current.Name).Append(" was built ").Append(num4).Append(" x\n");
             }
         }
         if (current.Upgrade.ShadowCloneCount > 0)
         {
             int     num5     = current.Upgrade.ShadowCloneCount.ToInt();
             CDouble cDouble5 = timeMS * (long)num5 * (long)this.State.PremiumBoni.MonumentBuildTimeDivider * (100 + this.State.PremiumBoni.BuildingSpeedUpPercent(true)) / 100;
             int     num6     = 0;
             while (cDouble5 > 0)
             {
                 long value = current.Upgrade.DurationInMS(1) - current.Upgrade.CurrentDuration;
                 if (cDouble5 >= value && current.Upgrade.Level >= current.Upgrade.StopAt && current.Upgrade.StopAt != 0)
                 {
                     this.State.Clones.RemoveUsedShadowClones(current.Upgrade.ShadowCloneCount);
                     current.Upgrade.ShadowCloneCount = 0;
                     current.Upgrade.CurrentDuration  = 0L;
                     cDouble5 = 0;
                 }
                 else if (cDouble5 >= value)
                 {
                     cDouble5 -= value;
                     current.Upgrade.CurrentDuration = 0L;
                     bool flag2 = false;
                     if (!current.Upgrade.IsPaid)
                     {
                         foreach (CreationCost current4 in current.Upgrade.RequiredCreations)
                         {
                             if (!CreationCost.HasCreations(this.State, current4, this.State.GameSettings.AutoBuyCreationsForMonuments))
                             {
                                 flag2    = true;
                                 cDouble5 = 0;
                                 break;
                             }
                         }
                     }
                     if (!flag2)
                     {
                         if (!current.Upgrade.IsPaid)
                         {
                             using (List <CreationCost> .Enumerator enumerator6 = current.Upgrade.RequiredCreations.GetEnumerator())
                             {
                                 while (enumerator6.MoveNext())
                                 {
                                     CreationCost cost      = enumerator6.Current;
                                     Creation     creation2 = this.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                                     creation2.Count -= cost.CountNeeded;
                                     if (creation2.count < 0)
                                     {
                                         creation2.count = 0;
                                     }
                                 }
                             }
                         }
                         else
                         {
                             current.Upgrade.IsPaid = false;
                         }
                         num6++;
                         current.AddUpgradeLevel();
                         if (this.State.GameSettings.StopMonumentBuilding)
                         {
                             this.State.Clones.RemoveUsedShadowClones(current.Upgrade.ShadowCloneCount);
                             current.Upgrade.ShadowCloneCount = 0;
                             current.Upgrade.CurrentDuration  = 0L;
                             cDouble5 = 0;
                         }
                     }
                 }
                 else
                 {
                     current.Upgrade.CurrentDuration += cDouble5.ToLong();
                     cDouble5 = 0;
                 }
             }
             if (num6 > 0)
             {
                 infoBuilder.Append("- upgrade for ").Append(current.Name).Append(" was built ").Append(num6).Append(" x\n");
             }
         }
     }
 }
Пример #2
0
 private void CalcDivGen(long timeMS, StringBuilder infoBuilder)
 {
     if (this.State.Generator.ShadowCloneCount > 0 && !this.State.Generator.IsBuilt)
     {
         int     num     = this.State.Generator.ShadowCloneCount.ToInt();
         CDouble cDouble = timeMS * (long)num * (long)this.State.PremiumBoni.MonumentBuildTimeDivider * (100 + this.State.PremiumBoni.BuildingSpeedUpPercent(true)) / 100;
         long    value   = this.State.Generator.DurationInMS(1) - this.State.Generator.CurrentDuration;
         if (cDouble >= value)
         {
             this.State.Generator.CurrentDuration = 0L;
             this.State.Generator.IsPaid          = false;
             this.State.Generator.IsBuilt         = true;
             this.State.Clones.RemoveUsedShadowClones(num);
             this.State.Generator.ShadowCloneCount = 0;
             infoBuilder.Append("- divinity generator was built\n");
         }
         else
         {
             this.State.Generator.CurrentDuration += cDouble.ToLong();
             cDouble = 0;
         }
     }
     foreach (GeneratorUpgrade current in this.State.Generator.Upgrades)
     {
         if (current.ShadowCloneCount > 0)
         {
             int     num2     = current.ShadowCloneCount.ToInt();
             CDouble cDouble2 = timeMS * (long)num2 * (long)this.State.PremiumBoni.MonumentBuildTimeDivider * (100 + this.State.PremiumBoni.BuildingSpeedUpPercent(true)) / 100;
             int     num3     = 0;
             while (cDouble2 > 0)
             {
                 if (current.StopAt != 0 && current.StopAt <= current.Level)
                 {
                     this.State.Clones.RemoveUsedShadowClones(current.ShadowCloneCount);
                     current.ShadowCloneCount = 0;
                     cDouble2 = 0;
                 }
                 else
                 {
                     long value2 = current.DurationInMS(1) - current.CurrentDuration;
                     if (cDouble2 >= value2)
                     {
                         cDouble2 -= value2;
                         current.CurrentDuration = 0L;
                         bool flag = false;
                         if (!current.IsPaid)
                         {
                             foreach (CreationCost current2 in current.RequiredCreations)
                             {
                                 if (!CreationCost.HasCreations(this.State, current2, this.State.GameSettings.AutoBuyCreationsForMonuments))
                                 {
                                     flag = true;
                                     current.CurrentDuration = current.DurationInMS(1);
                                     cDouble2 = 0;
                                     break;
                                 }
                             }
                         }
                         if (!flag)
                         {
                             if (!current.IsPaid)
                             {
                                 using (List <CreationCost> .Enumerator enumerator3 = current.RequiredCreations.GetEnumerator())
                                 {
                                     while (enumerator3.MoveNext())
                                     {
                                         CreationCost cost     = enumerator3.Current;
                                         Creation     creation = this.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                                         creation.Count -= cost.CountNeeded;
                                     }
                                 }
                             }
                             else
                             {
                                 current.IsPaid = false;
                             }
                             num3++;
                             GeneratorUpgrade expr_3BE = current;
                             expr_3BE.Level = ++expr_3BE.Level;
                             if (this.State.GameSettings.StopDivinityGenBuilding)
                             {
                                 this.State.Clones.RemoveUsedShadowClones(current.ShadowCloneCount);
                                 current.ShadowCloneCount = 0;
                                 current.CurrentDuration  = 0L;
                                 cDouble2 = 0;
                             }
                         }
                     }
                     else
                     {
                         current.CurrentDuration += cDouble2.ToLong();
                         cDouble2 = 0;
                     }
                 }
             }
             if (num3 > 0)
             {
                 infoBuilder.Append("- upgrade: ").Append(current.Name).Append(" was built ").Append(num3).Append(" x\n");
             }
         }
     }
     infoBuilder.Append("After your break, you feel refreshed and your creation speed is tripled for the next ").Append(Conv.MsToGuiText(this.State.CreatingSpeedBoniDuration, true)).Append("!");
 }
Пример #3
0
        private void CalcCreations(long timeMS, StringBuilder infoBuilder)
        {
            CDouble cDouble = this.State.CreationSpeed(timeMS) / 3L;
            long    num     = timeMS;
            bool    flag    = false;

            if ((this.State.GameSettings.LastCreation != null && this.State.GameSettings.LastCreation.TypeEnum == Creation.CreationType.Shadow_clone) || (this.State.GameSettings.CreateShadowClonesIfNotMax && this.State.Clones.Count < this.State.Clones.MaxShadowClones))
            {
                flag = true;
            }
            if (flag)
            {
                Creation creation = this.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == Creation.CreationType.Shadow_clone);
                Creation.UpdateDurationMulti(this.State);
                CDouble cDouble2 = cDouble / creation.DurationInMS * (this.State.PremiumBoni.CreationCountBoni(true) + 1);
                if (cDouble2 > timeMS / 30L * (this.State.PremiumBoni.CreationCountBoni(true) + 1))
                {
                    cDouble2 = timeMS / 30L * (this.State.PremiumBoni.CreationCountBoni(true) + 1);
                }
                if (cDouble2 > 0)
                {
                    CDouble cDouble3 = timeMS / cDouble2;
                    bool    flag2    = this.State.GameSettings.LastCreation != null && this.State.GameSettings.LastCreation.TypeEnum == Creation.CreationType.Shadow_clone;
                    if (cDouble2 + creation.Count > this.State.Clones.MaxShadowClones && this.State.GameSettings.CreateShadowClonesIfNotMax && !flag2)
                    {
                        cDouble2 = this.State.Clones.MaxShadowClones - creation.Count;
                        num     -= cDouble2.ToLong() * cDouble3.ToLong();
                    }
                    creation.TotalCreated += cDouble2;
                    this.State.Clones.TotalClonesCreated          += cDouble2;
                    this.State.Statistic.TotalShadowClonesCreated += cDouble2;
                    if (cDouble2 > 0)
                    {
                        infoBuilder.Append("- created ").Append(cDouble2.GuiText).Append(" Shadow Clones\n");
                    }
                    if (this.State.Clones.Count + cDouble2 > this.State.Clones.MaxShadowClones)
                    {
                        cDouble2 = this.State.Clones.MaxShadowClones - this.State.Clones.Count;
                    }
                    this.State.Clones.Count = this.State.Clones.Count + cDouble2.ToInt();
                    if (this.State.Clones.Count < this.State.Clones.MaxShadowClones)
                    {
                        num = 0L;
                    }
                }
            }
            if (this.State.GameSettings.LastCreation != null && this.State.GameSettings.LastCreation.TypeEnum != Creation.CreationType.Shadow_clone && App.CurrentPlattform == Plattform.Android)
            {
                while (num > 0L)
                {
                    cDouble = this.State.CreationSpeed(num) / 3L;
                    Creation creation2 = this.State.GameSettings.LastCreation;
                    CDouble  cDouble4  = creation2.DurationInMS;
                    if (cDouble4 < 30)
                    {
                        cDouble4 = 30;
                    }
                    CDouble cDouble5 = cDouble / cDouble4;
                    if (cDouble5 < 1)
                    {
                        creation2.currentDuration += cDouble.ToLong();
                        break;
                    }
                    cDouble5.Round();
                    cDouble5 *= this.State.PremiumBoni.CreationCountBoni(true) + 1;
                    List <CreationCost> list = CreationCost.RequiredCreations(creation2.TypeEnum, cDouble5.ToLong(), true);
                    bool flag3 = true;
                    foreach (CreationCost current in list)
                    {
                        if (!CreationCost.HasCreations(this.State, current, this.State.GameSettings.AutoBuyCreations))
                        {
                            flag3 = false;
                        }
                    }
                    if (!flag3)
                    {
                        cDouble5 = this.State.GameSettings.CreationToCreateCount;
                        if (cDouble5 == 0)
                        {
                            cDouble5 = 1;
                        }
                        list  = CreationCost.RequiredCreations(creation2.TypeEnum, cDouble5.ToLong(), true);
                        flag3 = true;
                        foreach (CreationCost current2 in list)
                        {
                            if (!CreationCost.HasCreations(this.State, current2, this.State.GameSettings.AutoBuyCreations))
                            {
                                flag3 = false;
                            }
                        }
                        if (flag3)
                        {
                            bool flag4 = true;
                            while (flag4)
                            {
                                cDouble5 *= 2;
                                list      = CreationCost.RequiredCreations(creation2.TypeEnum, cDouble5.ToLong(), true);
                                foreach (CreationCost current3 in list)
                                {
                                    if (!CreationCost.HasCreations(this.State, current3, this.State.GameSettings.AutoBuyCreations))
                                    {
                                        flag4     = false;
                                        cDouble5 /= 2;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (!flag3)
                    {
                        infoBuilder.Append("- you failed to create " + creation2.Name + " because of missing prerequisites or divinity, so you created stones instead.\n");
                        list      = new List <CreationCost>();
                        creation2 = this.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == Creation.CreationType.Stone);
                        cDouble4  = creation2.DurationInMS;
                        if (cDouble4 < 30)
                        {
                            cDouble4 = 30;
                        }
                        cDouble5 = cDouble / cDouble4 * (this.State.PremiumBoni.CreationCountBoni(true) + 1);
                    }
                    CDouble cDouble6 = cDouble5 + creation2.Count;
                    CDouble cDouble7 = -1;
                    if (creation2.NextAtCount > 0)
                    {
                        if (this.State.GameSettings.CreationsNextAtMode == 1)
                        {
                            cDouble7 = creation2.NextAtCount - creation2.Count;
                        }
                        else if (this.State.GameSettings.CreationsNextAtMode == 2)
                        {
                            cDouble7 = creation2.NextAtCount - creation2.TotalCreated;
                        }
                    }
                    if (cDouble7 != -1 && cDouble5 > cDouble7 && flag3)
                    {
                        if (cDouble7 > 0)
                        {
                            cDouble5 = cDouble7;
                            CDouble cDouble8 = (cDouble5 * cDouble4 / (this.State.PremiumBoni.CreationCountBoni(true) + 1)).ToLong();
                            cDouble8 = cDouble8 / this.State.PremiumBoni.CreationDopingDivider / (100 + this.State.PremiumBoni.CreatingSpeedUpPercent(true)) * 100;
                            num     -= cDouble8.ToLong();
                        }
                        else
                        {
                            cDouble5 = 0;
                        }
                    }
                    else
                    {
                        num = 0L;
                    }
                    if (num > 0L && this.State.GameSettings.LastCreation.TypeEnum != Creation.CreationType.Universe)
                    {
                        Creation creation3 = this.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == this.State.GameSettings.LastCreation.TypeEnum + 1);
                        if (!creation3.GodToDefeat.IsDefeated)
                        {
                            break;
                        }
                        this.State.GameSettings.LastCreation = creation3;
                    }
                    else
                    {
                        num = 0L;
                    }
                    if (cDouble5 > 1)
                    {
                        list = CreationCost.RequiredCreations(creation2.TypeEnum, cDouble5.ToLong(), true);
                        using (List <CreationCost> .Enumerator enumerator4 = list.GetEnumerator())
                        {
                            while (enumerator4.MoveNext())
                            {
                                CreationCost cost      = enumerator4.Current;
                                Creation     creation4 = this.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                                creation4.Count -= cost.CountNeeded;
                                if (creation4.Count < 0)
                                {
                                    Log.Info(string.Concat(new object[]
                                    {
                                        creation4.Name,
                                        " had ",
                                        creation4.Count,
                                        "!"
                                    }));
                                    creation4.Count = 0;
                                }
                            }
                        }
                        cDouble5.Floor();
                        creation2.Count        += cDouble5;
                        creation2.TotalCreated += cDouble5;
                        this.State.CheckForAchievement(creation2);
                        this.State.CheckForAchievement(creation2);
                        this.State.CheckForAchievement(creation2);
                        infoBuilder.Append("- you created ").Append(cDouble5.GuiText).Append(" " + creation2.Name + "\n\n");
                    }
                }
                num = 0L;
            }
            if (this.State.Statistic.HasStartedUniverseChallenge)
            {
                Creation creation5 = this.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == Creation.CreationType.Universe);
                creation5.FinishUUC(this.State);
            }
        }