void OnGUI() { if (showTree) { for (int i = 0; i < listOfSkills.Count; i++) { MySkill skill = listOfSkills[i]; if (skill.isActive) { GUI.color = skill.btnOn; } else { GUI.color = skill.btnOff; } if (GUI.Button(skill.position, skill.label)) { if (skill.isAvailable() && (ps.skillPoint >= skill.skillCost) && !skill.isActive) { ps.skillPoint -= skill.skillCost; ps.changePlayerStat(skill.statToChange, skill.statValue); skill.isActive = true; } } } } }
void Start() { ps = gameObject.GetComponent <Player> (); showTree = false; listOfSkills = new List <MySkill>(); MySkill HP1 = new MySkill("HP I", 1, "maxHealth", 6); MySkill HP2 = new MySkill("HP II", 2, "maxHealth", 7); MySkill HP3 = new MySkill("HP III", 3, "maxHealth", 8); HP2.addRequirement(HP1); HP3.addRequirement(HP2); listOfSkills.Add(HP1); listOfSkills.Add(HP2); listOfSkills.Add(HP3); }
public void addRequirement(MySkill skill) { requirements.Add(skill); }
void AddMySkill(MySkill mySkill) { skillList.Add(mySkill); }