/** 删除指定道具 */ 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); }
/** 添加道具在最后的位置 */ public bool addPropLast(StorageProp prop) { if (!checkSize(1)) { return(false); } space.Add(prop); return(true); }
/** 检查能否删除指定sid指定数量的道具 */ public bool checkReducePropBySid(int sid, int num) { StorageProp sp = getPropBySid(sid); if (sp != null && sp.getNum() >= num) { return(true); } return(false); }
/** 检查能否删除指定uid的道具 */ public bool checkReducePropByUid(string uid) { StorageProp sp = getPropByUid(uid); if (sp != null) { return(true); } return(false); }
/** 获得指定索引的道具,返回道具数组,没有找到的补null */ public StorageProp[] getPropByIndex(int[] indexs) { int l = indexs.Length; StorageProp[] sps = new StorageProp[l]; for (int i = 0; i < l; i++) { sps [i] = getPropByIndex(indexs [i]); } return(sps); }
/** 获得指定uid的道具,返回道具数组,没有找到的补null */ public StorageProp[] getPropByUid(string[] uids) { int l = uids.Length; StorageProp[] sps = new StorageProp[l]; for (int i = 0; i < l; i++) { sps [i] = getPropByUid(uids [i]); } return(sps); }
/** 获得指定sid的道具,返回道具数组,没有找到的补null */ public StorageProp[] getPropBySid(int[] sids) { int l = sids.Length; StorageProp[] sps = new StorageProp[l]; for (int i = 0; i < l; i++) { sps [i] = getPropBySid(sids [i]); } return(sps); }
// **********************public method******************************** / /** 获得指定索引的道具 */ public StorageProp getPropByIndex(int index) { if (space.Count > index) { StorageProp sp = space [index] as StorageProp; sp.index = index; return(sp); } else { return(null); } }
/** 获得指定sid的道具 */ public StorageProp getPropBySid(int sid) { for (int i = 0, l = space.Count; i < l; i++) { StorageProp sp = space [i] as StorageProp; if (sp.sid == sid) { sp.index = i; return(sp); } } return(null); }
/** 删除指定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 checkReducePropByIndex(int index, int num) { StorageProp sp = getPropByIndex(index); if (sp != null) { if (sp.isU) { return(true); } else if (sp.getNum() >= num) { return(true); } } return(false); }
/** 删除指定uid的道具 */ public bool reducePropByUid(string uid) { StorageProp sp = getPropByUid(uid); if (sp != null) { if (sp is Card) { Card card = sp as Card; card.putOffEquip(); // card.delStarSoulBoreByAll (); } space.RemoveAt(sp.index); 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); }
/** 检查能否添加一个道具, * 不考虑添加相同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); } }
/** 比较两个道具是否是相同道具,子类必须重写此方法 */ public virtual bool equal(StorageProp prop) { return(false); }
public override bool equal(StorageProp prop) { return(this.uid == prop.uid); }
public override bool equal(StorageProp prop) { return(this.tempUid == (prop as TempProp).tempUid); }