示例#1
0
文件: Player.cs 项目: atxkirl/FYPJ2
    //////////////////////////
    // ADD/REMOVE FUNCTIONS //
    //////////////////////////

    /// <summary>
    /// Adds a skill to the player
    /// </summary>
    public void AddSkill(SkillBase _skill)
    {
        //Check if player already has the skill
        if (playerSkills.Contains(_skill))
        {
            return;
        }

        //Add skill to player's list of skill
        playerSkills.Add(_skill);
        //Update player's skillpoints
        ModifyCurrentSkillpoints(-_skill.GetSkillpointsNeeded());
        //Apply new skill's effect to player
        _skill.ApplySkillEffect();
    }
示例#2
0
文件: Player.cs 项目: atxkirl/FYPJ2
    //////////////////////////
    // ADD/REMOVE FUNCTIONS //
    //////////////////////////

    /// <summary>
    /// Adds a skill to the player
    /// </summary>
    public void AddSkill(SkillBase _skill)
    {
        //Check if player already has the skill
        if (playerSkills.Contains(_skill))
        {
            Debug.Log("Player already has skill: " + _skill.displayName);
            return;
        }

        //Instantiate scene-based version of skill
        GameObject skill = (GameObject)Instantiate(Resources.Load("Skills/" + _skill.displayName));

        skill.GetComponent <SkillBase>().SetOwner(gameObject);

        //Set player as skill's owner
        _skill.SetOwner(gameObject);
        //Add skill to player's list of skill
        playerSkills.Add(_skill);
        //Update player's skillpoints
        ModifyCurrentSkillpoints(-_skill.GetSkillpointsNeeded());
        //Apply new skill's effect to player
        _skill.ApplySkillEffect();
    }