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()); } }
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("裝備資料不存在!"); } }
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); }
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(); }
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)); }
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(); } }
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("資料不存在!"); } }
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("裝備資料不存在!"); } }
private void SetData() { MoneyLabel.text = ItemManager.Instance.Money.ToString(); NameLabel.text = _selectedData.GetName(); AmountLabel.text = "庫存:" + ItemManager.Instance.GetItemAmount(_selectedData.ID, ItemManager.Type.Warehouse); CommentLabel.text = _selectedData.GetComment(); if (_selectedData.Type == ItemData.TypeEnum.Equip) { EquipComment.gameObject.SetActive(true); EquipComment.SetData(_selectedData.ID); } else { EquipComment.gameObject.SetActive(false); } BuyButton.gameObject.SetActive(true); _canBuy = true; if (ItemManager.Instance.Money < _selectedData.Price) { BuyButton.SetColor(Color.grey); _canBuy = false; _tipText = "錢不足"; } int have; int need; for (int i = 0; i < MaterialNameLabel.Length; i++) { if (i < _selectedData.MaterialList.Count) { have = ItemManager.Instance.GetItemAmount(_selectedData.MaterialList[i], ItemManager.Type.Warehouse); need = _selectedData.AmountList[i]; MaterialNameLabel[i].gameObject.SetActive(true); MaterialNameLabel[i].text = ItemData.GetData(_selectedData.MaterialList[i]).GetName(); MaterialAmountLabel[i].gameObject.SetActive(true); if (have < need) { BuyButton.SetColor(Color.grey); _canBuy = false; _tipText = "素材不足"; MaterialAmountLabel[i].text = "<color=#FF0000>" + have.ToString() + "</color>/" + need.ToString(); } else { MaterialAmountLabel[i].text = have.ToString() + "/" + need.ToString(); } } else { MaterialNameLabel[i].gameObject.SetActive(false); MaterialAmountLabel[i].gameObject.SetActive(false); } } if (_canBuy) { BuyButton.SetColor(Color.white); } }