Exemplo n.º 1
0
 public void ExchangeItem(ExchangeItem _this, CharacterController character, long guid, ItemBaseData item)
 {
     _this.mCharacter       = character;
     _this.mDbdata          = new DBStoreLogicOne();
     _this.mDbdata.Id       = guid;
     _this.mDbdata.ItemData = item;
 }
Exemplo n.º 2
0
 public void ResetData(ExchangeItem _this, long guid, ItemBaseData itemBase, int needCount)
 {
     _this.mDbdata.Id        = guid;
     _this.mDbdata.ItemData  = itemBase;
     _this.mDbdata.StartTime = DateTime.Now.ToBinary();
     _this.mDbdata.NeedCount = needCount;
     _this.State             = StoreItemType.Normal;
 }
Exemplo n.º 3
0
 //商店放入一个道具
 public ErrorCodes PushItem(int type,
                            int bagId,
                            int bagIndex,
                            int count,
                            int needtype,
                            int needCount,
                            int storeIndex,
                            ref ExchangeItem resultItem)
 {
     return(mImpl.PushItem(this, type, bagId, bagIndex, count, needtype, needCount, storeIndex, ref resultItem));
 }
Exemplo n.º 4
0
 //重新设置商店的空格
 public void ResetCount(Exchange _this, int count)
 {
     if (_this.mDataList.Count > count)
     {
         return;
     }
     for (var i = _this.mDataList.Count; i < count; ++i)
     {
         var temp = new ExchangeItem(_this.mCharacter);
         _this.mDataList.Add(temp);
         _this.mDbData.StoreItems.Add(temp.mDbdata);
     }
 }
Exemplo n.º 5
0
 public void InitByDB(Exchange _this, CharacterController character, DBCharacterStoreData storeData)
 {
     _this.mCharacter = character;
     _this.mDbData    = storeData;
     foreach (var dbItem in storeData.StoreItems)
     {
         var item = new ExchangeItem(character, dbItem);
         _this.mDataList.Add(item);
         if (item.State != StoreItemType.Free)
         {
             _this.mData.Add(dbItem.Id, item);
         }
         _this.AddChild(item);
     }
 }
Exemplo n.º 6
0
        //收回一个商店放入的道具
        public ErrorCodes CancelItem(Exchange _this, long id, ref ExchangeItem resultItem)
        {
            ExchangeItem eItem;

            if (_this.mData.TryGetValue(id, out eItem))
            {
                if (eItem.State == StoreItemType.Normal)
                {
                    var result = _this.mCharacter.mBag.CheckAddItem(eItem.ItemId, eItem.ItemCount);
                    if (result != ErrorCodes.OK)
                    {
                        return(result);
                    }
                    _this.mCharacter.mBag.AddItem(eItem.mDbdata.ItemData, eCreateItemType.ExchangeCancel);
                    eItem.State = StoreItemType.Free;
                    resultItem  = eItem;
                    _this.mData.Remove(id);
                    return(ErrorCodes.OK);
                }
                return(ErrorCodes.Error_ExchangeItemState);
            }
            return(ErrorCodes.Error_ItemNotFind);
        }
Exemplo n.º 7
0
 //收回一个商店放入的道具
 public ErrorCodes CancelItem(long id, ref ExchangeItem resultItem)
 {
     return(mImpl.CancelItem(this, id, ref resultItem));
 }
Exemplo n.º 8
0
 public void ExchangeItem(ExchangeItem _this, CharacterController character, DBStoreLogicOne dbdata)
 {
     _this.mCharacter = character;
     _this.mDbdata    = dbdata;
 }
Exemplo n.º 9
0
 public void ExchangeItem(ExchangeItem _this, CharacterController character)
 {
     _this.mCharacter    = character;
     _this.mDbdata       = new DBStoreLogicOne();
     _this.mDbdata.State = (int)StoreItemType.Free;
 }
Exemplo n.º 10
0
        //商店放入一个道具
        public ErrorCodes PushItem(Exchange _this,
                                   int type,
                                   int bagId,
                                   int bagIndex,
                                   int count,
                                   int needType,
                                   int needCount,
                                   int storeIndex,
                                   ref ExchangeItem resultItem)
        {
            //参数条件检查
            var bag = _this.mCharacter.mBag.GetBag(bagId);

            if (bag == null)
            {
                return(ErrorCodes.Error_BagID);
            }
            var item = bag.GetItemByIndex(bagIndex);

            if (item == null || item.GetId() == -1)
            {
                return(ErrorCodes.Error_ItemNotFind);
            }
            if (storeIndex < 0 || storeIndex >= _this.mDataList.Count)
            {
                return(ErrorCodes.Error_DataOverflow);
            }
            if (item.GetCount() < count)
            {
                return(ErrorCodes.Error_CountNotEnough);
            }
            var storeItem = _this.mDataList[storeIndex];

            if (storeItem.State != StoreItemType.Free)
            {
                return(ErrorCodes.Error_ExchangeItemState);
            }
            var tbItem = Table.GetItemBase(item.GetId());

            if (tbItem == null)
            {
                return(ErrorCodes.Error_ItemID);
            }


            var equip = item as ItemEquip2;

            if (equip != null)
            {
                if (equip.GetBinding())
                {
                    return(ErrorCodes.Error_ItemNoExchange);
                }
            }
            if (type != -1)
            {
                if (!BitFlag.GetLow(tbItem.CanTrade, 0))
                {
                    return(ErrorCodes.Error_ItemNoExchange);
                }

                if (needType == 0)
                {
                    if (tbItem.BuyNeedCount * count > needCount)
                    {
                        return(ErrorCodes.Error_ExchangeValueNotEnough);
                    }
                }
                else if (needType == 1)
                {
                    if (needCount < StaticParam.AuctionMinValue)
                    {
                        return(ErrorCodes.Error_ExchangeValueNotEnough);
                    }
                }
                else
                {
                    Logger.Error("PushItem type={0},needType={1}", type, needType);
                }
            }
            else
            {
                if (!BitFlag.GetLow(tbItem.CanTrade, 1))
                {
                    return(ErrorCodes.Error_ItemNoExchange);
                }

                if (needType == 10)
                {
                    if (tbItem.BuyNeedCount * count > needCount)
                    {
                        return(ErrorCodes.Error_ExchangeValueNotEnough);
                    }
                }
                else if (needType == 11)
                {
                    if (needCount < StaticParam.AuctionMinValue)
                    {
                        return(ErrorCodes.Error_ExchangeValueNotEnough);
                    }
                }
                else
                {
                    Logger.Error("PushItem type={0},needType={1}", type, needType);
                }
            }
            //是否有消耗
            switch (type)
            {
            case -1:     //拍卖行
                break;

            case 0:     //正常不广播
                break;

            case 1:     //正常广播
            {
                if (DateTime.FromBinary(_this.mDbData.NextFreeTime) > DateTime.Now)
                {
                    return(ErrorCodes.Error_ExchangeFreeBroadcast);
                }
                _this.mDbData.NextFreeTime = DateTime.Now.AddSeconds(GetBroadcastCD(_this)).ToBinary();
            }
            break;

            case 2:     //购买广播
            {
                if (DateTime.FromBinary(_this.mDbData.NextFreeTime) > DateTime.Now)
                {
                    if (_this.mCharacter.mBag.GetRes(eResourcesType.DiamondRes) < Exchange.BuyBroadcastNeedRes)
                    {
                        return(ErrorCodes.DiamondNotEnough);
                    }
                    _this.mCharacter.mBag.DelRes(eResourcesType.DiamondRes, Exchange.BuyBroadcastNeedRes,
                                                 eDeleteItemType.ExchangeBroadcast);
                    _this.mDbData.NextFreeTime = DateTime.Now.AddSeconds(GetBroadcastCD(_this)).ToBinary();
                }
            }
            break;
            }
            //执行
            var guid         = GetNextId(_this);
            var itemBaseData = new ItemBaseData();

            itemBaseData.ItemId = item.GetId();
            itemBaseData.Count  = count;
            item.CopyTo(itemBaseData.Exdata);
            storeItem.ResetData(guid, itemBaseData, needCount);
            storeItem.NeedType = needType;
            if (type == -1)
            {
                bag.ReduceCountByIndex(bagIndex, count, eDeleteItemType.AuctionPush);
            }
            else
            {
                bag.ReduceCountByIndex(bagIndex, count, eDeleteItemType.ExchangePush);
            }
            _this.mData.Add(guid, storeItem);
            resultItem = storeItem;
            return(ErrorCodes.OK);
        }