コード例 #1
0
        //-------------------------------------------------------------------------
        public ItemOperateResponseData operateItem(ItemOperate item_operate)
        {
            // 执行使用道具操作
            ItemOperateResponseData result = new ItemOperateResponseData();

            result.result     = ProtocolResult.Failed;
            result.operate_id = item_operate.operate_id;
            result.item_objid = item_operate.item_objid;

            Item item = null;

            mMapItem.TryGetValue(item_operate.item_objid, out item);
            if (item == null)
            {
                return(result);
            }
            item.operate(item_operate.operate_id);

            // 检测是否需要删除道具
            if (item.ItemData.n <= 0)
            {
                mMapItem.Remove(item_operate.item_objid);
                Dictionary <string, ItemData> map_itemdata4db = Def.mPropMapItemData4Db.get();
                map_itemdata4db.Remove(item_operate.item_objid);
            }

            result.result = ProtocolResult.Success;
            return(result);
        }
コード例 #2
0
        //-------------------------------------------------------------------------
        void _s2cOnOperateItem(ItemOperateResponseData result)
        {
            if (result.result != ProtocolResult.Success)
            {
                //string msg = "使用道具失败!";
                //FloatMsgInfo f_info;
                //f_info.msg = msg;
                //f_info.color = Color.green;
                //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info);
                return;
            }

            Item item = null;

            mMapItem.TryGetValue(result.item_objid, out item);
            if (item == null)
            {
                return;
            }

            // 使用道具成功提示
            if (item.TbDataItem.MainOperateInfo.OperateId == result.operate_id)
            {
                //string msg = item.TbDataItem.MainOperateInfo.OperateName + ":" + item.TbDataItem.Name;
                //FloatMsgInfo f_info;
                //f_info.msg = msg;
                //f_info.color = Color.green;
                //UiMgr.Instance.FloatMsgMgr.createFloatMsg(f_info);
            }

            if (result.overlap_num <= 0)
            {
                mMapItem.Remove(result.item_objid);
            }
            item.ItemData.n = result.overlap_num;

            // 广播消息通知Ui更新
            //var e = UiMgr.Instance.getEventPublisherEntityToUi().genEvent<EvEntityBagOperateItem>();
            //e.item = item;
            //e.send(null);
        }