예제 #1
0
        private void Randomize <T>(IList <T> items)
        {
            var sortedItems = new List <T>(items);

            items.Clear();

            for (int i = 0, size = sortedItems.Count; i < size; i++)
            {
                var min       = 0;
                var max       = sortedItems.Count - 1;
                var nextIndex = ModRandom.Next(min, max);
                items.Add(sortedItems[nextIndex]);
                sortedItems.RemoveAt(nextIndex);
            }
        }
예제 #2
0
        private void ForgeNewAttributes(HeroItem newItem, HeroItemDescriptor descriptor)
        {
            var itemLevel = ModRandom.Next(0, 2) + descriptor.Rarity.Level;
            var engine    = new LevelUpEngine(descriptor.Modifiers);

            if (!engine.CanLevelUp())
            {
                return;
            }

            for (var i = 0; i < itemLevel;)
            {
                if (engine.TryToLevelUp())
                {
                    i++;
                }
            }

            descriptor.For(TargetProperty.Cost, x => x.Value += itemLevel * 8);
            descriptor.Add(TargetProperty.SellingCost, Operation.Subtraction, itemLevel * 4);
        }
예제 #3
0
        public bool TryToLevelUp()
        {
            if (!CanLevelUp())
            {
                return(false);
            }
            var nextIndex    = ModRandom.Next(0, enhanceableModifiers.Count - 1);
            var nextModifier = enhanceableModifiers[nextIndex];
            var isPenalty    = nextModifier.IsPenalty();
            var levelUpValue = upgrader.GetNextLevelOf(nextModifier);

            if (isPenalty)
            {
                nextModifier.AddPenalty(levelUpValue);
            }
            else
            {
                nextModifier.AddBonus(levelUpValue);
            }

            return(!isPenalty);
        }