/** 删除指定道具 */ 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); }
/** 删除指定sid指定数量的道具 */ public bool reducePropBySid(int sid, int num) { StorageProp sp = getPropBySid(sid); if (sp != null && sp.getNum() >= num) { sp.reduceNum(num); if (sp.getNum() < 1) { space.Remove(sp); } return(true); } return(false); }
/** 删除指定索引的道具 */ public bool reducePropByIndex(int index, int num) { StorageProp sp = getPropByIndex(index); if (sp != null) { if (sp.isU) { space.RemoveAt(index); return(true); } else if (sp.getNum() >= num) { sp.reduceNum(num); return(true); } } return(false); }