57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 负责工具材料包管理
|
|
/// </summary>
|
|
public class PacksackBagMgr : BaseManager<PacksackBagMgr>
|
|
{
|
|
//包里用了哪些工器具
|
|
private readonly Dictionary<int, List<ItemInfo>> toolAndMaterialDic = new Dictionary<int, List<ItemInfo>>();
|
|
|
|
private PacksackBagMgr()
|
|
{
|
|
}
|
|
|
|
public Dictionary<int, List<ItemInfo>> GetCurrentBagData()
|
|
{
|
|
return toolAndMaterialDic;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 添加一个工器具或材料
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void AddOneToolOrMater(ItemInfo itemInfo)
|
|
{
|
|
if (toolAndMaterialDic.ContainsKey(itemInfo.toolId))
|
|
{
|
|
toolAndMaterialDic[itemInfo.toolId].Add(itemInfo);
|
|
}
|
|
else
|
|
{
|
|
toolAndMaterialDic.Add(itemInfo.toolId, new List<ItemInfo>() { itemInfo });
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 移除一个工器具或材料
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void RemoveOneToolOrMater(ItemInfo itemInfo)
|
|
{
|
|
if (toolAndMaterialDic.ContainsKey(itemInfo.toolId))
|
|
{
|
|
if (toolAndMaterialDic[itemInfo.toolId].Count > 1)
|
|
{
|
|
toolAndMaterialDic[itemInfo.toolId].Remove(itemInfo);
|
|
}
|
|
else
|
|
{
|
|
toolAndMaterialDic.Remove(itemInfo.toolId);
|
|
}
|
|
}
|
|
}
|
|
} |