/** 删除指定道具 */ public bool reduceProp(StorageProp prop) { for (int i = 0, l = space.Count; i < l; i++) { StorageProp sp = space [i] as StorageProp; if (sp.equal(prop)) { if (sp.isU) { space.RemoveAt(i); return(true); } else if (sp.getNum() >= prop.getNum()) { sp.reduceNum(prop.getNum()); return(true); } else { return(false); } } } return(false); }
/** 检查能否添加一个道具, * 不考虑添加相同uid的道具, * 不考虑堆叠上限问题 */ public bool checkAddProp(StorageProp prop) { if (checkSize(1)) { return(true); } if (prop.isU) { return(false); } for (int i = 0, l = space.Count; i < l; i++) { StorageProp sp = space [i] as StorageProp; if (sp.equal(prop)) { return(true); } } return(false); }
/** 添加道具 */ public bool addProp(StorageProp prop) { if (!prop.isU) { for (int i = 0, l = space.Count; i < l; i++) { StorageProp sp = space [i] as StorageProp; if (sp.equal(prop)) { sp.addNum(prop.getNum()); return(true); } } } if (checkSize(1)) { space.Add(prop); return(true); } else { return(false); } }