internal static CDouble getCDoubleFromParts(string[] parts, string partname, bool round = false) { string stringFromParts = Conv.getStringFromParts(parts, partname); CDouble cDouble = new CDouble(stringFromParts); if (round) { cDouble.Round(); } return(cDouble); }
public static bool SpendGodPower(CDouble cdCount) { int num = cdCount.ToInt(); if (App.State.PremiumBoni.GodPower >= num) { CDouble cDouble = num; CDouble cDouble2 = App.State.PremiumBoni.GodPower - App.State.PremiumBoni.GpBoniPhysical - App.State.PremiumBoni.GpBoniMystic - App.State.PremiumBoni.GpBoniBattle - App.State.PremiumBoni.GpBoniCreating; cDouble2.Round(); if (cDouble2 > 0) { cDouble = num - cDouble2; if (cDouble < 0) { cDouble = 0; } } App.State.PremiumBoni.GpBoniPhysical -= cDouble; cDouble = 0; if (App.State.PremiumBoni.GpBoniPhysical < 0) { cDouble = App.State.PremiumBoni.GpBoniPhysical * -1; App.State.PremiumBoni.GpBoniPhysical = 0; } App.State.PremiumBoni.GpBoniMystic -= cDouble; cDouble = 0; if (App.State.PremiumBoni.GpBoniMystic < 0) { cDouble = App.State.PremiumBoni.GpBoniMystic * -1; App.State.PremiumBoni.GpBoniMystic = 0; } App.State.PremiumBoni.GpBoniBattle -= cDouble; cDouble = 0; if (App.State.PremiumBoni.GpBoniBattle < 0) { cDouble = App.State.PremiumBoni.GpBoniBattle * -1; App.State.PremiumBoni.GpBoniBattle = 0; } App.State.PremiumBoni.GpBoniCreating -= cDouble; cDouble = 0; if (App.State.PremiumBoni.GpBoniCreating < 0) { cDouble = App.State.PremiumBoni.GpBoniCreating * -1; App.State.PremiumBoni.GpBoniCreating = 0; } App.State.PremiumBoni.TotalGodPowerSpent += num; App.State.PremiumBoni.GodPower -= num; App.State.PremiumBoni.permanentGPSpent = 0; return(true); } GuiBase.ShowToast("You don't have enough god power!"); return(false); }
private void CalcTrainingSkills <T>(long timeMS, StringBuilder infoBuilder, List <T> elements, int stopAtCount, bool isNextOn) { int num = 0; long num2 = 0L; List <TrainingBase> list = new List <TrainingBase>(); foreach (T current in elements) { if (current is TrainingBase) { list.Add(current as TrainingBase); } } for (int i = 0; i < list.Count; i++) { TrainingBase trainingBase = list[i]; bool flag = false; if (trainingBase is Skill) { flag = ((Skill)trainingBase).IsAvailable; } if (trainingBase is Training) { flag = ((Training)trainingBase).IsAvailable; } if (num > 0 && flag) { if (trainingBase.ShadowCloneCount > 0) { num2 = 0L; } trainingBase.AddCloneCount(num); num = 0; } long num3 = 0L; if (trainingBase is Skill && ((Skill)trainingBase).IsAvailable && trainingBase.DurationInMS(1) > 30) { num3 = timeMS / 300000L; if (num3 > 10000L) { num3 = 10000L; } ((Skill)trainingBase).Extension.UsageCount += num3; } if (trainingBase.ShadowCloneCount > 0) { int num4 = trainingBase.ShadowCloneCount.ToInt(); int num5 = trainingBase.DurationInMS(num4); if (num5 < 30) { num5 = 30; } long num6 = timeMS; CDouble cDouble = 0; if (num2 > 0L) { num6 = num2; num2 = 0L; } cDouble = num6 / (long)num5; if (cDouble > 0) { bool flag2 = num4 <= this.State.GameSettings.TrainIgnoreCount && this.State.GameSettings.IgnoreCloneCountOn; if (!flag2 && !this.State.GameSettings.UseStopAt && stopAtCount <= trainingBase.Level + cDouble && isNextOn) { CDouble cDouble2 = stopAtCount - trainingBase.Level; if (this.State.PremiumBoni.ImprovedNextAt) { cDouble2 = (trainingBase.EnumValue + 1) * 500 - trainingBase.Level; if (stopAtCount - trainingBase.Level > cDouble2) { cDouble2 = stopAtCount - trainingBase.Level; } } if (cDouble2 > 0) { num6 -= (cDouble2 * num5).ToLong(); num2 = (num5 * (cDouble - cDouble2)).ToLong(); int num7 = this.State.GameSettings.TrainIgnoreCount; if (!this.State.GameSettings.IgnoreCloneCountOn) { num7 = 0; } num = trainingBase.ShadowCloneCount.ToInt() - num7; if (num2 > 0L) { int num8 = trainingBase.ShadowCloneCount.ToInt() - num; num5 = trainingBase.DurationInMS(num8); if (num5 < 30) { num5 = 30; } if (num8 > 0) { cDouble = cDouble2 + num6 / (long)num5; } else { cDouble = cDouble2; } trainingBase.RemoveCloneCount(num); } else { num = 0; } } } else if (!flag2 && isNextOn && stopAtCount <= trainingBase.Level + cDouble && (this.State.GameSettings.UseStopAt || trainingBase.EnumValue != 27)) { cDouble = stopAtCount - trainingBase.Level.ToInt(); if (cDouble < 0) { cDouble = 0; } } cDouble.Round(); trainingBase.Level += cDouble; string value = string.Empty; if (trainingBase is Training) { value = ((Training)trainingBase).Name; this.State.PhysicalPowerBase += trainingBase.PowerGain * cDouble; this.State.Statistic.TotalTrainingLevels += cDouble; } else if (trainingBase is Skill) { value = ((Skill)trainingBase).Name; this.State.MysticPowerBase += trainingBase.PowerGain * cDouble; this.State.Statistic.TotalSkillLevels += cDouble; } infoBuilder.Append("- gained ").Append(cDouble).Append(" levels in ' ").Append(value).Append(" '\n"); if (num3 > 0L) { infoBuilder.Append("- ").Append(value).Append(" was also used ").Append(num3).Append(" times to reduce the cap").Append("\n"); } } } } }
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); } }
private void ShowBuyCreations() { GUIStyle style = GUI.skin.GetStyle("TextField"); GUIStyle style2 = GUI.skin.GetStyle("Label"); GUIStyle style3 = GUI.skin.GetStyle("Button"); style.fontSize = GuiBase.FontSize(16); style3.fontSize = GuiBase.FontSize(16); style.alignment = TextAnchor.MiddleCenter; Rect rect = new Rect(GuiBase.Width(365f), GuiBase.Height(360f), GuiBase.Width(500f), GuiBase.Height(150f)); GUI.Box(new Rect(GuiBase.Width(290f), GuiBase.Height(110f), GuiBase.Width(660f), GuiBase.Height(480f)), string.Empty); style2.fontSize = GuiBase.FontSize(16); style2.alignment = TextAnchor.MiddleCenter; GUI.Label(new Rect(rect.xMin, rect.yMin + GuiBase.Height(10f), GuiBase.Width(450f), GuiBase.Height(30f)), new GUIContent(string.Empty, "Hello my dear god. Please click twice on the white box and then put a big number into it.\nOnly numbers though! Then finalize with the 'Buy' button. You can ignore the 'Cancel' button")); if (string.IsNullOrEmpty(this.countToBuy)) { this.countToBuy = string.Empty; } this.countToBuy = GUI.TextField(new Rect(rect.xMin + GuiBase.Width(30f), rect.yMin + GuiBase.Height(45f), GuiBase.Width(270f), GuiBase.Height(30f)), this.countToBuy); if (GUI.Button(new Rect(rect.xMin + GuiBase.Width(400f), rect.yMin + GuiBase.Height(45f), GuiBase.Width(75f), GuiBase.Height(30f)), "Cancel")) { this.creationToShow = null; return; } try { if (!string.IsNullOrEmpty(this.countToBuy) && this.countToBuy.StartsWith("-")) { GuiBase.ShowToast("I only sell my creations to you. I won't buy them."); this.countToBuy = string.Empty; return; } CDouble cDouble = new CDouble(this.countToBuy); cDouble.Round(); this.countToBuy = cDouble.ToString(); style2.alignment = TextAnchor.UpperLeft; GUI.Label(new Rect(rect.xMin + GuiBase.Width(35f), rect.yMin + GuiBase.Height(85f), GuiBase.Width(450f), GuiBase.Height(30f)), "Divinity cost: " + (this.creationToShow.BuyCost * cDouble).ToGuiText(true)); GUI.Label(new Rect(rect.xMin + GuiBase.Width(35f), rect.yMin + GuiBase.Height(115f), GuiBase.Width(450f), GuiBase.Height(30f)), "You have: " + App.State.Money.ToGuiText(true) + " divinity"); GUI.Label(new Rect(rect.xMin + GuiBase.Width(35f), rect.yMin + GuiBase.Height(145f), GuiBase.Width(450f), GuiBase.Height(30f)), "You have: " + this.creationToShow.Count.ToGuiText(true) + " " + this.creationToShow.Name.ToLower()); style2.alignment = TextAnchor.MiddleCenter; if (GUI.Button(new Rect(rect.xMin + GuiBase.Width(315f), rect.yMin + GuiBase.Height(45f), GuiBase.Width(75f), GuiBase.Height(30f)), "Buy")) { CDouble cDouble2 = this.creationToShow.BuyCost * cDouble; App.State.Money.Round(); cDouble2.Round(); if (App.State.Money >= cDouble2) { App.State.Money -= cDouble2; this.creationToShow.Count += cDouble; this.creationToShow = null; App.State.Statistic.TotalMoneySpent += cDouble2; } else { GuiBase.ShowToast("Sorry you are way too poor to afford that.\nPlease save up a little more and then come back."); } } } catch (ArgumentOutOfRangeException) { this.countToBuy = string.Empty; GuiBase.ShowToast("Only numbers are allowed! Don't ask why. It's just hard to count money with letters or some weird characters."); } GUI.BeginGroup(new Rect(GuiBase.Width(280f), GuiBase.Height(120f), GuiBase.Width(670f), GuiBase.Height(480f))); if (this.creationToShow != null) { style2.fontStyle = FontStyle.Bold; GUI.Label(new Rect(GuiBase.Width(10f), GuiBase.Height(10f), GuiBase.Width(660f), GuiBase.Height(50f)), "I can sell you a " + this.creationToShow.Name + ". How many do you want to buy? \nPress a button or input a number."); style2.fontStyle = FontStyle.Normal; } this.toggleNumber = GUI.Toolbar(new Rect(GuiBase.Width(55f), GuiBase.Height(70f), GuiBase.Width(245f), GuiBase.Height(35f)), this.toggleNumber, this.toolbarLeftStrings); int value = 1; if (this.toggleNumber == 1) { value = 2; } else if (this.toggleNumber == 2) { value = 5; } else if (this.toggleNumber == 3) { value = 25; } else if (this.toggleNumber == 4) { value = 75; } CDouble cDouble3 = new CDouble("1") * value; if (GUI.Button(new Rect(GuiBase.Width(55f), GuiBase.Height(120f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble3.ToGuiText(true))) { this.BuyCount(cDouble3); } CDouble cDouble4 = new CDouble("10") * value; if (GUI.Button(new Rect(GuiBase.Width(200f), GuiBase.Height(120f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble4.ToGuiText(true))) { this.BuyCount(cDouble4); } CDouble cDouble5 = new CDouble("100") * value; if (GUI.Button(new Rect(GuiBase.Width(345f), GuiBase.Height(120f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble5.ToGuiText(true))) { this.BuyCount(cDouble5); } CDouble cDouble6 = new CDouble("1000") * value; if (GUI.Button(new Rect(GuiBase.Width(490f), GuiBase.Height(120f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble6.ToGuiText(true))) { this.BuyCount(cDouble6); } CDouble cDouble7 = new CDouble("10000") * value; if (GUI.Button(new Rect(GuiBase.Width(55f), GuiBase.Height(155f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble7.ToGuiText(true))) { this.BuyCount(cDouble7); } CDouble cDouble8 = new CDouble("100000") * value; if (GUI.Button(new Rect(GuiBase.Width(200f), GuiBase.Height(155f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble8.ToGuiText(true))) { this.BuyCount(cDouble8); } CDouble cDouble9 = new CDouble("1000000") * value; if (GUI.Button(new Rect(GuiBase.Width(345f), GuiBase.Height(155f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble9.ToGuiText(true))) { this.BuyCount(cDouble9); } CDouble cDouble10 = new CDouble("10000000") * value; if (GUI.Button(new Rect(GuiBase.Width(490f), GuiBase.Height(155f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble10.ToGuiText(true))) { this.BuyCount(cDouble10); } CDouble cDouble11 = new CDouble("100000000") * value; if (GUI.Button(new Rect(GuiBase.Width(55f), GuiBase.Height(190f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble11.ToGuiText(true))) { this.BuyCount(cDouble11); } CDouble cDouble12 = new CDouble("1000000000") * value; if (GUI.Button(new Rect(GuiBase.Width(200f), GuiBase.Height(190f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble12.ToGuiText(true))) { this.BuyCount(cDouble12); } CDouble cDouble13 = new CDouble("10000000000") * value; if (GUI.Button(new Rect(GuiBase.Width(345f), GuiBase.Height(190f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble13.ToGuiText(true))) { this.BuyCount(cDouble13); } CDouble cDouble14 = new CDouble("100000000000") * value; if (GUI.Button(new Rect(GuiBase.Width(490f), GuiBase.Height(190f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble14.ToGuiText(true))) { this.BuyCount(cDouble14); } CDouble cDouble15 = new CDouble("1000000000000") * value; if (GUI.Button(new Rect(GuiBase.Width(55f), GuiBase.Height(225f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble15.ToGuiText(true))) { this.BuyCount(cDouble15); } CDouble cDouble16 = new CDouble("10000000000000") * value; if (GUI.Button(new Rect(GuiBase.Width(200f), GuiBase.Height(225f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble16.ToGuiText(true))) { this.BuyCount(cDouble16); } CDouble cDouble17 = new CDouble("100000000000000") * value; if (GUI.Button(new Rect(GuiBase.Width(345f), GuiBase.Height(225f), GuiBase.Width(140f), GuiBase.Height(25f)), cDouble17.ToGuiText(true))) { this.BuyCount(cDouble17); } if (GUI.Button(new Rect(GuiBase.Width(490f), GuiBase.Height(225f), GuiBase.Width(140f), GuiBase.Height(25f)), "MAX")) { CDouble buyCost = this.creationToShow.BuyCost; if (buyCost == 0) { return; } CDouble cDouble18 = App.State.Money / this.creationToShow.BuyCost; cDouble18.Value = Math.Floor(cDouble18.Value); this.BuyCount(cDouble18); } GUI.EndGroup(); }