コード例 #1
0
    public static UtilityAbility ScaleUtilityAbility(float points, float cooldown, float mp, float baseMp, string targetType, List <AbilityAttribute> abilityAttributes, AbilitySkillTree skillTree)
    {
        var startingPoints = points;
        var newAbility     = new UtilityAbility {
            points      = points,
            cooldown    = cooldown,
            mpUsage     = mp,
            baseMpUsage = baseMp,
            targetType  = targetType,
            level       = AbilityCalculator.GetLevelFromPoints(startingPoints),
            skillTree   = skillTree
        };

        ModifyUtilityAbilityPointsForQualities(newAbility);
        foreach (var attribute in abilityAttributes)
        {
            var pointCost = AbilityAttributeAppraiser.Appraise(newAbility, attribute);
            points -= pointCost;
            if (points >= 0)
            {
                newAbility.attributes.Add(attribute);
                newAbility.points -= pointCost;
            }
            else
            {
                points += pointCost;
            }
        }
        newAbility.name        = AbilityNamer.Name(newAbility);
        newAbility.description = AbilityDescriber.Describe(newAbility);
        newAbility.xp          = GetXpFromLevel(newAbility.level);
        SetMpUsage(newAbility);
        return(newAbility);
    }
コード例 #2
0
    void Start()
    {
        var data = TextReader.ReadSets("DotSpellEffects");

        foreach (var item in data)
        {
            dotSpellEffects.Add(AbilityCalculator.StringToElement(item[0]), int.Parse(item[1]));
        }
    }
コード例 #3
0
        public void CheckSimpleDamageIncreaseWithAttribute()
        {
            var output = AbilityScaler.ScaleAttackAbility(AbilityCalculator.GetPointsFromLevel(2), Element.bashing, BaseStat.strength, 0.3f, 0, 0, true, 0, 0, 0, 0, 0, 0, 0, 0, new List <AbilityAttribute> {
                new AbilityAttribute {
                    type     = "projectileSpread",
                    priority = 100
                }
            }, new AbilitySkillTree());

            Assert.Greater(output.damage, 0.3f);
        }
コード例 #4
0
    private static float GetPoints(ActiveAbility ability1, ActiveAbility ability2)
    {
        var points1    = AbilityCalculator.GetPointsFromLevel(ability1.level);
        var points2    = AbilityCalculator.GetPointsFromLevel(ability2.level);
        var calcPoints = (points1 + points2) / 2;

        calcPoints *= Mathf.Pow(1.04f, 3f);
        var maxPoints = AbilityCalculator.GetPointsFromLevel(PlayerCharacter.localPlayer.GetComponent <ExperienceGainer>().level);

        return(Mathf.Min(calcPoints, maxPoints));
    }
コード例 #5
0
        public void CheckDamageIncreaseWithPositiveAndNegativeAttribute()
        {
            var output = AbilityScaler.ScaleAttackAbility(AbilityCalculator.GetPointsFromLevel(2), Element.bashing, BaseStat.strength, 0.75f, 0, 0, true, 0, 0, 0, 0, 0, 0, 0, 0, new List <AbilityAttribute> {
                new AbilityAttribute {
                    type     = "offGCD",
                    priority = 100
                },
                new AbilityAttribute {
                    type     = "delay",
                    priority = 100
                }
            }, new AbilitySkillTree());

            Assert.Greater(output.damage, 0.75f);
        }
コード例 #6
0
    protected override void LevelUp(int originalLevel, int targetLevel)
    {
        LevelUp(targetLevel - originalLevel);
        float targetPoints = AbilityCalculator.GetPointsFromLevel(targetLevel);

        AbilityScaler.RemoveSkillTreeEnhancements(this);
        var newAbility = AbilityScaler.ScaleUtilityAbility(targetPoints, cooldown, mpUsage, baseMpUsage, targetType, attributes, skillTree);

        level       = targetLevel;
        points      = targetPoints;
        mpUsage     = newAbility.mpUsage;
        baseMpUsage = newAbility.baseMpUsage;
        attributes  = newAbility.attributes;
        AbilityScaler.AddSkillTreeEnhancements(this);
        description = AbilityDescriber.Describe(this);
    }
コード例 #7
0
    protected override void LevelUp(int originalLevel, int targetLevel)
    {
        LevelUp(targetLevel - originalLevel);
        float targetPoints = AbilityCalculator.GetPointsFromLevel(targetLevel);

        AbilityScaler.RemoveSkillTreeEnhancements(this);
        var newAbility = AbilityScaler.ScaleAttackAbility((int)targetPoints, element, baseStat, damage, dotDamage, dotTime, isRanged, cooldown, mpUsage, baseMpUsage, radius, icon, hitEffect, rangedProjectile, aoe, attributes, skillTree);

        level       = targetLevel;
        points      = targetPoints;
        damage      = newAbility.damage;
        dotDamage   = newAbility.dotDamage;
        mpUsage     = newAbility.mpUsage;
        baseMpUsage = newAbility.baseMpUsage;
        attributes  = newAbility.attributes;
        AbilityScaler.AddSkillTreeEnhancements(this);
        description = AbilityDescriber.Describe(this);
    }
コード例 #8
0
    static ElementalAffinity()
    {
        var data = TextReader.ReadSets("ElementalAlliances");

        foreach (var item in data)
        {
            var list = new List <Element>();
            for (int i = 1; i < item.Length; i++)
            {
                list.Add(AbilityCalculator.StringToElement(item[i]));
            }
            alliances.Add(AbilityCalculator.StringToElement(item[0]), list);
        }
        data = TextReader.ReadSets("ElementalEnemies");
        foreach (var item in data)
        {
            enemies.Add(AbilityCalculator.StringToElement(item[0]), AbilityCalculator.StringToElement(item[1]));
        }
    }
コード例 #9
0
 public static PassiveAbility Generate(int level = 1)
 {
     for (int i = 0; i < 10000; i++)
     {
         var startingPoints = AbilityCalculator.GetPointsFromLevel(level);
         int numAttributes  = RNG.Int(1, 5);
         var ability        = new PassiveAbility {
             points = startingPoints,
             level  = level
         };
         for (int j = 0; j < numAttributes; j++)
         {
             for (int k = 0; k < 10000; k++)
             {
                 var attribute = AbilityAttributeGenerator.Generate(ability);
                 if (attribute != null && attribute.points <= ability.points)
                 {
                     ability.attributes.Add(attribute);
                     ability.points -= attribute.points;
                     break;
                 }
             }
         }
         ability.points = startingPoints;
         ability.SortAttributes();
         ability.icon        = AbilityIconSelector.Select(ability);
         ability.name        = AbilityNamer.Name(ability);
         ability.description = AbilityDescriber.Describe(ability);
         if (ability.IsValid())
         {
             ability.skillTree = new AbilitySkillTree(ability);
             return(ability);
         }
     }
     return(null);
 }
コード例 #10
0
    public static AttackAbility ScaleAttackAbility(float points, Element element, BaseStat baseStat, float damageRatio, float dotDamageRatio, float dotTime, bool isRanged, float cooldown, float mp, float baseMp, float radius, int icon, int hitEffect, int projectile, int aoe, List <AbilityAttribute> abilityAttributes, AbilitySkillTree skillTree)
    {
        var startingPoints = points;
        List <AbilityAttribute> paralysis = new List <AbilityAttribute>();

        foreach (var attribute in abilityAttributes)
        {
            if (attribute.type == "paralyze")
            {
                paralysis.Add(attribute);
            }
        }
        if (paralysis.Count > 0 && cooldown == 0)
        {
            foreach (var attribute in paralysis)
            {
                abilityAttributes.Remove(attribute);
            }
        }
        var newAbility = new AttackAbility {
            element          = element,
            baseStat         = baseStat,
            dotTime          = dotTime,
            isRanged         = isRanged,
            cooldown         = cooldown,
            mpUsage          = mp,
            baseMpUsage      = baseMp,
            radius           = radius,
            points           = points,
            icon             = icon,
            hitEffect        = hitEffect,
            rangedProjectile = projectile,
            aoe       = aoe,
            level     = AbilityCalculator.GetLevelFromPoints(startingPoints),
            skillTree = skillTree
        };

        ModifyAttackAbilityPointsForQualities(newAbility);
        points = newAbility.points;
        int count = 0;

        foreach (var attribute in abilityAttributes)
        {
            if (attribute.priority >= 50)
            {
                var pointCost = AbilityAttributeAppraiser.Appraise(newAbility, attribute);
                if (count < 4)
                {
                    points -= pointCost;
                }
                if (count < 4 && points >= 0)
                {
                    newAbility.attributes.Add(attribute);
                    newAbility.points -= pointCost;
                }
                else if (count < 4 && points < 0)
                {
                    points += pointCost;
                }
                count++;
            }
            else
            {
                newAbility.attributes.Add(attribute);
            }
        }
        var totalDamage   = AttackAbilityGenerator.CalculateDamage(points);
        var regularDamage = totalDamage * damageRatio / (damageRatio + dotDamageRatio);
        var dotDamage     = totalDamage * dotDamageRatio / (damageRatio + dotDamageRatio);

        newAbility.damage      = regularDamage;
        newAbility.dotDamage   = dotDamage;
        newAbility.name        = AbilityNamer.Name(newAbility);
        newAbility.description = AbilityDescriber.Describe(newAbility);
        newAbility.xp          = GetXpFromLevel(newAbility.level);
        SetMpUsage(newAbility);
        return(newAbility);
    }
コード例 #11
0
 public static UtilityAbility Generate(int level = 1)
 {
     for (int i = 0; i < 10000; i++)
     {
         var  startingPoints = AbilityCalculator.GetPointsFromLevel(level);
         var  usesMpRoll     = RNG.Int(0, 3);
         bool usesMp         = false;
         if (usesMpRoll < 2)
         {
             usesMp = true;
         }
         int mp, baseMp;
         if (!usesMp)
         {
             baseMp = 0;
         }
         else
         {
             var mpResults = AbilityCalculator.GetBaseMpCostAndPointsMod();
             baseMp          = mpResults.Item1;
             startingPoints *= mpResults.Item2;
         }
         mp = AbilityCalculator.ScaleMp(baseMp, level);
         var baseStat        = RNG.EnumValue <BaseStat>();
         int numAttributes   = RNG.Int(1, 5);
         var cooldownResults = AbilityCalculator.GetCooldownAndPointsMod();
         var cooldown        = cooldownResults.Item1;
         startingPoints *= cooldownResults.Item2;
         var targetType = RNG.List(new List <string> {
             "player",
             "none",
             "point"
         });
         var ability = new UtilityAbility {
             baseStat    = baseStat,
             cooldown    = cooldown,
             mpUsage     = mp,
             baseMpUsage = baseMp,
             points      = startingPoints,
             level       = level,
             targetType  = targetType
         };
         for (int j = 0; j < numAttributes; j++)
         {
             for (int k = 0; k < 10000; k++)
             {
                 var attribute = AbilityAttributeGenerator.Generate(ability);
                 if (attribute != null && attribute.points <= ability.points)
                 {
                     ability.attributes.Add(attribute);
                     ability.points -= attribute.points;
                     break;
                 }
             }
         }
         ability.points = startingPoints;
         ability.SortAttributes();
         ability.icon        = AbilityIconSelector.Select(ability);
         ability.name        = AbilityNamer.Name(ability);
         ability.description = AbilityDescriber.Describe(ability);
         if (ability.IsValid())
         {
             ability.skillTree = new AbilitySkillTree(ability);
             return(ability);
         }
     }
     return(null);
 }
コード例 #12
0
        public void CheckSimpleLevelIncrease()
        {
            var output = AbilityScaler.ScaleAttackAbility(AbilityCalculator.GetPointsFromLevel(2), Element.bashing, BaseStat.strength, 1, 0, 0, true, 0, 0, 0, 0, 0, 0, 0, 0, new List <AbilityAttribute>(), new AbilitySkillTree());

            Assert.AreEqual(output.level, 2);
        }
コード例 #13
0
    public static AttackAbility Generate(int level = 1, Element element = Element.none)
    {
        for (int i = 0; i < 10000; i++)
        {
            var startingPoints = AbilityCalculator.GetPointsFromLevel(level);
            var isRanged       = RNG.Bool();
            var usesMp         = RNG.Bool();
            var statResults    = GetBaseStatAndPointsMod(isRanged, usesMp);
            var baseStat       = statResults.Item1;
            startingPoints *= statResults.Item2;
            int mp, baseMp;
            if (!usesMp)
            {
                baseMp = 0;
            }
            else
            {
                var mpResult = AbilityCalculator.GetBaseMpCostAndPointsMod();
                baseMp          = mpResult.Item1;
                startingPoints *= mpResult.Item2;
            }
            mp = AbilityCalculator.ScaleMp(baseMp, level);
            if (element == Element.none)
            {
                element = RNG.EnumValue <Element>();
            }
            int hitEffect = 0, projectile = 0;
            if (isRanged)
            {
                projectile = AbilityTables.baseProjectiles[element];
            }
            else
            {
                hitEffect = AbilityTables.baseHitEffects[element];
            }
            var   radiusResults = GetRadiusAndPointsMod();
            float radius        = radiusResults.Item1;
            startingPoints *= radiusResults.Item2;
            int aoe = 0;
            if (radius > 0)
            {
                aoe = AbilityTables.baseAoes[element];
            }
            var dotResults = GetDotStatusAndTimeAndPointsMod();
            var isDot      = dotResults.Item1;
            var dotTime    = dotResults.Item2;
            startingPoints *= dotResults.Item3;
            int numAttributes   = RNG.Int(0, 6);
            var cooldownResults = AbilityCalculator.GetCooldownAndPointsMod();
            var cooldown        = cooldownResults.Item1;
            startingPoints *= cooldownResults.Item2;
            var ability = new AttackAbility {
                element          = element,
                baseStat         = baseStat,
                dotTime          = dotTime,
                isRanged         = isRanged,
                cooldown         = cooldown,
                mpUsage          = mp,
                baseMpUsage      = baseMp,
                radius           = radius,
                hitEffect        = hitEffect,
                rangedProjectile = projectile,
                aoe       = aoe,
                points    = startingPoints,
                level     = level,
                damage    = 0,
                dotDamage = 0
            };
            int count = 0;
            for (int j = 0; j < numAttributes; j++)
            {
                for (int k = 0; k < 10000; k++)
                {
                    count = 0;
                    var attribute = AbilityAttributeGenerator.Generate(ability);
                    if (attribute != null && attribute.points <= ability.points)
                    {
                        ability.attributes.Add(attribute);
                        if (attribute.priority >= 50 && count < 4)
                        {
                            ability.points -= attribute.points;
                            count++;
                        }
                        if (attribute.priority >= 50 && count < 4 && attribute.type == "createDamageZone")
                        {
                            ability.aoe = AbilityTables.baseDamageZones[element];
                        }
                        break;
                    }
                }
            }

            // sort the abilities added and make sure they are processed in the order they will always be processed on future level ups, so that attributes dependent on order for cost will resolve correctly
            ability.SortAttributes();
            ability.points = startingPoints;
            count          = 0;
            foreach (var attribute in ability.attributes)
            {
                if (attribute.priority >= 50)
                {
                    var pointCost = AbilityAttributeAppraiser.Appraise(ability, attribute);
                    if (count < 4)
                    {
                        ability.points -= pointCost;
                    }
                    if (ability.points <= 0)
                    {
                        ability.attributes.Remove(attribute);
                        ability.points += pointCost;
                    }
                    count++;
                }
            }

            var damage = CalculateDamage(ability.points);
            if (isDot)
            {
                ability.dotDamage = damage;
            }
            else
            {
                ability.damage = damage;
            }
            ability.points = AbilityCalculator.GetPointsFromLevel(level);
            ability.SortAttributes();
            ability.icon        = AbilityIconSelector.Select(ability);
            ability.name        = AbilityNamer.Name(ability);
            ability.description = AbilityDescriber.Describe(ability);
            if (ability.IsValid())
            {
                ability.skillTree = new AbilitySkillTree(ability);
                return(ability);
            }
        }
        return(null);
    }