예제 #1
0
        public void InitSubItemCost(int countAdded = 0)
        {
            List <CreationCost> list = new List <CreationCost>();

            foreach (CreationCost current in CreationCost.RequiredCreations(this.TypeEnum, (long)countAdded, false))
            {
                list.AddRange(this.GetCost(current, countAdded));
            }
            this.SubItemCreationCost = new List <CreationCost>();
            using (List <CreationCost> .Enumerator enumerator2 = list.GetEnumerator())
            {
                while (enumerator2.MoveNext())
                {
                    CreationCost cost         = enumerator2.Current;
                    CreationCost creationCost = this.SubItemCreationCost.FirstOrDefault((CreationCost x) => x.TypeEnum == cost.TypeEnum);
                    if (creationCost == null)
                    {
                        this.SubItemCreationCost.Add(cost);
                    }
                    else
                    {
                        creationCost.CountNeeded = cost.CountNeeded;
                    }
                }
            }
            //this.SubItemCreationCost = (from o in this.SubItemCreationCost
            //                            orderby (int)(o.TypeEnum * (Creation.CreationType)(-1))
            //                            select o).ToList<CreationCost>();
        }
예제 #2
0
        private List <CreationCost> GetCost(CreationCost creationCost, int creationCount = 0)
        {
            List <CreationCost> list = new List <CreationCost>();

            try
            {
                if (creationCount == 0 && App.State != null && App.State.GameSettings.CreationToCreateCount > 0)
                {
                    creationCount = App.State.GameSettings.CreationToCreateCount;
                }
                if (creationCount == 0)
                {
                    creationCount = 1;
                }
                foreach (CreationCost current in CreationCost.RequiredCreations(creationCost.TypeEnum, (long)creationCount, false))
                {
                    current.CountNeeded = current.CountNeeded * creationCost.CountNeeded / creationCount;
                    list.Add(current);
                    list.AddRange(this.GetCost(current, 0));
                }
            }
            catch (Exception ex)
            {
            }
            return(list);
        }
예제 #3
0
        public CDouble TotalDuration(GameState state)
        {
            CDouble cDouble = this.DurationInMS;

            using (List <CreationCost> .Enumerator enumerator = CreationCost.RequiredCreations(this.TypeEnum, 1L, false).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    CreationCost cost     = enumerator.Current;
                    Creation     creation = state.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                    if (creation != null)
                    {
                        cDouble += cost.CountNeeded * creation.TotalDuration(state);
                    }
                }
            }
            return(cDouble);
        }
예제 #4
0
        private int CheckCountNeeded()
        {
            if (App.State.GameSettings.CreationToCreateCount > App.State.PremiumBoni.CreationCountBoni(true) + 1)
            {
                App.State.GameSettings.CreationToCreateCount = App.State.PremiumBoni.CreationCountBoni(true).ToInt() + 1;
            }
            CDouble cDouble = App.State.GameSettings.CreationToCreateCount;

            if (App.State.GameSettings.CreationsNextAtMode == 2 && this.NextAtCount > 0 && this.TotalCreated + cDouble >= this.NextAtCount && App.State.GameSettings.LastCreation == this)
            {
                cDouble = this.NextAtCount - this.TotalCreated;
            }
            if (App.State.GameSettings.CreationsNextAtMode == 1 && this.NextAtCount > 0 && this.Count + cDouble >= this.NextAtCount && App.State.GameSettings.LastCreation == this)
            {
                cDouble = this.NextAtCount - this.Count;
            }
            if (App.State.GameSettings.LastCreation != null && App.State.GameSettings.LastCreation != this)
            {
                List <CreationCost> source       = CreationCost.RequiredCreations(App.State.GameSettings.LastCreation.TypeEnum, (long)App.State.GameSettings.LastCreation.CountToAdd.ToInt(), false);
                CreationCost        creationCost = source.FirstOrDefault((CreationCost x) => x.TypeEnum == this.TypeEnum);
                if (creationCost != null)
                {
                    cDouble = creationCost.CountNeeded;
                }
                if (cDouble > App.State.GameSettings.CreationToCreateCount)
                {
                    cDouble = App.State.GameSettings.CreationToCreateCount;
                }
                if (!this.AutoBuy && cDouble < App.State.GameSettings.CreationToCreateCount)
                {
                    cDouble = App.State.GameSettings.CreationToCreateCount;
                }
            }
            if (cDouble <= 0)
            {
                cDouble = 1;
            }
            if (this.TypeEnum == Creation.CreationType.Shadow_clone || this.TypeEnum == Creation.CreationType.Light || this.TypeEnum == Creation.CreationType.Stone)
            {
                cDouble = App.State.PremiumBoni.CreationCountBoni(true) + 1;
            }
            this.CountToAdd = cDouble;
            return(cDouble.ToInt());
        }
예제 #5
0
        public void UpdateDuration(long ms)
        {
            if (App.State == null)
            {
                return;
            }
            if (!this.GodToDefeat.IsDefeated)
            {
                this.GodToDefeat.RecoverHealth(ms);
            }
            if (!this.IsActive)
            {
                return;
            }
            if (!this.GodToDefeat.IsDefeated)
            {
                this.FightGod(ms);
                if (this.GodToDefeat.IsDefeated)
                {
                    this.description = string.Empty;
                }
                return;
            }
            bool flag = this.NextAtCount != 0 && this.NextAtCount <= this.Count;

            if (App.State.GameSettings.CreationsNextAtMode == 2)
            {
                flag = (this.NextAtCount != 0 && this.NextAtCount <= this.TotalCreated);
            }
            if ((App.State.GameSettings.LastCreation != null && App.State.GameSettings.LastCreation.TypeEnum != this.TypeEnum) || App.State.GameSettings.CreationsNextAtMode == 0)
            {
                flag = false;
            }
            if (flag && this.TypeEnum != Creation.CreationType.Shadow_clone)
            {
                foreach (Creation current in App.State.AllCreations)
                {
                    current.IsActive = false;
                }
                Creation lastCreation = this;
                Creation creation     = App.State.AllCreations.First((Creation x) => x.TypeEnum == Creation.CreationType.Shadow_clone);
                if (this.TypeEnum == Creation.CreationType.Universe)
                {
                    lastCreation      = creation;
                    creation.IsActive = true;
                }
                else
                {
                    Creation creation2 = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == this.TypeEnum + 1);
                    if (creation2 != null && creation2.GodToDefeat.IsDefeated)
                    {
                        lastCreation       = creation2;
                        creation2.IsActive = true;
                    }
                    else
                    {
                        bool flag2 = false;
                        foreach (Creation current2 in App.State.AllCreations)
                        {
                            if (current2.GodToDefeat.IsDefeated && current2.NextAtCount == 0 && current2.TypeEnum != Creation.CreationType.Shadow_clone)
                            {
                                lastCreation      = current2;
                                current2.IsActive = true;
                                flag2             = true;
                                break;
                            }
                        }
                        if (!flag2)
                        {
                            lastCreation      = creation;
                            creation.IsActive = true;
                        }
                    }
                }
                App.State.GameSettings.LastCreation = lastCreation;
                return;
            }
            if (App.State.GameSettings.CreateShadowClonesIfNotMax && App.State.Clones.Count < App.State.Clones.MaxShadowClones && this.TypeEnum != Creation.CreationType.Shadow_clone)
            {
                this.oldActiveCreation = this;
                Creation creation3 = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == Creation.CreationType.Shadow_clone);
                creation3.IsActive = true;
                return;
            }
            if (this.oldActiveCreation != null)
            {
                this.IsActive = false;
                this.oldActiveCreation.IsActive = true;
                this.oldActiveCreation          = null;
            }
            int num = this.CheckCountNeeded();
            List <CreationCost> list = CreationCost.RequiredCreations(this.TypeEnum, (long)num, false);

            if (this.CheckPrerequesiteCost(list))
            {
                return;
            }
            this.currentDuration += App.State.CreationSpeed(ms);
            long durationInMS = this.DurationInMS;

            if (this.currentDuration > durationInMS)
            {
                this.currentDuration -= durationInMS;
                if (this.currentDuration > durationInMS)
                {
                    this.currentDuration = durationInMS;
                }
                using (List <CreationCost> .Enumerator enumerator3 = list.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        CreationCost cost      = enumerator3.Current;
                        Creation     creation4 = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == cost.TypeEnum);
                        creation4.Count -= cost.CountNeeded;
                    }
                }
                CDouble rightSide = this.CreatingPowerGain() * (100 + (num - 1) * 5) / 100;
                App.State.CreatingPowerBase += rightSide;
                this.CanBuy        = true;
                this.Count        += num;
                this.TotalCreated += num;
                App.State.CheckForAchievement(this);
                if (this.TypeEnum != Creation.CreationType.Shadow_clone)
                {
                    App.State.Statistic.TotalCreations += num;
                }
                this.FinishUUC(App.State);
                if (App.State.GameSettings.LastCreation != null && App.State.GameSettings.LastCreation.TypeEnum != this.TypeEnum)
                {
                    Creation creation5 = App.State.AllCreations.FirstOrDefault((Creation x) => x.TypeEnum == App.State.GameSettings.LastCreation.TypeEnum);
                    this.IsActive      = false;
                    creation5.IsActive = true;
                }
            }
        }