Skill Nodes
Last updated
Last updated
A skill node is a skill's representation in a skill graph. 'mySkillNode
' in the code examples below is an instance of a SkillNode
.
The recommended method of getting a skill node is through a . Alternatively, you can get a skill node with it's key.
All of the data you can set for a skill node from the Editor Window are public fields.
You can use the stats
field the access the full list of stats.
There are 4 possible skill states:
Locked
If the skill is locked.
Unlocked
If the skill is unlocked.
Obtained
If the skill is obtained.
Maxed
If the skill's level is maxed.
Skills start out locked. Skill states can be managed with the methods below.
You can check the current state of a skill by comparing the state field or you may use the Boolean properties listed below.
IsLocked
If the skill is locked.
IsUnlocked
If the skill is unlocked.
IsObtained
If the skill is obtained.
IsMaxed
If the skill's level is maxed.
Skills must be unlocked to be obtainable (or upgradable).
TryUnlock
This method attempts to unlock a skill if possible. Skills cannot be unlocked if the player doesn't meet the level requirement, no obtained skill leads to this skill through a connection, or if enough required skill points haven't been spent on skills in a specific skill tree.
TryUnlockAllThroughConnections
This method tries to unlock all skills that the skill has a connection with. This is useful when you need to unlock skills connected to another. For example, if skill B, C, and D have a connection with skill A, this will unlock skills B, C, and D if skill A is obtained.
Once a skill is upgraded at least once, it's state changes to Obtained
.
TryUpgrade
This method will upgrade a skill if possible. If a skill is not obtained or maxed, nothing will happen. This accepts a skill points parameter (int
), which will decrease the player's skill points by the amount provided (it will decrease the SkillTree.playerSkillPoints
field).
The skill state will change to Maxed
if it cannot be upgraded anymore.
Skills can be downgraded with TryDowngrade
. Skill states will change accordingly. Downgrading may fail if the skill is at the lowest level (0). Downgrading may also be prevented from Skill Tree's settings.
Optionally, you can use Deplete
to completely downgrade a skill.
Assuming mySkillNode
's first stat's current value is 100, result
will equal:
You can get a string that represents the skill's current level out of the max level.
You can access the sprites with mySkillNode.lockedSprite
, mySkillNode.unlockedSprite
, and mySkillNode.obtainedSprite
.
To get the relevant sprite based on the current state of the skill, use the GetSprite
method.
Skill nodes store a reference to the skill graph they are a part of.
Skills support text interpolation with the usage of text tags. You can learn more about this . Essentially, you can use text tags in a string, run the string through the skill's GetInterpolatedText
method, and it will return the same string except with the tags replaced by the skill's details.