示例#1
0
        public ShieldItem GenerateShield(ItemRareness rareness)
        {
            var config = RandomHelper.GetRandomElement(
                configuration.SmallShieldConfiguration,
                configuration.MediumShieldConfiguration, 
                configuration.BigShieldConfiguration);

            var rarenessConfig = GetRarenessConfiguration(config, rareness);
            var material = RandomHelper.GetRandomElement(rarenessConfig.Materials);
            var name = GenerateName(material, config.Name);
            var inventoryImage = GenerateInventoryImage(config, material);
            var worldImage = GetMaterialColoredImage(config.WorldImage, material);
            var equippedImageRight = GetMaterialColoredImage(config.EquippedImageRight, material);
            var equippedImageLeft = GetMaterialColoredImage(config.EquippedImageLeft, material);
            var bonusesCount = GetIntervalRandomValue(rarenessConfig.Bonuses);
            var weightConfiguration = GetWeightConfiguration(config, material);
            var maxDurability = weightConfiguration.Durability;
            var blocksDamage = GetIntervalRandomValue(rarenessConfig.BlocksDamage);
            var protectChance = GetIntervalRandomValue(rarenessConfig.ProtectChance);
            var hitChancePenalty = - GetIntervalRandomValue(rarenessConfig.HitChancePenalty); // Negative value
            var description = GenerateDescription(rareness, material);

            var itemConfig = new ShieldItemConfiguration
            {
                Name = name,
                Key = Guid.NewGuid().ToString(),
                Rareness = rareness,
                InventoryImage = inventoryImage,
                WorldImage = worldImage,
                EquippedImageRight = equippedImageRight,
                EquippedImageLeft = equippedImageLeft,
                Weight = weightConfiguration.Weight,
                MaxDurability = maxDurability,
                BlocksDamage = blocksDamage,
                ProtectChance = protectChance,
                HitChancePenalty = hitChancePenalty,
                Description = description
            };
            bonusesGenerator.GenerateBonuses(itemConfig, bonusesCount);

            var durabilityPercent = RandomHelper.GetRandomValue(MinDurabilityPercent, MaxDurabilityPercent);
            var durability = Math.Min(itemConfig.MaxDurability, (int)Math.Round(itemConfig.MaxDurability * (durabilityPercent / 100d)));
            itemConfig.Durability = durability;

            return new ShieldItem(itemConfig);
        }
示例#2
0
        public WeaponItem GenerateWeapon(ItemRareness rareness)
        {
            var rarenessConfiguration = GetRarenessConfiguration(rareness);
            var material            = RandomHelper.GetRandomElement(rarenessConfiguration.Materials);
            var inventoryImage      = GenerateImage(material);
            var worldImage          = GetMaterialColoredImage(worldImageName, material);
            var equippedRightImage  = GetMaterialColoredImage(configuration.EquippedImageRight, material);
            var equippedLeftImage   = GetMaterialColoredImage(configuration.EquippedImageLeft, material);
            var maxDamage           = GenerateMaxDamage(rarenessConfiguration);
            var minDamage           = maxDamage.ToDictionary(pair => pair.Key, pair => pair.Value - rarenessConfiguration.MinMaxDamageDifference);
            var hitChance           = RandomHelper.GetRandomValue(rarenessConfiguration.MinHitChance, rarenessConfiguration.MaxHitChance);
            var weightConfiguration = GetWeightConfiguration(material);
            var name          = GenerateName(material);
            var description   = GenerateDescription(rareness, material);
            var bonusesCount  = RandomHelper.GetRandomValue(rarenessConfiguration.MinBonuses, rarenessConfiguration.MaxBonuses);
            var maxDurability = weightConfiguration.Durability;

            var itemConfig = new WeaponItemConfiguration
            {
                Name               = name,
                Key                = Guid.NewGuid().ToString(),
                Description        = description,
                Rareness           = rareness,
                Weight             = weightConfiguration.Weight,
                MaxDamage          = maxDamage,
                MinDamage          = minDamage,
                HitChance          = hitChance,
                InventoryImage     = inventoryImage,
                WorldImage         = worldImage,
                EquippedImageRight = equippedRightImage,
                EquippedImageLeft  = equippedLeftImage,
                MaxDurability      = maxDurability
            };

            bonusesGenerator.GenerateBonuses(itemConfig, bonusesCount);

            var durabilityPercent = RandomHelper.GetRandomValue(MinDurabilityPercent, MaxDurabilityPercent);
            var durability        = Math.Min(itemConfig.MaxDurability, (int)Math.Round(itemConfig.MaxDurability * (durabilityPercent / 100d)));

            itemConfig.Durability = durability;

            return(new WeaponItem(itemConfig));
        }
示例#3
0
        public ArmorItem GenerateArmor(ItemRareness rareness, ArmorClass armorClass)
        {
            var armorType      = GenerateArmorType();
            var config         = GetSpecificConfiguration(armorType, armorClass);
            var rarenessConfig = GetRarenessConfiguration(config, rareness);
            var material       = RandomHelper.GetRandomElement(rarenessConfig.Materials);
            var inventoryImage = GetArmorImage(config, material);
            var worldImage     = GetWorldImage(material, armorType);
            var equippedImage  = GetEquippedImage(material, config);
            var protection     = GenerateProtection(rarenessConfig.Protection);
            var name           = GenerateName(material, config.TypeName, armorType);
            var description    = GenerateDescription(rareness, material);
            var weightConfig   = GetWeightConfiguration(config, material);
            var maxDurability  = weightConfig.Durability;
            var bonusesCount   = RandomHelper.GetRandomValue(rarenessConfig.MinBonuses, rarenessConfig.MaxBonuses);

            var itemConfig = new ArmorItemConfiguration
            {
                Name           = name,
                Key            = Guid.NewGuid().ToString(),
                ArmorType      = armorType,
                Description    = description,
                InventoryImage = inventoryImage,
                WorldImage     = worldImage,
                EquippedImage  = equippedImage,
                Protection     = protection,
                Rareness       = rareness,
                Weight         = weightConfig.Weight,
                MaxDurability  = maxDurability
            };

            bonusesGenerator.GenerateBonuses(itemConfig, bonusesCount);

            var durabilityPercent = RandomHelper.GetRandomValue(MinDurabilityPercent, MaxDurabilityPercent);
            var durability        = Math.Min(itemConfig.MaxDurability, (int)Math.Round(itemConfig.MaxDurability * (durabilityPercent / 100d)));

            itemConfig.Durability = durability;

            return(new ArmorItem(itemConfig));
        }
示例#4
0
        public SpellBook GenerateSpellBook(ItemRareness rareness)
        {
            var config         = GetConfiguration(rareness);
            var spellsCount    = RandomHelper.GetRandomValue(config.MinSpells, config.MaxSpells);
            var bonusesCount   = RandomHelper.GetRandomValue(config.MinBonuses, config.MaxBonuses);
            var inventoryImage = GenerateImage(out var mainColor);
            var worldImage     = GetWorldImage(mainColor);

            var itemConfig = new SpellBookConfiguration
            {
                Name           = DefaultName,
                Key            = Guid.NewGuid().ToString(),
                Description    = GenerateDescription(config),
                Size           = spellsCount,
                InventoryImage = inventoryImage,
                WorldImage     = worldImage,
                Weight         = configuration.Weight,
                Rareness       = rareness
            };

            bonusesGenerator.GenerateBonuses(itemConfig, bonusesCount);

            return(new SpellBook(itemConfig));
        }