using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; /// /// 装备插槽 /// public class EquipmentSlot { /// 数量 public int count; /// 名字 public string name; /// 物品 public InventoryItem item; /// 限制类型 public List limits = new List(); /// 堆叠数量 public int MaxStack => item != null ? item.stack : 0; /// 图片 public Sprite Sprite => item != null ? item.sprite : null; /// 验证类型 public bool Verify(InventoryItem item) { string[] types = item.type.Split("/"); return limits.All(item => types.Contains(item)); } /// 替换 public (InventoryItem, int) Replace(InventoryItem newItem, int count) { int remain = this.count; InventoryItem old = item; item = newItem; this.count = count; return (old, remain); } }