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));
    }
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 pushToNodePogression(string nodeID)
    {
        CharacterData data = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        data.characterTreeNodeProgression.Add(nodeID);
        PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
    }
    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;
                }
            }
        }
    }
    public void removeNodeFromPogression(string nodeID)
    {
        CharacterData data = PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData;

        data.characterTreeNodeProgression.RemoveAll(x => x == nodeID);
        PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().SaveCharacterData();
    }
Example #6
0
 public void OnUse()
 {
     if (PlayerFinder.getPlayer())
     {
         PlayerFinder.getPlayer().GetComponent <CharacterDataTracker>().charData.portalUnlocked = true;
     }
 }
    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 #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 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 #10
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();
     }
 }
    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;
            }
        }
    }
Example #12
0
    protected override void Awake()
    {
        playerFinder = new PlayerFinder();

        yieldWait = new WaitForSeconds(waitTime);

        base.Awake();
    }
    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 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 #16
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();
    }
 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 #21
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;
            }
        }
    }
Example #22
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();
        }
    }