//缓存商店可看到的其他玩家 public void ChechTemp(Exchange _this, StoreBroadcastList temp) { _this.ChechTempList = temp; _this.ChechOverTime = DateTime.FromBinary(temp.CacheOverTime); //DateTime.Now.AddMinutes(Exchange.RefreshCDTime); }
//获取下一个ID private long GetNextId(Exchange _this) { _this.mDbData.NextItem++; return(_this.mDbData.NextItem); }
//商店放入一个道具 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); }