示例#1
0
    public void GetItem(ItemBase i)
    {
        Debug.LogFormat("Inventory Add: {0} ", i);
        // 重複利用道具不可重複拿
        foreach (ItemBase item in Inventory)
        {
            if (item.id == i.id)
            {
                if (i.canReuse())
                {
                    return;
                }
            }
        }
        if (i.canReuse())
        {
            Inventory.Add(i);
        }
        else
        {
            for (int c = 0; c < i.Amount; c++)
            {
                if (Inventory.Count == 3)
                {
                    return;
                }
                ItemBase itemcopy;
                switch (i.id)
                {
                case 0:
                    itemcopy = new HpRecover();
                    break;

                case 1:
                    itemcopy = new MpRecover();
                    break;

                case 2:
                    itemcopy = new BoostAttack();
                    break;

                default:
                    Debug.Log("item error!");
                    return;
                }
                itemcopy.Amount = 1;
                Inventory.Add(itemcopy);
            }
        }
    }
示例#2
0
 protected new void Start()
 {
     base.Start();
     AcquireItem = new HpRecover();
 }