Пример #1
0
        /// <summary>
        /// 删除物品。
        /// </summary>
        /// <param name="data">网络消息数据。</param>
        private void OnItemDel(MsgData data)
        {
            MsgData_sItemDel info = data as MsgData_sItemDel;
            BagInfo          bag  = GetBagInfo(info.Bag);

            if (bag != null)
            {
                ItemInfo iteminfo = bag.GetItemInfo(info.Pos);
                if (mCacheAddUID == iteminfo.UID)
                {
                    //抵消前一个Add
                    mCacheAddUID = 0;
                }
                else
                {
                    mItems.Remove(iteminfo.UID);
                }
                bag.DeleteItem(info.Pos);
                TriggerEventItemDel(1, info.Bag, info.Pos, iteminfo.UID);
            }
            else
            {
                LogMgr.ErrorLog("未知背包编号 id:{0}", info.Bag);
            }
        }
Пример #2
0
        private void OnMoShenItemResult(MsgData data)
        {
            MsgData_sMoShenItemResult info = data as MsgData_sMoShenItemResult;

            if (info.Result == 0)
            {
                for (int i = 0; i < info.ResultList.Count; i++)
                {
                    //交换物品成功 先将物品从背包移除,再放入对方背包
                    BagInfo srcbag = GetBagInfo(info.ResultList[i].SrcBag);
                    BagInfo dstbag = GetBagInfo(info.ResultList[i].DstBag);
                    if (dstbag == null)
                    {
                        return;
                    }
                    if (srcbag == null)
                    {
                        return;
                    }
                    ItemInfo srciteminfo = srcbag.GetItemInfo(info.ResultList[i].SrcPos);
                    ItemInfo dstiteminfo = dstbag.GetItemInfo(info.ResultList[i].DstPos);

                    srcbag.DeleteItem(info.ResultList[i].SrcPos);
                    dstbag.DeleteItem(info.ResultList[i].DstPos);
                    if (srciteminfo != null)
                    {
                        srciteminfo.Bag = info.ResultList[i].DstBag;
                        srciteminfo.Pos = info.ResultList[i].DstPos;
                        dstbag.AddItem(srciteminfo);
                    }
                    if (dstiteminfo != null)
                    {
                        dstiteminfo.Bag = info.ResultList[i].SrcBag;
                        dstiteminfo.Pos = info.ResultList[i].SrcPos;
                        srcbag.AddItem(dstiteminfo);
                    }
                }
            }
            EventParameter par = EventParameter.Get();

            par.intParameter = info.Result;
            CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_CC_MOSHEN_BAGCHANGEOVER, par);
        }
Пример #3
0
        /// <summary>
        /// 交换物品回复。
        /// </summary>
        /// <param name="data">网络消息数据。</param>
        private void OnSwapItem(MsgData data)
        {
            MsgData_sSwapItemResult info = data as MsgData_sSwapItemResult;

            LogMgr.Log("交换物品回复 srcbag:{0} desbag:{1} srcpos:{2} dstpos:{3}", info.SrcBag, info.DstBag, info.SrcPos, info.DstPos);
            if (info.Result == 0)
            {
                //交换物品成功 先将物品从背包移除,再放入对方背包
                BagInfo srcbag = GetBagInfo(info.SrcBag);
                BagInfo dstbag = GetBagInfo(info.DstBag);
                if (dstbag == null)
                {
                    return;
                }
                if (srcbag == null)
                {
                    return;
                }
                ItemInfo srciteminfo = srcbag.GetItemInfo(info.SrcPos);
                ItemInfo dstiteminfo = dstbag.GetItemInfo(info.DstPos);

                srcbag.DeleteItem(info.SrcPos);
                dstbag.DeleteItem(info.DstPos);

                if ((info.DstBag == (int)BagType.ITEM_BAG_TYPE_EQUIP || info.DstBag == (int)BagType.ITEM_BAG_TYPE_RIDE) && srciteminfo != null)
                {
                    SG.CoreEntry.gAudioMgr.PlayUISound(900011);
                }
                if (srciteminfo != null)
                {
                    srciteminfo.Bag = info.DstBag;
                    srciteminfo.Pos = info.DstPos;
                    dstbag.AddItem(srciteminfo);
                    if (dstbag.BagType == BagType.ITEM_BAG_TYPE_EQUIP)
                    {
                        ShowEquipChange(srciteminfo.ID);
                    }
                }
                if (dstiteminfo != null)
                {
                    dstiteminfo.Bag = info.SrcBag;
                    dstiteminfo.Pos = info.SrcPos;
                    srcbag.AddItem(dstiteminfo);
                }

                if (srciteminfo != null && dstiteminfo != null)
                {
                    //两者不为空,两边更新
                    TriggerEventItemUpdate(info.SrcBag, info.SrcPos);
                    TriggerEventItemUpdate(info.DstBag, info.DstPos);
                }
                else if (srciteminfo != null)
                {
                    //源背包删除 目标背包添加
                    TriggerEventItemDel(2, info.SrcBag, info.SrcPos, srciteminfo.UID);
                    TriggerEventItemAdd(info.DstBag, info.DstPos);
                }
                else if (dstiteminfo != null)
                {
                    //源背包添加 目标背包删除
                    TriggerEventItemAdd(info.SrcBag, info.SrcPos);
                    TriggerEventItemDel(2, info.DstBag, info.DstPos, dstiteminfo.UID);
                }
            }
            EventParameter par = EventParameter.Get(data);

            CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_CC_BAGCHANGEOVER, par);
        }