public void Push(GameObject obj) { if (obj.GetComponent <Self_class>() == null) { Debug.Log("Wrong Target!"); return; } if (_NowSize >= Size) { return; } Item objc = new Item(obj.GetComponent <Self_class>().s_id, obj.GetComponent <Self_class>().s_iCount); if (Bagspace.Contains(objc.Id)) { Item temp = (Item)Bagspace[objc.Id]; temp.Count += objc.Count; Bagspace[objc.Id] = temp; } else { _NowSize++; Bagspace.Add(objc.Id, objc); } }
public void Delete(int Id) { if (!Bagspace.Contains(Id)) { Debug.Log("Wrong Target"); return; } Bagspace.Remove(Id); _NowSize--; }
public int GetCount(int Id) { if (!Bagspace.Contains(Id)) { return(0); } Item temp = (Item)Bagspace[Id]; return(temp.Count); }
public void Sub(int Id, int subcount = 1) { if (!Bagspace.Contains(Id)) { Debug.Log("Wrong Target"); return; } Item temp = (Item)Bagspace[Id]; if (temp.Count - subcount <= 0) { Delete(Id); } else { temp.Count -= subcount; Bagspace[Id] = temp; } }
public bool Query(int Id) { return(Bagspace.Contains(Id)); }
public void Clear() { Bagspace.Clear(); _NowSize = 0; }