Beispiel #1
0
 private void ReconstructNodesByLayer(AbilitySkillTree ast)
 {
     foreach (var item in ast.baseNodes)
     {
         ReconstructNode(ast, item, 0);
     }
 }
 public void Initialize(AbilitySkillTree skillTree)
 {
     foreach (Transform child in transform)
     {
         Destroy(child.gameObject);
     }
     this.skillTree = skillTree;
     initialized    = false;
 }
 private void GenerateLines(AbilitySkillTree skillTree)
 {
     foreach (var node in skillTree.baseNodes)
     {
         foreach (var child in node.children)
         {
             DrawLinesForNode(node, child);
         }
     }
 }
Beispiel #4
0
    public AbilitySkillTree ConvertTo()
    {
        var ast = new AbilitySkillTree();

        foreach (var item in nodes)
        {
            ast.baseNodes.Add(item.ConvertTo());
        }
        ReconstructNodesByLayer(ast);
        return(ast);
    }
Beispiel #5
0
 private void ReconstructNode(AbilitySkillTree ast, AbilitySkillTreeNode node, int depth)
 {
     if (ast.nodesByLayer.Count < depth + 1)
     {
         ast.nodesByLayer.Add(new List <AbilitySkillTreeNode>());
     }
     ast.nodesByLayer[depth].Add(node);
     foreach (var child in node.children)
     {
         ReconstructNode(ast, child, depth + 1);
     }
 }
Beispiel #6
0
    public static SavedSkillTree ConvertFrom(AbilitySkillTree skillTree)
    {
        var nodes = new List <SavedSkillTreeNode>();

        foreach (var item in skillTree.baseNodes)
        {
            nodes.Add(SavedSkillTreeNode.ConvertFrom(item));
        }
        return(new SavedSkillTree {
            nodes = nodes
        });
    }
 private void GenerateIcons(AbilitySkillTree skillTree)
 {
     foreach (var line in skillTree.nodesByLayer)
     {
         foreach (var icon in line)
         {
             var node = Instantiate(nodePrefab);
             node.transform.SetParent(transform);
             node.GetComponent <RectTransform>().localPosition = icon.position;
             node.GetComponent <RectTransform>().anchorMin    -= new Vector2(0.5f, 0.5f);
             node.GetComponent <RectTransform>().anchorMax    -= new Vector2(0.5f, 0.5f);
             node.GetComponent <SkillTreeNodeRenderer>().Initialize(icon);
         }
     }
 }
    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);
    }
    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);
    }