using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 负责工具材料包管理
///
public class PacksackBagMgr : BaseManager
{
//包里用了哪些工器具
private readonly Dictionary toolAndMaterialDic =
new Dictionary();
private PacksackBagMgr()
{
}
public Dictionary GetCurrentBagData()
{
return toolAndMaterialDic;
}
///
/// 添加一个工器具或材料
///
///
public void AddOneToolOrMater(string name)
{
if (toolAndMaterialDic.ContainsKey(name))
{
toolAndMaterialDic[name].count++;
}
else
{
//从配置里得知是tool or Material
var tempToolOrMaterType = GameManager.ToolAndmaterialMgr.GetObjType(name);
if (tempToolOrMaterType == -1) return;
var tempToolAndMaterData = new ToolAndMaterialData()
{ count = 1, objName = name, type = tempToolOrMaterType };
toolAndMaterialDic.Add(name, tempToolAndMaterData);
}
}
///
/// 移除一个工器具或材料
///
///
public void RemoveOneToolOrMater(string name)
{
if (toolAndMaterialDic.ContainsKey(name))
{
var toolAndMaterCount = toolAndMaterialDic[name].count--;
if (toolAndMaterCount <= 0)
{
toolAndMaterialDic.Remove(name);
}
}
}
}