Example #1
0
    public void AddChip(int id, int num)
    {
        XItem item = DataManager.Instance.GetItemDataById(id);

        if (item == null)
        {
            int newPos = GetNewPos(EBagType.CHIP);
            if (newPos != 0)
            {
                DataManager.Instance.MaxInstance++;
                item          = new XItem();
                item.Instance = DataManager.Instance.MaxInstance;
                item.Pos      = newPos;
                item.Id       = id;
                item.Num      = num;
                item.PosType  = (int)EPosType.BagChip;
                DataBagChip.Insert(newPos, item);
            }
        }
        else
        {
            item.Num += num;
            DataBagChip.Update(item.Pos, item);
        }
    }
Example #2
0
    public bool UseBagChip(int id, int num)
    {
        XItem item = DataManager.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;
            DataBagChip.Delete(pos);
        }
        else
        {
            DataBagChip.Update(item.Pos, item);
        }

        return(true);
    }