Ejemplo n.º 1
0
    public void clicked()
    {
        UIBase uiBase = UIBase.instance;

        if (uiBase && uiBase.openSkillTrees.Count > 0)
        {
            SkillTree  openSkillTree = uiBase.openSkillTrees[0];
            GameObject player        = PlayerFinder.getPlayer();
            if (openSkillTree && player && player.GetComponent <SpecialisedAbilityList>())
            {
                // de-allocate all the nodes
                foreach (SkillTreeNode node in SkillTreeNode.all)
                {
                    if (node.tree == openSkillTree)
                    {
                        node.pointsAllocated = 0;
                        node.updateText();
                    }
                }
                // set unspent points to 1
                openSkillTree.unspentPoints = 1;
                // update the mutator now that the points are de-allocated
                openSkillTree.updateMutator();
                // despecialise the ability
                player.GetComponent <SpecialisedAbilityList>().DespecialiseAbility(openSkillTree.ability);
                // play a sound
                UISounds.playSound(UISounds.UISoundLabel.Despecialise);
                // update tooltip mana costs
                AbilityTooltip.updateManaCosts(openSkillTree.ability);
            }
            uiBase.closeSkillTrees();
            uiBase.closeSpecialisationSelection();
        }
    }
Ejemplo n.º 2
0
    public void Clicked()
    {
        // return if the player has not specialised in this ability
        SkillTree skillTree = tree as SkillTree;

        if (skillTree)
        {
            if (!PlayerFinder.getPlayer().GetComponent <SpecialisedAbilityList>().abilities.Contains(skillTree.ability))
            {
                return;
            }
        }

        // check if there is a spare point and this is not at max points
        if ((nodeType == nodeRequirementType.axis && tree.unspentAxisPoints > 0) || (nodeType == nodeRequirementType.node && tree.unspentPoints > 0))
        {
            if (pointsAllocated < maxPoints || maxPoints < 0)
            {
                // if the requirements are met then allocate the point
                if (requirementsMet())
                {
                    pointsAllocated++;
                    if (nodeType == nodeRequirementType.node)
                    {
                        tree.unspentPoints--;
                    }
                    if (nodeType == nodeRequirementType.axis)
                    {
                        tree.unspentAxisPoints--;
                    }
                    tree.updateMutator();
                    updateText();
                    // play a sound
                    UISounds.playSound(UISounds.UISoundLabel.AllocateNode);
                    // update mana costs on tooltips
                    SkillTree st = tree as SkillTree;
                    if (st && st.ability)
                    {
                        AbilityTooltip.updateManaCosts(st.ability);
                    }
                    // update the node progression (for respeccing)
                    if (tree as CharacterTree)
                    {
                        SkillSavingManager.instance.pushToNodePogression(nodeID);
                    }
                }
            }
        }

        // save
        SkillSavingManager.instance.saveNodeData(this);
        PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
    }