Beispiel #1
0
    private void MinusWarehouseItem(int id, int amount)
    {
        Item item;

        ItemData.RootObject data = ItemData.GetData(id);

        if (WarehouseItemListContains(id))
        {
            if (data.CanBeStacked)
            {
                item         = GetWarehouseItem(id);
                item.Amount -= amount;

                if (item.Amount < 0)
                {
                    Debug.Log("道具不足,差 " + item.Amount * -1 + " 個");
                    item.Amount += amount;
                }
                else if (item.Amount == 0)
                {
                    _warehouseTypeDic[ItemData.TypeEnum.All].Remove(item);
                    _warehouseTypeDic[data.Type].Remove(item);
                }
            }
            else
            {
                Debug.Log(data.GetName() + "不是可堆疊的道具");
            }
        }
        else
        {
            Debug.Log("沒有這個道具: " + data.GetName());
        }
    }
Beispiel #2
0
    public Equip(int id, int lv = 1)
    {
        ItemData.RootObject  itemData  = ItemData.GetData(id);
        EquipData.RootObject equipData = EquipData.GetData(id);

        if (itemData != null && equipData != null)
        {
            ID   = id;
            Name = itemData.GetName();
            Lv   = lv;
            if (lv > 1)
            {
                Name += "+" + (Lv - 1);
            }
            Comment      = itemData.GetComment();
            Icon         = itemData.Icon;
            Volume       = itemData.Volume;
            Price        = itemData.Price;
            Amount       = 1;
            CanCook      = itemData.CanCook;
            CanBeStacked = itemData.CanBeStacked;
            Type         = itemData.Type;

            EquipType    = equipData.Type;
            ATK          = Mathf.RoundToInt(equipData.ATK * (1 + (Lv - 1) * 0.1f));
            DEF          = Mathf.RoundToInt(equipData.DEF * (1 + (Lv - 1) * 0.1f));
            MTK          = Mathf.RoundToInt(equipData.MTK * (1 + (Lv - 1) * 0.1f));
            MEF          = Mathf.RoundToInt(equipData.MEF * (1 + (Lv - 1) * 0.1f));
            UpgradePrice = equipData.UpgradePrice;
        }
        else
        {
            Debug.Log("裝備資料不存在!");
        }
    }
Beispiel #3
0
 private void Init(ItemData.RootObject data)
 {
     Icon.gameObject.SetActive(true);
     Icon.overrideSprite = Resources.Load <Sprite>("Image/Item/" + data.Icon);
     NameLabel.text      = data.GetName();
     AmountLabel.gameObject.SetActive(false);
 }
Beispiel #4
0
 private void Init(ItemData.RootObject data, int have, int need)
 {
     Icon.gameObject.SetActive(true);
     Icon.overrideSprite = Resources.Load <Sprite>("Image/Item/" + data.Icon);
     NameLabel.text      = data.GetName();
     AmountLabel.gameObject.SetActive(true);
     AmountLabel.text = have.ToString() + "/" + need.ToString();
 }
Beispiel #5
0
 public void Init(int id, int have, int need)
 {
     if (id >= 0)
     {
         ItemData.RootObject data = ItemData.GetData(id);
         Init(data, have, need);
     }
     else
     {
         SetMoney(id * -1);
     }
 }
Beispiel #6
0
 public void Init(int id, int amount)
 {
     if (id >= 0)
     {
         ItemData.RootObject data = ItemData.GetData(id);
         Init(data, amount);
     }
     else
     {
         SetMoney(id * -1);
     }
 }
Beispiel #7
0
 public void LvUp()
 {
     ItemData.RootObject  itemData  = ItemData.GetData(ID);
     EquipData.RootObject equipData = EquipData.GetData(ID);
     if (Lv < MaxLv)
     {
         Lv += 1;
     }
     Name  = itemData.GetName();
     Name += "+" + (Lv - 1);
     ATK   = Mathf.RoundToInt(equipData.ATK * (1 + (Lv - 1) * 0.1f));
     DEF   = Mathf.RoundToInt(equipData.DEF * (1 + (Lv - 1) * 0.1f));
     MTK   = Mathf.RoundToInt(equipData.MTK * (1 + (Lv - 1) * 0.1f));
     MEF   = Mathf.RoundToInt(equipData.MEF * (1 + (Lv - 1) * 0.1f));
 }
Beispiel #8
0
 private void Init(ItemData.RootObject data, int amount)
 {
     if (amount == 0)
     {
         Clear();
     }
     else
     {
         Icon.gameObject.SetActive(true);
         Icon.overrideSprite = Resources.Load <Sprite>("Image/Item/" + data.Icon);
         NameLabel.text      = data.GetName();
         AmountLabel.gameObject.SetActive(true);
         AmountLabel.text = amount.ToString();
     }
 }
Beispiel #9
0
    public Food(int id, int amount, int addHP = -1, int addMP = -1)
    {
        ItemData.RootObject itemData = ItemData.GetData(id);

        if (itemData != null)
        {
            ID           = id;
            Name         = itemData.GetName();
            Icon         = itemData.Icon;
            Volume       = itemData.Volume;
            Price        = itemData.Price;
            Amount       = amount;
            CanCook      = itemData.CanCook;
            CanBeStacked = itemData.CanBeStacked;
            Type         = itemData.Type;
            CookTag      = itemData.CookTag;

            ItemEffectData.RootObject itemEffectData = ItemEffectData.GetData(id);
            if (addHP == -1)
            {
                AddHP = itemEffectData.AddHP;
            }
            else
            {
                AddHP = addHP;
            }

            if (addMP == -1)
            {
                AddMP = itemEffectData.AddMP;
            }
            else
            {
                AddMP = addMP;
            }

            Comment = String.Format(itemData.GetComment(), AddHP, AddMP);
        }
        else
        {
            Debug.Log("資料不存在!");
        }
    }
Beispiel #10
0
    private void AddWarehouseItem(int id, int amount)
    {
        Item item;

        ItemData.RootObject data = ItemData.GetData(id);


        if (WarehouseItemListContains(id) && data.CanBeStacked)
        {
            item         = GetWarehouseItem(id);
            item.Amount += amount;
        }
        else
        {
            item = GetNewItem(id, data.Type, amount);
            _warehouseTypeDic[ItemData.TypeEnum.All].Add(item);
            _warehouseTypeDic[data.Type].Add(item);
        }
    }
Beispiel #11
0
    private void AddBagItem(int id, int amount)
    {
        Item item;

        ItemData.RootObject data = ItemData.GetData(id);

        if (BagItemListContains(id) && data.CanBeStacked)
        {
            item         = GetBagItem(id);
            item.Amount += amount;
        }
        else
        {
            item = GetNewItem(id, data.Type, amount);
            _bagTypeDic[ItemData.TypeEnum.All].Add(item);
            _bagTypeDic[data.Type].Add(item);
        }

        CurrentBagVolume += data.Volume * amount;
    }
Beispiel #12
0
    public Item(int id, int amount)
    {
        ItemData.RootObject itemData = ItemData.GetData(id);

        if (itemData != null)
        {
            ID           = id;
            Name         = itemData.GetName();
            Comment      = itemData.GetComment();
            Icon         = itemData.Icon;
            Volume       = itemData.Volume;
            Price        = itemData.Price;
            Amount       = amount;
            CanCook      = itemData.CanCook;
            CanBeStacked = itemData.CanBeStacked;
            Type         = itemData.Type;
            CookTag      = itemData.CookTag;
        }
        else
        {
            Debug.Log("裝備資料不存在!");
        }
    }
Beispiel #13
0
 private void Init()
 {
     _selectedData   = null;
     MoneyLabel.text = ItemManager.Instance.Money.ToString();
     SetScrollView(ShopData.TypeEnum.Item);
 }
Beispiel #14
0
 private void MenuOnClick(object obj)
 {
     _selectedData = ItemData.GetData((int)obj);
     SetData();
 }