public void clicked() { if (AbilityDragHandler.dragging) { return; } if (ability) { openSkillTree(); //int abilityNumber = AbilityPanelManager.instance.abilityClicked; //// abilityNumber is 0 if this was opened with the S key //if (abilityNumber == 0) { openSkillTree(); } //// otherise it was opened by clicking on an ability in the ability bar //else //{ // list.GetComponent<AbilityList>().abilities[abilityNumber - 1] = ability; // UIBase.instance.closeSkills(); //} } else { UIBase.instance.closeSkillTrees(); UIBase.instance.closeSpecialisationSelection(); openSkillSelection(); } // play a sound UISounds.playSound(UISounds.UISoundLabel.Confirm); }
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(); } }
public void clicked() { UIBase ui = UIBase.instance; ui.openSkills(); // play a sound UISounds.playSound(UISounds.UISoundLabel.Confirm); deactivate(); }
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 clicked() { UIBase ui = UIBase.instance; if (ui) { ui.openPassiveTree(true); // play a sound UISounds.playSound(UISounds.UISoundLabel.Confirm); deactivate(); } }
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 clicked() { // specialise in the ability if (specialisationPanelmanager) { player.GetComponent <SpecialisedAbilityList>().Specialise(ability, specialisationPanelmanager.slotClicked); } // close the selection panel UIBase.instance.closeSpecialisationSelection(); // open the relevant skill tree foreach (SkillTree skillTree in SkillTree.all) { if (skillTree.ability == ability) { skillTree.open(); } } // play a sound UISounds.playSound(UISounds.UISoundLabel.Specialise); }
public void clicked(Ability ability = null) { UIBase ui = UIBase.instance; ui.openSkills(); AbilityPanelManager.instance.abilityClicked = 0; // open the relevant tree if (ability != null) { foreach (SkillTree tree in SkillTree.all) { if (tree.ability == ability) { tree.open(); } } } // play a sound UISounds.playSound(UISounds.UISoundLabel.Confirm); deactivate(); }
public void clicked() { if (AbilityDragHandler.dragging) { return; } int abilityNumber = AbilityPanelManager.instance.abilityClicked; // abilityNumber is 0 if this was opened with the S key if (abilityNumber == 0) { // play a sound UISounds.playSound(UISounds.UISoundLabel.Confirm); // open the tree openSkillTree(); } // otherise it was opened by clicking on an ability in the ability bar else { player.GetComponent <AbilityList>().abilities[abilityNumber - 1] = ability; UIBase.instance.closeSkills(); } }
public void OnEndDrag(PointerEventData eventData) { safeToClearVariables = true; StartCoroutine(clearDragVariables()); // find the ability player = PlayerFinder.getPlayer(); if (GetComponent <AbilityPanelIcon>()) { ability = GetComponent <AbilityPanelIcon>().ability; } else if (GetComponent <SpecialisedAbilityIcon>() && player.GetComponent <SpecialisedAbilityList>().abilities.Count > GetComponent <SpecialisedAbilityIcon>().abilityNumber&& player.GetComponent <SpecialisedAbilityList>().abilities[GetComponent <SpecialisedAbilityIcon>().abilityNumber] != null) { ability = player.GetComponent <SpecialisedAbilityList>().abilities[GetComponent <SpecialisedAbilityIcon>().abilityNumber]; } // if the ability is null just return if (ability == null) { transform.position = startPos; return; } // try to apply to an ability bar icon AbilityBarIcon[] abilityIcons = AbilityBarIcon.all.ToArray(); if (abilityIcons != null) { AbilityBarIcon selectedIcon = abilityIcons [0]; foreach (AbilityBarIcon a in abilityIcons) { if (Mathf.Abs(a.transform.position.x - eventData.position.x) < Mathf.Abs(selectedIcon.transform.position.x - eventData.position.x)) { selectedIcon = a; } } if (Mathf.Abs(selectedIcon.transform.position.x - eventData.position.x) < 30.0f) { abilityNum = selectedIcon.abilityNumber; player.GetComponent <AbilityList> ().abilities [abilityNum - 1] = ability; // play a sound UISounds.playSound(UISounds.UISoundLabel.Confirm); } } // try to apply to a specialisation slot if (!specialisedIconHandler) { // check if this ability has a tree bool abilityHasTree = false; foreach (SkillTree tree in SkillTree.all) { if (tree.ability == ability) { abilityHasTree = true; } } if (abilityHasTree && !player.GetComponent <SpecialisedAbilityList>().abilities.Contains(ability)) { // only look at open specialisation slots List <SpecialisedAbilityIcon> specialisedIcons = new List <SpecialisedAbilityIcon>(); specialisedIcons.AddRange(SpecialisedAbilityIcon.all); specialisedIcons.RemoveAll(x => x.ability != null); specialisedIcons.RemoveAll(x => x.locked == true); if (specialisedIcons.Count > 0) { SpecialisedAbilityIcon selectedIcon = specialisedIcons[0]; foreach (SpecialisedAbilityIcon icon in specialisedIcons) { if (Mathf.Abs(icon.transform.position.x - eventData.position.x) < Mathf.Abs(selectedIcon.transform.position.x - eventData.position.x)) { selectedIcon = icon; } } if (Mathf.Abs(selectedIcon.transform.position.x - eventData.position.x) < 30.0f) { player.GetComponent <SpecialisedAbilityList>().Specialise(ability, selectedIcon.abilityNumber); // close the selection panel UIBase.instance.closeSpecialisationSelection(); // open the relevant skill tree foreach (SkillTree skillTree in SkillTree.all) { if (skillTree.ability == ability) { skillTree.open(); } } // play a sound UISounds.playSound(UISounds.UISoundLabel.Specialise); } } } } //alternate way of doing this, probably better if to find what is under the curser than the above functional way //this is dependant on what order objects are in, in the hierarchy /* * foreach (GameObject g in eventData.hovered) { * if (g.transform.GetComponent<AbilityBarIcon> () != null) { * player = GameObject.FindGameObjectWithTag ("Player"); * abilityNum = g.transform.GetComponent<AbilityBarIcon> ().abilityNumber; * ability = GetComponent<AbilityPanelIcon> ().ability; * player.GetComponent<AbilityList>().abilities[abilityNum - 1] = ability; * break; * } * } */ transform.position = startPos; }