コード例 #1
0
    public void AddAbility(Blueprint bp)
    {
        Ability ability;
        bool    hasAbility;

        do
        {
            hasAbility = false;
            ability    = bp.GetAbility();

            foreach (Ability ablt in abilities)
            {
                if (ability.GetType().Equals(ablt.GetType()))
                {
                    hasAbility = true;
                    break;
                }
            }
        } while (hasAbility);

        Ability newAbility = Instantiate(ability.gameObject, transform).GetComponent <Ability>();

        if (abilities.Count < 3)
        {
            abilities.Add(newAbility);
        }
        else
        {
            abilities[abilities.Count - 1] = newAbility;
        }

        UIManager.I.ChangeAbilitySprite(abilities.Count - 1, newAbility.buttonSprite, newAbility.bgSprite);
    }