using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 负责工具材料包管理
///
public class PacksackBagMgr : BaseManager
{
private readonly Dictionary> toolAndMaterialDic = new Dictionary>();
public Dictionary wearDic = new Dictionary();
private PacksackBagMgr()
{
}
public Dictionary> GetCurrentBagData()
{
return toolAndMaterialDic;
}
///
/// 添加一个工器具或材料
///
///
public void AddOneToolOrMater(ItemInfo itemInfo)
{
if (toolAndMaterialDic.ContainsKey(itemInfo.toolId))
{
toolAndMaterialDic[itemInfo.toolId].Add(itemInfo);
}
else
{
toolAndMaterialDic.Add(itemInfo.toolId, new List() { itemInfo });
}
}
public Dictionary> GetItemsByE_TMDType(E_ToolOrDeviceOrMaterials tmdTpye)
{
Dictionary> tempNew = new Dictionary>();
var dicTemp = toolAndMaterialDic;
foreach (var item in dicTemp.Keys)
{
for (int i = 0; i < dicTemp[item].Count; i++)
{
if (dicTemp[item][i].toolOrDeviceOrMaterial == tmdTpye)
{
if (tempNew.ContainsKey(dicTemp[item][i].toolId))
{
tempNew[dicTemp[item][i].toolId].Add(dicTemp[item][i]);
}
else
{
tempNew.Add(dicTemp[item][i].toolId, new List() { dicTemp[item][i] });
}
}
}
}
return tempNew;
}
///
/// 移除一个工器具或材料
///
///
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);
}
}
}
///
/// 移除多个
///
///
public void RemoveAllToolOrMater(ItemInfo itemInfo)
{
if (toolAndMaterialDic.ContainsKey(itemInfo.toolId))
{
toolAndMaterialDic.Remove(itemInfo.toolId);
}
}
///
/// 移除全部工具 设备 材料
///
public void ClearAllToolAndDiveceAndMaterial()
{
toolAndMaterialDic.Clear();
}
///
/// 添加 穿戴 状态 0 去掉 1 穿上
///
///
///
public void WearItemState(ItemInfo itemInfo, bool state)
{
if (state)
{
if (!wearDic.ContainsKey(itemInfo.toolId))
wearDic.Add(itemInfo.toolId, itemInfo);
}
else
{
if (wearDic.ContainsKey(itemInfo.toolId))
wearDic.Remove(itemInfo.toolId);
}
}
}