void OnEnable()
    {
        // get a list of the player's known abilities and specialised abilities
        GameObject player = PlayerFinder.getPlayer();

        if (player != null)
        {
            List <Ability> playerAbilities      = player.GetComponent <KnownAbilityList> ().abilities;
            List <Ability> specialisedAbilities = player.GetComponent <SpecialisedAbilityList> ().abilities;

            // get a list of the abilities with skill trees
            List <Ability> abilitiesWithTrees = new List <Ability> ();

            foreach (SkillTree skillTree in SkillTree.all)
            {
                if (skillTree.ability != null && !abilitiesWithTrees.Contains(skillTree.ability))
                {
                    abilitiesWithTrees.Add(skillTree.ability);
                }
            }

            // instantiate an ability icon for each ability in the player's known ability list that is also in the abilities with trees list and is not already specialised
            foreach (Ability abilitiy in playerAbilities)
            {
                if (abilitiesWithTrees.Contains(abilitiy) && !specialisedAbilities.Contains(abilitiy))
                {
                    GameObject abilityIcon = Instantiate(abilityIconPrefab, transform);
                    abilityIcon.GetComponent <SpecialisationSelectionIcon> ().ability = abilitiy;
                }
            }
        }
    }
Example #2
0
 // Use this for initialization
 void Start()
 {
     player = PlayerFinder.getPlayer();
     PlayerFinder.playerChangedEvent += ChangePlayer;
     if (player != null)
     {
         playerMana    = player.GetComponent <BaseMana> ();
         playerCharges = player.GetComponent <ChargeManager> ();
     }
     tooltipAbility = GetComponent <AbilityTooltip> ();
     foreach (UIBarWithMaterial bar in GetComponentsInChildren <UIBarWithMaterial>())
     {
         //if (bar.name == "CooldownBar") { bar.currentFill = bar.maxFill; }
         //else
         if (bar.name == "OutOfMana")
         {
             outOfMana = bar;
         }
     }
     foreach (Image im in GetComponentsInChildren <Image>())
     {
         if (im.name == "Sprite")
         {
             icon = im;
         }
         if (im.name == "CooldownBar")
         {
             cooldownBar = im;
         }
     }
 }
    public void removeNodeFromPogression(string nodeID)
    {
        CharacterData data = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        data.characterTreeNodeProgression.RemoveAll(x => x == nodeID);
        PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
    }
    public void pushToNodePogression(string nodeID)
    {
        CharacterData data = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        data.characterTreeNodeProgression.Add(nodeID);
        PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
    }
    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();
        }
    }
Example #6
0
 public void OnUse()
 {
     if (PlayerFinder.getPlayer())
     {
         PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData.portalUnlocked = true;
     }
 }
Example #7
0
 public void respecOnePoint(bool updateMutator = true)
 {
     if (pointsAllocated > 0)
     {
         if (nodeType == nodeRequirementType.node)
         {
             tree.unspentPoints += 1;
         }
         else if (nodeType == nodeRequirementType.axis)
         {
             tree.unspentAxisPoints += 1;
         }
         pointsAllocated--;
         if (updateMutator)
         {
             tree.updateMutator();
         }
         updateText();
         // save
         if (tree as CharacterTree)
         {
             SkillSavingManager.instance.PopNodeProgression(nodeID);
         }
         SkillSavingManager.instance.saveNodeData(this);
         PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
     }
 }
Example #8
0
 // Use this for initialization
 void Start()
 {
     tooltipAbility = gameObject.GetComponent <AbilityTooltip> ();
     player         = PlayerFinder.getPlayer();
     PlayerFinder.playerChangedEvent += ChangePlayer;
     if (player != null)
     {
         foreach (Transform child in transform)
         {
             if (child.name == "Sprite" && child.GetComponent <Image> ())
             {
                 icon        = child.GetComponent <Image> ();
                 icon.sprite = ability.abilitySprite;
             }
             else if (child.name == "Frame")
             {
             }
             else if (child.name == "Description")
             {
                 child.GetComponent <TextMeshProUGUI> ().text = ability.description;
             }
             else if (child.name == "SkillName")
             {
                 child.GetComponent <TextMeshProUGUI> ().text = ability.abilityName;
             }
             else if (child.name == "LevelRequirement")
             {
                 child.GetComponent <TextMeshProUGUI>().text = "" + levelRequirement;
             }
         }
     }
 }
    public void levelUpAbility(int abilityNumber)
    {
        abilityLevels[abilityNumber]++;
        bool skillPanelOpen = UIBase.instance.skillsOpen;

        if (!skillPanelOpen)
        {
            UIBase.instance.openSkills();
        }
        foreach (SkillTree skillTree in SkillTree.all)
        {
            if (skillTree.ability == abilities[abilityNumber])
            {
                skillTree.unspentPoints++;
                SkillSavingManager.instance.saveUnspentPoints(skillTree);
            }
        }
        if (!skillPanelOpen)
        {
            UIBase.instance.closeSkills();
        }
        // activate the level up button if this is the local player
        if (gameObject == PlayerFinder.getPlayer())
        {
            levelUpButton.addAbilityButton(abilities[abilityNumber]);
        }
    }
Example #10
0
    // Use this for initialization
    void Start()
    {
        pathFinder = this.GetComponent <AStar> ();

        health = transform.GetComponent <Health> ();
        AI     = transform.GetComponent <Player> ();
        AI.setIsAI(true);

        playerFinder = transform.GetComponent <PlayerFinder> ();
        player       = playerFinder.getPlayer().gameObject;

        playerHealth = player.GetComponent <Health> ();
        //Movement
        playerComponent = player.GetComponent <Player> ();
        AIHeight        = transform.GetComponent <BoxCollider2D> ().bounds.size.y;

        pathGen = GameObject.Find("Platforms").GetComponent <PathGen> ();

        path = pathFinder.FindShortestPath(playerComponent);
        if (path != null)
        {
            target = path [0];
            path.RemoveAt(0);
        }

        // Movement State
        state = States.Follow;

        //Same Platform Movement
        inMotion  = false;
        mightJump = true;

        stuckOnWrongPlatform = 0f;
    }
    public void saveUnspentPoints(Tree tree)
    {
        SkillTree     skillTree = tree as SkillTree;
        CharacterData data      = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        // if it's a skill tree find the correct saved skill tree and update it
        if (skillTree)
        {
            List <CharacterData.SavedSkillTree> skillTrees = data.savedSkillTrees;
            foreach (CharacterData.SavedSkillTree sst in skillTrees)
            {
                if (sst.treeID == tree.treeID)
                {
                    sst.unspentPoints = tree.unspentPoints;
                }
            }
        }
        else
        {
            // initialise the character tree data if necessary
            if (data.savedCharacterTree == null)
            {
                data.savedCharacterTree = new CharacterData.SavedCharacterTree(tree.treeID, tree.unspentPoints, tree.unspentAxisPoints);
            }
            else
            {
                data.savedCharacterTree.treeID            = tree.treeID;
                data.savedCharacterTree.unspentPoints     = tree.unspentPoints;
                data.savedCharacterTree.unspentAxisPoints = tree.unspentAxisPoints;
            }
        }
    }
    public void changeSpecialisation(string newPlayerAbilityID, int slotNumber, string oldPlayerAbilityID = "")
    {
        CharacterData data = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        // remove the old tree if an old PlayerAbilityID is given
        if (oldPlayerAbilityID != "")
        {
            CharacterData.SavedSkillTree treeToRemove = null;
            foreach (CharacterData.SavedSkillTree tree in data.savedSkillTrees)
            {
                if (tree.treeID == oldPlayerAbilityID)
                {
                    treeToRemove = tree;
                }
            }
            if (treeToRemove == null)
            {
                Debug.LogError("Failed to remove saved tree with id " + oldPlayerAbilityID);
            }
            else
            {
                data.savedSkillTrees.Remove(treeToRemove);
            }
        }
        // save the new ability
        data.savedSkillTrees.Add(new CharacterData.SavedSkillTree(newPlayerAbilityID, slotNumber, 0, 1));
    }
    public void saveNodeData(SkillTreeNode node)
    {
        Tree          tree      = node.tree;
        SkillTree     skillTree = tree as SkillTree;
        CharacterData data      = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        // if it's a skill tree find the correct saved skill tree and update it
        if (skillTree)
        {
            List <CharacterData.SavedSkillTree> skillTrees = data.savedSkillTrees;
            foreach (CharacterData.SavedSkillTree sst in skillTrees)
            {
                if (sst.treeID == tree.treeID)
                {
                    sst.unspentPoints = tree.unspentPoints;
                    // look for the node in the dictionary
                    foreach (StringIntPair pair in sst.nodesTaken)
                    {
                        if (pair.key == node.nodeID)
                        {
                            pair.value = node.pointsAllocated;
                            return;
                        }
                    }
                    // if the node has not been found in the dictionary add it
                    sst.nodesTaken.Add(new StringIntPair(node.nodeID, node.pointsAllocated));
                    return;
                }
            }
        }
        // if it's not a skill tree update the character tree
        else
        {
            // initialise the character tree data if necessary
            if (data.savedCharacterTree == null)
            {
                data.savedCharacterTree = new CharacterData.SavedCharacterTree(tree.treeID, tree.unspentPoints, tree.unspentAxisPoints);
            }
            else
            {
                data.savedCharacterTree.treeID            = tree.treeID;
                data.savedCharacterTree.unspentPoints     = tree.unspentPoints;
                data.savedCharacterTree.unspentAxisPoints = tree.unspentAxisPoints;
            }
            // look for the node in the list
            foreach (StringIntPair pair in data.savedCharacterTree.nodesTaken)
            {
                if (pair.key == node.nodeID)
                {
                    pair.value = node.pointsAllocated;
                    return;
                }
            }
            // if the node has not been found in the dictionary add it
            data.savedCharacterTree.nodesTaken.Add(new StringIntPair(node.nodeID, node.pointsAllocated));
            return;
        }
    }
    public void updateGoldCost()
    {
        if (PlayerFinder.getPlayer())
        {
            CharacterDataTracker dataTracker = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>();

            if (dataTracker && dataTracker.charData != null)
            {
                goldCost = 100 + dataTracker.charData.respecs * 100;

                GoldTracker goldTracker = PlayerFinder.getPlayer().GetComponent <GoldTracker>();

                if (dataTracker.charData.characterTreeNodeProgression.Count <= 0)
                {
                    foreach (Transform child in transform)
                    {
                        if (child.name == "gold cost message")
                        {
                            child.GetComponent <TextMeshProUGUI>().text = "You do not have any points allocated on your passive grid";
                        }
                        else if (child.name == "Yes")
                        {
                            child.gameObject.SetActive(false);
                        }
                    }
                }
                else if (goldTracker.value < goldCost)
                {
                    foreach (Transform child in transform)
                    {
                        if (child.name == "gold cost message")
                        {
                            child.GetComponent <TextMeshProUGUI>().text = "You do not have the <color=#DAA520FF>" + goldCost + "</color> gold required to respec.";
                        }
                        else if (child.name == "Yes")
                        {
                            child.gameObject.SetActive(false);
                        }
                    }
                }
                else
                {
                    foreach (Transform child in transform)
                    {
                        if (child.name == "gold cost message")
                        {
                            child.GetComponent <TextMeshProUGUI>().text = "This will undo your latest allocation to your passive grid at the cost of <color=#DAA520FF>" + goldCost + "</color> gold.\n\nIt will also make subsequent respecs cost 100 more gold.";
                        }
                        else if (child.name == "Yes")
                        {
                            child.gameObject.SetActive(true);
                        }
                    }
                }
            }
        }
    }
    public override void setLocation(Vector3 startLocation, Vector3 targetLocation)
    {
        float newDistance = distance;

        if (addWeaponRange)
        {
            newDistance += PlayerFinder.getPlayer().GetComponent <WeaponInfoHolder>().weaponRange;
        }
        transform.position = transform.position + Vector3.Normalize(targetLocation - transform.position) * newDistance;
    }
 void OnEnable()
 {
     if (skillTree && PlayerFinder.getPlayer() && PlayerFinder.getPlayer().GetComponent <SpecialisedAbilityList>() && PlayerFinder.getPlayer().GetComponent <SpecialisedAbilityList>().abilities.Contains(skillTree.ability))
     {
         specialised = true;
     }
     else
     {
         specialised = false;
     }
 }
Example #17
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();
    }
Example #18
0
    // Use this for initialization
    void Start()
    {
        tooltipAbility = gameObject.GetComponent <AbilityTooltip> ();
        player         = PlayerFinder.getPlayer();
        PlayerFinder.playerChangedEvent += ChangePlayer;

        if (skillTree == null)
        {
            foreach (SkillTree tree in SkillTree.all)
            {
                if (tree.ability == ability)
                {
                    skillTree = tree;
                }
            }
        }

        if (player != null)
        {
            foreach (Transform child in transform)
            {
                if (child.name == "Sprite" && child.GetComponent <Image> ())
                {
                    icon        = child.GetComponent <Image> ();
                    icon.sprite = ability.abilitySprite;
                }
                else if (child.name == "Frame")
                {
                }
                else if (child.name == "Description")
                {
                    child.GetComponent <TextMeshProUGUI> ().text = ability.description;
                }
                else if (child.name == "SkillName")
                {
                    child.GetComponent <TextMeshProUGUI> ().text = ability.abilityName;
                }
                else if (child.name == "HasTree")
                {
                    hasTree = child.gameObject;
                    if (!skillTree)
                    {
                        hasTree.SetActive(false);
                    }
                }
            }
        }
    }
 public void Start()
 {
     parent = transform.parent.gameObject;
     if (parent == PlayerFinder.getPlayer())
     {
         parentIsPlayer = true;
     }
     if (parentIsPlayer)
     {
         agent = GetComponent <NavMeshAgent>();
         movementFromAbility = parent.GetComponent <MovementFromAbility>();
         destination         = movementFromAbility.destination;
         transform.position  = transform.parent.position;
         agent.baseOffset    = parent.GetComponent <NavMeshAgent>().baseOffset;
     }
 }
    public void saveAbilityXP(SpecialisedAbilityList sal)
    {
        CharacterData data = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        for (int i = 0; i < sal.abilities.Count; i++)
        {
            foreach (CharacterData.SavedSkillTree tree in data.savedSkillTrees)
            {
                if (tree.treeID == sal.abilities[i].playerAbilityID)
                {
                    tree.abilityXP = (int)sal.abilityXP[i];
                }
            }
        }
        PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
    }
    public void RespecLatestPassive()
    {
        bool open = UIBase.instance.passiveTreeOpen;

        if (!open)
        {
            UIBase.instance.openPassiveTree(true);
        }

        if (PlayerFinder.getPlayer())
        {
            CharacterDataTracker dataTracker = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>();
            GoldTracker          goldTracker = PlayerFinder.getPlayer().GetComponent <GoldTracker>();

            if (dataTracker && goldTracker && goldTracker.value >= goldCost)
            {
                if (dataTracker.charData != null && dataTracker.charData.characterTreeNodeProgression != null && dataTracker.charData.characterTreeNodeProgression.Count > 0)
                {
                    string nodeID = dataTracker.charData.characterTreeNodeProgression[dataTracker.charData.characterTreeNodeProgression.Count - 1];
                    foreach (CharacterTree tree in CharacterTree.all)
                    {
                        if (tree.characterClass == dataTracker.charData.characterClass)
                        {
                            foreach (SkillTreeNode node in tree.nodeList)
                            {
                                if (node.nodeID == nodeID)
                                {
                                    dataTracker.charData.respecs++;
                                    goldTracker.modifyGold(-goldCost);
                                    node.respecOnePoint(true);
                                }
                            }
                        }
                    }
                }
            }
        }

        if (!open)
        {
            UIBase.instance.closePassiveTree();
        }

        UIBase.instance.closePassiveRespecConfirmation();
    }
    public void PopNodeProgression(string nodeID = "")
    {
        CharacterData data = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        if (data.characterTreeNodeProgression.Count > 0)
        {
            if (nodeID != "")
            {
                if (data.characterTreeNodeProgression[data.characterTreeNodeProgression.Count - 1] != nodeID)
                {
                    return;
                }
            }

            data.characterTreeNodeProgression.RemoveAt(data.characterTreeNodeProgression.Count - 1);
        }
        PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
    }
Example #23
0
    void OnEnable()
    {
        // get a list of the player's known abilities and specialised abilities
        GameObject player = PlayerFinder.getPlayer();

        if (player != null)
        {
            List <Ability> playerAbilities = player.GetComponent <KnownAbilityList>().abilities;

            // get a list of the abilities with skill trees
            List <Ability> abilitiesWithTrees = new List <Ability>();

            foreach (SkillTree skillTree in SkillTree.all)
            {
                if (skillTree.ability != null && !abilitiesWithTrees.Contains(skillTree.ability))
                {
                    abilitiesWithTrees.Add(skillTree.ability);
                }
            }

            List <Ability> unspecialisableAbilities = new List <Ability>();

            foreach (Ability ability in playerAbilities)
            {
                if (!abilitiesWithTrees.Contains(ability))
                {
                    unspecialisableAbilities.Add(ability);
                }
            }

            Ability basicMeleeAttack = AbilityIDList.getAbility(AbilityID.basicMeleeAttack);
            if (unspecialisableAbilities.Contains(basicMeleeAttack))
            {
                unspecialisableAbilities.Remove(basicMeleeAttack);
            }

            // instantiate an ability icon for each ability in the player's known ability list that is also in the abilities with trees list and is not already specialised
            foreach (Ability abilitiy in unspecialisableAbilities)
            {
                GameObject abilityIcon = Instantiate(abilityIconPrefab, transform);
                abilityIcon.GetComponent <VisualAbilityIcon>().ability = abilitiy;
            }
        }
    }
 public void GetListReference()
 {
     // get a reference to the player's specialised ability list
     if (!list)
     {
         if (PlayerFinder.getPlayer() == null)
         {
             return;
         }
         list = PlayerFinder.getPlayer().GetComponent <SpecialisedAbilityList>();
         if (list.abilities.Count > abilityNumber && list.abilities[abilityNumber] != null)
         {
             ability     = list.abilities[abilityNumber];
             icon.sprite = ability.abilitySprite;
             findSkillTree();
         }
         list.abilityChangedEvent += checkIfAbilityChanged;
     }
 }
Example #25
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>())
            {
                player.GetComponent <SpecialisedAbilityList>().SpecialiseIfThereIsAFreeSlot(openSKillTree.ability);
                // play a sound
                UISounds.playSound(UISounds.UISoundLabel.Specialise);
            }
            uiBase.closeSkillTrees();
            openSKillTree.open();
            uiBase.closeSpecialisationSelection();
        }
    }
    public void loadAbility(string playerAbilityID, int slotNumber, float abilityXP, int unspentPoints, List <StringIntPair> nodesTaken)
    {
        UIBase uiBase = UIBase.instance;

        uiBase.openSkills();
        // specialised in the ability
        SpecialisedAbilityList specialisedAbilityList = PlayerFinder.getPlayer().GetComponent <SpecialisedAbilityList>();

        specialisedAbilityList.Specialise(AbilityIDList.getPlayerAbility(playerAbilityID), slotNumber, false);
        // set the ability xp
        specialisedAbilityList.abilityXP[slotNumber] = abilityXP;
        // set the ability level
        specialisedAbilityList.abilityLevels[slotNumber] = SpecialisedAbilityManager.getAbilityLevel(abilityXP);

        // update the tree
        loadTree(playerAbilityID, unspentPoints, 0, nodesTaken);

        uiBase.closeSkills();
    }
    public static void loadAbilityBar()
    {
        CharacterDataTracker tracker        = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>();
        AbilityList          abilityList    = PlayerFinder.getPlayer().GetComponent <AbilityList>();
        List <string>        savedAbilities = tracker.charData.abilityBar;

        for (int i = 0; i < savedAbilities.Count; i++)
        {
            Ability ability = AbilityIDList.getPlayerAbility(savedAbilities[i]);
            if (ability == null)
            {
                abilityList.abilities[i] = AbilityIDList.getAbility(AbilityID.nullAbility);
            }
            else
            {
                abilityList.abilities[i] = ability;
            }
        }
    }
    public static void selectionChange(int abilityNumber1to5, string newPlayerAbilityID)
    {
        CharacterDataTracker tracker = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>();

        if (tracker.charData.abilityBar == null)
        {
            tracker.charData.abilityBar = new List <string>();
        }
        while (tracker.charData.abilityBar.Count < abilityNumber1to5)
        {
            tracker.charData.abilityBar.Add("");
        }
        tracker.charData.abilityBar[abilityNumber1to5 - 1] = newPlayerAbilityID;

        if (tracker.charData.characterName != "")
        {
            tracker.SaveCharacterData();
        }
    }
    // specialise in an ability for a specific slot
    public void Specialise(Ability ability, int slot, bool save = true)
    {
        string oldID = "";

        if (save && abilities[slot] != null)
        {
            oldID = abilities[slot].playerAbilityID;
        }
        abilities[slot]     = ability;
        abilityLevels[slot] = 1;
        abilityXP[slot]     = 0f;
        if (abilityChangedEvent != null)
        {
            abilityChangedEvent.Invoke(slot);
        }
        if (save)
        {
            SkillSavingManager.instance.changeSpecialisation(ability.playerAbilityID, slot, oldID);
            PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
        }
    }
    void OnEnable()
    {
        if (PlayerFinder.getPlayer() == null)
        {
            return;
        }
        List <Ability> abilities = PlayerFinder.getPlayer().GetComponent <KnownAbilityList> ().abilities;

        // find the list of locked abilities
        List <CharacterClass.AbilityAndLevel> lockedAbilities = new List <CharacterClass.AbilityAndLevel>();
        CharacterData data = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        if (data != null && data.characterClass != null)
        {
            foreach (CharacterClass.AbilityAndLevel aal in data.characterClass.unlockableAbilities)
            {
                if (!abilities.Contains(aal.ability))
                {
                    lockedAbilities.Add(aal);
                }
            }
        }

        lockedAbilities.Sort((la1, la2) => la1.level.CompareTo(la2.level));

        // instantiate an ability icon for each ability in the player's known ability list
        foreach (Ability abilitiy in abilities)
        {
            GameObject abilityIcon = Instantiate(abilityIconPrefab, transform);
            abilityIcon.GetComponent <AbilityPanelIcon>().ability = abilitiy;
        }

        foreach (CharacterClass.AbilityAndLevel aal in lockedAbilities)
        {
            GameObject abilityIcon = Instantiate(lockedAbilityIconPrefab, transform);
            abilityIcon.GetComponent <LockedAbilityPanelIcon>().ability          = aal.ability;
            abilityIcon.GetComponent <LockedAbilityPanelIcon>().levelRequirement = aal.level;
        }
    }