using System; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 装备栏 /// public class Equipment { /// 插槽字典 public Dictionary dictionary = new Dictionary(); /// 索引器 public EquipmentSlot this[string key] => dictionary[key]; public bool ContainsKey(string key) => dictionary.ContainsKey(key); /// 添加插槽 public void AddSlot(EquipmentSlot slot) => dictionary.Add(slot.name, slot); } /// /// 插槽类型 /// public enum SlotType { 库存, 主手, 副手, 上衣, 头盔, 手套, 腰带, 鞋子, 项链, 戒指1, 戒指2, 手镯1, 手镯2 } /// /// 装备插槽 /// public abstract class EquipmentSlot { /// 名字 public string name; /// 物品 public DataEquipment item; public EquipmentSlot(SlotType slot) => name = slot.ToString(); /// 设置 public void Settings(DataItem item, int count) { if (item is DataEquipment equipment) { this.item = equipment; } else { this.item = null; } } public abstract bool Verify(DataEquipment equipment); } /// /// 武器 - 装备插槽 /// public class WeaponSlot : EquipmentSlot { /// 副手插槽 public DeputySlot deputy; public WeaponSlot(SlotType slot) : base(slot) { } public override bool Verify(DataEquipment equipment) { string[] type = equipment.type.Split("/"); if (type[0] == WeaponType.单手.ToString()) { return true; } if (type[0] == WeaponType.双手.ToString()) { return true; } return false; } } /// /// 副手 - 装备插槽 /// public class DeputySlot : EquipmentSlot { /// 主手插槽 public WeaponSlot weapon; public DeputySlot(SlotType slot) : base(slot) { } public override bool Verify(DataEquipment equipment) { string[] type = equipment.type.Split("/"); if (type[0] == WeaponType.副手.ToString()) { return true; } return false; } } /// /// 护甲 - 装备插槽 /// public class ArmorSlot : EquipmentSlot { /// 护甲类型 public string armorType; public ArmorSlot(SlotType slot, ArmorType armor) : base(slot) => armorType = armor.ToString(); public override bool Verify(DataEquipment equipment) { string[] type = equipment.type.Split("/"); if (type[0] == armorType) { return true; } return false; } } /// /// 饰品 - 装备插槽 /// public class AccessorySlot : EquipmentSlot { /// 饰品类型 public string accessoryType; public AccessorySlot(SlotType slot, AccessoryType accessory) : base(slot) => accessoryType = accessory.ToString(); public override bool Verify(DataEquipment equipment) { string[] type = equipment.type.Split("/"); if (type[0] == accessoryType) { return true; } return false; } }