using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 装备栏
/// 装备类型:稀有度/装备类型/次级类型/种类
///
稀有度:普通,精良,稀有,史诗,传奇,神话
///
装备类型:武器,护甲,饰品
///
次级类型:单手,副手,双手,上衣,头盔,手套,腰带,鞋子,项链,戒指,手镯
///
装备种类:剑,锤,枪,弓,斧头,盾牌,法杖,魔杖
///
public class Equipment {
/// 插槽字典
public Dictionary dictionary = new Dictionary();
/// 索引器
public InventorySlot this[string key] => dictionary[key];
/// 索引器(枚举)
public InventorySlot this[Enum key] => dictionary[key.ToString()];
/// 遍历数组
public void ForEach(Action action) {
foreach (var item in dictionary) { action?.Invoke(item.Key, item.Value); }
}
/// 添加插槽
public void AddSlot(Enum name, string type) {
AddSlot(name.ToString(), type);
}
/// 添加插槽
public void AddSlot(string name, string type) {
var slot = new InventorySlot();
slot.name = name;
slot.limits = new List(type.Split("/"));
AddSlot(slot);
}
/// 添加插槽
public void AddSlot(InventorySlot slot) {
if (dictionary.ContainsKey(slot.name)) { return; }
dictionary.Add(slot.name, slot);
}
}