public bool UseBagChip(int id, int num) { XItem item = GTDataManager.Instance.GetItemDataById(id); if (item == null) { return(false); } if (item.Num < num) { return(false); } item.Num -= num; if (item.Num < 1) { int pos = item.Pos; DataDBSBagChip.Delete(pos); } else { DataDBSBagChip.Update(item.Pos, item); } return(true); }
public void AddChip(int id, int num) { XItem item = GTDataManager.Instance.GetItemDataById(id); if (item == null) { int newPos = GetNewPos(EBagType.CHIP); if (newPos != 0) { this.MaxInstance++; item = new XItem(); item.Instance = this.MaxInstance; item.Pos = newPos; item.Id = id; item.Num = num; item.PosType = (int)EPosType.BagChip; DataDBSBagChip.Insert(newPos, item); } } else { item.Num += num; DataDBSBagChip.Update(item.Pos, item); } }