예제 #1
0
    //assign a new skill to the manager (put into the list) return whether the change is successful
    public static bool ChangeSkill(Skill skill, int index)
    {
        if((skill.attack_type != status_manager.weapon_type && skill.attack_type != Skill.AttackType.anytype) || skill.level_req > status_manager.level)
        {
            return false;
        }

        //if skill is already there
        for(int i = 0; i < 6; ++i)
        {
            if(skills[i] != null && skills[i].id == skill.id)
            {
                skills[i].Remove();
                skills[i] = null;
                StatusGUIManager.EmptySkillIcon(i);
                SkillSlotManager.EmptySkill(i);
            }
        }

        if(skills[index] != null)
        {
            skills[index].Remove();
        }

        StatusGUIManager.ChangeSkillIcon(index, skill.icon);
        SkillSlotManager.AssignSkill(index, skill);
        skill.ownership = Skill.Ownership.player;
        skill.SetUp(status_manager);
        skills[index] = skill;
        return true;
    }