Ejemplo n.º 1
0
    private void AttachOnClickListener(Button buttonToAttach)
    {
        buttonToAttach.onClick.AddListener(() =>
        {
            BaseSkill skill = playerSkills.GetSkillByName(buttonToAttach.name);

            if (playerSkills.IsSkillUnlocked(skill))
            {
                ActiveSkill activeSkill = skill as ActiveSkill;
                if (activeSkill != null && !playerSkills.TryActivateSkill(activeSkill))
                {
                    Debug.Log("Cannot activate " + buttonToAttach.name);
                }
            }
            else if (!playerSkills.TryUnlockSkill(skill))
            {
                Debug.Log("Cannot unlock " + buttonToAttach.name);
            }
        });
    }