public static UserEngine Instance() { if (m_Instance == null) { m_Instance = new UserEngine(); } return m_Instance; }
//创建军团返回 public void CreateLegion_Ret(CreateLegion_Ret info) { LegionInfo le = null; for (int i = 0; i < mListTemp.Count; i++) { if (mListTemp[i].leader_id == info.play_id) { le = mListTemp[i]; le.id = (uint)info.legion_id; mListTemp.Remove(le); break; } } if (info == null || info.ret == 0 || le == null) { return; } PlayerObject play = UserEngine.Instance().FindPlayerObjectToPlayerId(info.play_id); if (play == null) { return; } //加入军团长 LegionMember member = new LegionMember(); member.boChange = true; member.members_name = play.GetName(); member.money = info.money; member.id = info.boss_id; member.rank = GameBase.Config.Define.LEGION_PLACE_JUNTUANZHANG; le.list_member.Add(member); Legion l = new Legion(); l.SetBaseInfo(le); mDicLegion[le.id] = l; play.GetLegionSystem().SetLegion(l, true); }
//取消交易 public void QuitTrad(NetMsg.MsgTradInfo info) { if (GetTradTarget() == 0) { return; } this.SetTrading(false); this.SetSureTradTag(false); PlayerObject obj = UserEngine.Instance().FindPlayerObjectToTypeID(GetTradTarget()); if (obj == null) { return; } this.SetTradTarget(0); obj.GetTradSystem().SetTradTarget(0); obj.GetTradSystem().SetTrading(false); obj.GetTradSystem().SetSureTradTag(false); }
// public void SetFriendTarget(uint typeid) // { // mTargetId = typeid; // } //public uint GetFriendTarget() { return mTargetId; } //添加好友 public void AddFriend(uint playerid, byte type, bool party = true) { PlayerObject target = UserEngine.Instance().FindPlayerObjectToPlayerId((int)playerid); if (target == null) { return; } for (int i = 0; i < mList.Count; i++) { if (mList[i].friendid == (uint)target.GetBaseAttr().player_id&& mList[i].friendtype == type) { if (mList[i].id != -1) //删除标识 { return; } else { mList.RemoveAt(i); break; } } } play.LeftNotice(string.Format("{0},{1}锸血为盟,宣誓从此将生死与共,永不背叛!", play.GetName(), target.GetName())); RoleData_Friend friend = new RoleData_Friend(); friend.id = 0; friend.friendid = (uint)target.GetBaseAttr().player_id; friend.friendtype = type; friend.friendname = target.GetName(); mList.Add(friend); SendFriendInfo(friend); if (party) { target.GetFriendSystem().AddFriend((uint)play.GetBaseAttr().player_id, type, false); } }
//确定交易 public void SureTrad() { PlayerObject obj = UserEngine.Instance().FindPlayerObjectToTypeID(GetTradTarget()); if (obj == null) { return; } play.GetTradSystem().SetSureTradTag(true); //通知对方已经确定交易了-- byte[] data = { 16, 0, 32, 4, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0 }; obj.GetGamePackKeyEx().EncodePacket(ref data, data.Length); obj.SendData(data); if (!obj.GetTradSystem().GetSureTradTag()) //对方还没确定交易 { return; } obj.GetTradSystem().Trad(play); play.GetTradSystem().Trad(obj); }
//请求加为好友 public void RequestAddFriend(NetMsg.MsgFriendInfo info) { PlayerObject target = UserEngine.Instance().FindPlayerObjectToTypeID(info.playerid); if (target == null) { play.LeftNotice("对方已离线,无法添加好友!"); return; } if (mList.Count >= MAX_FRIEND_COUNT) { play.LeftNotice("阁下好友人数已满,无法再次添加!"); return; } for (int i = 0; i < mList.Count; i++) { if (mList[i].friendid == target.GetBaseAttr().player_id) { play.ChatNotice(string.Format("{0}已经是你的好友了!", mList[i].friendname)); return; } } //发给被请求玩家 NetMsg.MsgFriendInfo data = new NetMsg.MsgFriendInfo(); data.Create(null, target.GetGamePackKeyEx()); data.playerid = (uint)play.GetBaseAttr().player_id; data.fightpower = (uint)play.GetFightSoul(); data.type = NetMsg.MsgFriendInfo.TYPE_ADDFRIEND; data.Online = 1; data.level = play.GetBaseAttr().level; data.name = play.GetName(); target.SendData(data.GetBuffer()); // target.GetFriendSystem().SetFriendTarget(play.GetTypeId()) ; play.LeftNotice("已经发送结为好友的请求"); target.LeftNotice(string.Format("血与火的洗礼证明了坚固的友谊,{0}对你报以信任的眼神,你是否接受?", play.GetName())); }
public void GetFriendInfo(int playerid) { PlayerObject obj = UserEngine.Instance().FindPlayerObjectToPlayerId(playerid); if (obj == null) { return; } GameBase.Network.PacketOut outpack = new GameBase.Network.PacketOut(play.GetGamePackKeyEx()); outpack.WriteUInt16(52); outpack.WriteUInt16(2033); outpack.WriteInt32(playerid); outpack.WriteUInt32(obj.GetBaseAttr().lookface); outpack.WriteByte(obj.GetBaseAttr().level); outpack.WriteByte(obj.GetBaseAttr().profession); //职业 outpack.WriteInt32(0); outpack.WriteInt16(0); outpack.WriteByte(206); outpack.WriteByte(222); byte[] data = new byte[30]; outpack.WriteBuff(data); play.SendData(outpack.Flush()); }
public void SetTradGameGold(int gamegold) { if (gamegold <= 0) { return; } PlayerObject obj = UserEngine.Instance().FindPlayerObjectToTypeID(GetTradTarget()); if (obj == null) { return; } mnGameGold = gamegold; //发给对方 PacketOut outpack = new PacketOut(obj.GetGamePackKeyEx()); outpack.WriteUInt16(16); outpack.WriteUInt16(1056); outpack.WriteInt32(mnGameGold); outpack.WriteInt32(12); outpack.WriteInt32(0); obj.SendData(outpack.Flush()); }
public void ProcessDBNetMsg() { if (!mbConnect && System.Environment.TickCount - mnReconnectTick > 5000)//五秒重连 { mTcpDBClient.ReConnect(); mnReconnectTick = System.Environment.TickCount; } byte[] buff = null; lock (_lock) { buff = mDBPacket.GetData(); } if (buff == null) { return; } PackIn inpack = new PackIn(buff); ushort param = inpack.ReadUInt16(); switch (param) { case GameBase.Network.Internal.Define.ROLEINFO: { GameBase.Network.Internal.RoleInfo roleinfo = new GameBase.Network.Internal.RoleInfo(buff); //判断是否有缓存数据- PlayerObject cacheplay = UserEngine.Instance().GetCachePlay(roleinfo.sAccount); if (cacheplay != null) { Log.Instance().WriteLog("检测到角色缓存数据,保存中!" + cacheplay.GetName()); UserEngine.Instance().RemoveCachePlay(cacheplay); cacheplay.ExitGame(); return; } UserEngine.Instance().AddTempPlayObject(roleinfo); //回发给dbserver 表示收到了角色信息- 让他通知loginserver 发数据给玩家连接mapserver GameBase.Network.Internal.RoleInfo_Ret ret = new GameBase.Network.Internal.RoleInfo_Ret(); ret.gameid = roleinfo.gameid; ret.key = roleinfo.mKey; ret.key2 = roleinfo.mKey1; ret.accountid = roleinfo.accountid; mTcpDBClient.SendData(ret.GetBuffer()); Log.Instance().WriteLog("收到临时角色信息:" + roleinfo.sAccount + " id:" + roleinfo.accountid.ToString()); break; } case GameBase.Network.Internal.Define.QUERYROLENAME_RET: { QueryRoleName_Ret ret = new QueryRoleName_Ret(); ret.Create(buff); TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(ret.gameid); if (temp == null) { Log.Instance().WriteLog("找到玩家对象..在--ProcessDBNetMsg code:2"); break; } NetMsg.MsgNotice notice = new NetMsg.MsgNotice(); notice.Create(null, temp.play.GetGamePackKeyEx()); temp.play.SendData(notice.GetQueryNameBuff(!ret.tag)); break; } case GameBase.Network.Internal.Define.CREATEROLE_RET: { CreateRole_Ret ret = new CreateRole_Ret(); ret.Create(buff); TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(ret.gameid); if (temp == null) { Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:3"); break; } UserEngine.Instance().RemoveTempPlayObject(ret.gameid); //从临时列表出移除-- //进入游戏 temp.play.GetBaseAttr().account_id = temp.accountid; temp.play.GetBaseAttr().player_id = ret.playerid; temp.play.EnterGame(null, true); break; } case GameBase.Network.Internal.Define.ADDROLEDATA_ITEM_RET: { GameBase.Network.Internal.AddRoleData_Item_Ret ret = new GameBase.Network.Internal.AddRoleData_Item_Ret(); ret.Create(buff); PlayerObject play = UserEngine.Instance().FindPlayerObjectToID(ret.gameid); if (play == null) { Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:4"); break; } play.GetItemSystem().AwardItem_Ret(ret.sordid, ret.id); break; } case GameBase.Network.Internal.Define.LOADROLEDATA_ITEM: { GameBase.Network.Internal.ROLEDATA_ITEM item = new GameBase.Network.Internal.ROLEDATA_ITEM(); item.Create(buff); TempPlayObject play = UserEngine.Instance().GetTempPlayObj(item.key, item.key2); if (play == null) { Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:5"); break; } for (int i = 0; i < item.mListItem.Count; i++) { play.play.GetItemSystem().AddItemInfo(item.mListItem[i]); } break; } case GameBase.Network.Internal.Define.LOADROLEDATA_MAGIC: { GameBase.Network.Internal.RoleData_Magic magic = new GameBase.Network.Internal.RoleData_Magic(); magic.Create(buff); TempPlayObject play = UserEngine.Instance().GetTempPlayObj(magic.key, magic.key2); if (play == null) { Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:6"); break; } for (int i = 0; i < magic.mListMagic.Count; i++) { GameBase.Network.Internal.MagicInfo info = magic.mListMagic[i]; play.play.GetMagicSystem().AddMagicInfo(info); } break; } case GameBase.Network.Internal.Define.KICKGAMEPLAY: { GameBase.Network.Internal.KickGamePlay kickplay = new GameBase.Network.Internal.KickGamePlay(); kickplay.Create(buff); PlayerObject play = UserEngine.Instance().FindPlayerObjectToAccountId(kickplay.accountid); if (play != null) { SessionManager.Instance().RemoveSession(play.GetGameSession().m_Socket); play.Kick(); } break; } case GameBase.Network.Internal.Define.LOADROLEDATA_EUDEMON: { GameBase.Network.Internal.ROLEDATE_EUDEMON eudemon = new GameBase.Network.Internal.ROLEDATE_EUDEMON(); eudemon.Create(buff); TempPlayObject play = UserEngine.Instance().GetTempPlayObj(eudemon.key, eudemon.key2); if (play == null) { //只是为了下断点后延迟问题解决方案 PlayerObject _play = UserEngine.Instance().FindPlayerObjectToPlayerId(eudemon.playerid); if (_play == null) { Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:6"); } else { _play.GetEudemonSystem().DB_Load(eudemon); _play.GetEudemonSystem().SendAllEudemonInfo(); } break; } else { play.play.GetEudemonSystem().DB_Load(eudemon); } break; } case GameBase.Network.Internal.Define.LOADROLEDATA_FRIEND: { GameBase.Network.Internal.ROLEDATA_FRIEND friend = new GameBase.Network.Internal.ROLEDATA_FRIEND(); friend.Create(buff); TempPlayObject play = UserEngine.Instance().GetTempPlayObj(friend.key, friend.key2); if (play == null) { //只是为了下断点后延迟问题解决方案 PlayerObject _play = UserEngine.Instance().FindPlayerObjectToPlayerId(friend.playerid); if (_play == null) { Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:7"); } else { _play.GetFriendSystem().DB_Load(friend); _play.GetFriendSystem().SendAllFriendInfo(); } break; } else { play.play.GetFriendSystem().DB_Load(friend); } break; } case GameBase.Network.Internal.Define.GUANJUEDATA: //爵位数据 { GameBase.Network.Internal.GUANJUEINFO juewei = new GameBase.Network.Internal.GUANJUEINFO(); juewei.Create(buff); GuanJueManager.Instance().DB_Load(juewei); break; } case GameBase.Network.Internal.Define.LOADLEGION: //军团数据 { GameBase.Network.Internal.LEGIONINFO info = new GameBase.Network.Internal.LEGIONINFO(); info.Create(buff); LegionManager.Instance().DB_Load(info); break; } case GameBase.Network.Internal.Define.CREATELEGION_RET: //创建军团返回数据 { GameBase.Network.Internal.CreateLegion_Ret info = new GameBase.Network.Internal.CreateLegion_Ret(); info.Create(buff); LegionManager.Instance().CreateLegion_Ret(info); break; } case GameBase.Network.Internal.Define.LOADPAYRECINFO: //充值数据 { GameBase.Network.Internal.PackPayRecInfo info = new GameBase.Network.Internal.PackPayRecInfo(); info.Creaet(buff); PayManager.Instance().DB_Load(info); break; } } }
public void Run() { //每半分钟一个轮循 if (System.Environment.TickCount - mRunTick > 1000 * 30) { mRunTick = System.Environment.TickCount; for (int i = 0; i < mListInfo.Count; i++) { if (DateTime.Now.Year != 0 && DateTime.Now.Year != mListInfo[i].year) { continue; } if (DateTime.Now.Month != 0 && DateTime.Now.Month != mListInfo[i].month) { continue; } if (DateTime.Now.Day != 0 && DateTime.Now.Day != mListInfo[i].day) { continue; } if (DateTime.Now.Hour != mListInfo[i].hour) { continue; } if (DateTime.Now.Minute != mListInfo[i].minute) { continue; } ScripteManager.Instance().ExecuteAction(mListInfo[i].script_id, null); mListInfo[i].bTag = true; } } //三十分钟- //恢复已运行的事件标记 if (System.Environment.TickCount - mClearTagTick > 1000 * 60 * 30) { mClearTagTick = System.Environment.TickCount; for (int i = 0; i < mListInfo.Count; i++) { if (DateTime.Now.Hour != mListInfo[i].hour && mListInfo[i].bTag) { mListInfo[i].bTag = false; } } } //每一秒一个轮询 if (mPlayTimeOut.ToNextTime() && mListPlayTimeOut.Count > 0) { int amount = mListPlayTimeOut.Count; while (amount > 0) { amount--; if (mListPlayTimeOut[amount].TimeOut.IsToNextTime() && mListPlayTimeOut[amount].IsOnline && mListPlayTimeOut[amount].callback_scripte_id > 0) { PlayerObject play = UserEngine.Instance().FindPlayerObjectToPlayerId(mListPlayTimeOut[amount].id); if (play == null) { continue; } ScripteManager.Instance().ExecuteAction(mListPlayTimeOut[amount].callback_scripte_id, play); mListPlayTimeOut.RemoveAt(amount); } } } }
public void ProcessNetMsg() { foreach (GameSession session in m_DicSession.Values) { if (session == null || session.m_GamePack == null) { continue; } byte[] retdata = session.m_GamePack.GetData(); if (retdata != null) { GameBase.Network.PackIn packin = new GameBase.Network.PackIn(retdata); PlayerObject play = UserEngine.Instance().FindPlayerObjectToID(session.gameid); ushort tag = packin.ReadUInt16(); if (play != null) { play.ProcessNetMsg(tag, retdata); continue; } //第一次的封包一定是更新key哒.. if (play == null && tag != PacketProtoco.C_UPDATEKEY && tag != PacketProtoco.C_QUERYCREATEROLENAME && tag != PacketProtoco.C_CREATEROLE) { continue; } switch (tag) { case PacketProtoco.C_UPDATEKEY: { int key = packin.ReadInt32(); int key2 = packin.ReadInt32(); TempPlayObject tempplay = UserEngine.Instance().GetTempPlayObj(key, key2); if (tempplay == null) { return; //没有经过loginsserver进入的非法封包 } tempplay.play.SetGameSession(session); session.GetGamePackKeyEx().SunUpdateKey(key, key2); NetMsg.MsgNotice msgNotice; //没有角色就创建角色 if (!tempplay.isRole) { msgNotice = new NetMsg.MsgNotice(); msgNotice.Create(null, session.GetGamePackKeyEx()); session.SendData(msgNotice.GetCreateRoleBuff()); return; } //有角色就进游戏 UserEngine.Instance().RemoveTempPlayObject(tempplay.play.GetGameID()); tempplay.play.EnterGame(session); break; } case PacketProtoco.C_QUERYCREATEROLENAME: //创建角色名查询 { NetMsg.MsgQueryCreateRoleName info = new NetMsg.MsgQueryCreateRoleName(); info.Create(retdata, null); int key = 0, key2 = 0; session.GetGamePackKeyEx().GetKey(ref key, ref key2); TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(key, key2); if (temp == null) { Log.Instance().WriteLog("找到玩家对象-在ProcessNetMsg code:1"); break; } //发给dbserver 查询 GameBase.Network.Internal.QueryRoleName query = new GameBase.Network.Internal.QueryRoleName(); query.gameid = temp.play.GetGameID(); query.name = info.GetName(); DBServer.Instance().GetDBClient().SendData(query.GetBuffer()); //NetMsg.MsgNotice notice = new NetMsg.MsgNotice(); //notice.Create(null, session.GetGamePackKeyEx()); //session.SendData(notice.GetQueryNameBuff()); break; } case PacketProtoco.C_CREATEROLE: //创建角色 { int key = 0, key2 = 0; session.GetGamePackKeyEx().GetKey(ref key, ref key2); TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(key, key2); if (temp == null) { Log.Instance().WriteLog("找到玩家对象-在ProcessNetMsg code:2"); break; } NetMsg.MsgCreateRoleInfo info = new NetMsg.MsgCreateRoleInfo(); info.Create(retdata, null); if (info.GetName().Length <= 0) { Log.Instance().WriteLog("角色名称为空!!"); break; } PlayerObject _play = temp.play; _play.SetGameSession(session); _play.SetName(info.GetName()); _play.GetBaseAttr().profession = (byte)info.profession; _play.GetBaseAttr().lookface = info.lookface; //发给dbserver GameBase.Network.Internal.CreateRole create = new GameBase.Network.Internal.CreateRole(); create.accountid = temp.accountid; create.lookface = info.lookface; create.name = info.GetName(); create.profession = (byte)info.profession; create.gameid = temp.play.GetGameID(); DBServer.Instance().GetDBClient().SendData(create.GetBuffer()); //测试游戏 //play = new PlayerObject(); //play.mapid = 1000; //play.mPoint.x = 400; //play.mPoint.y = 440; //session.gameid = play.GetGameID(); //MapManager.Instance().GetGameMapToID(play.mapid).AddObject(play, session); //UserEngine.Instance().AddPlayerObject(play); ////公告信息 //NetMsg.MsgNotice msgNotice = new NetMsg.MsgNotice(); //msgNotice.Create(null, session.GetGamePackKeyEx()); //session.SendData(msgNotice.GetStartGameBuff()); //byte[] roledata = {238, 3, 64, 66, 15, 0, 241, 73, 2, 0, 101, // 0, 0, 0, 60, 1, 0, 0, 0, 0, 0, 0, 81, 118, // 203, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 31, 1, 0, 0, 73, 0, 0, 0, 30, 0, 100, 0, 99, // 0, 102, 0, 0, 0, 202, 3, 222, 3, 134, 7, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 255, 10, 0, 0, 1, 0, 0, // 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 12, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 20, 0, 4, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, // 0, 0, 0, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0, 0, 0, 0, 2, 8, 102, 101, 111, 119, 102, 113, 101, 119, 2, // 206, 222, 0, 0, 0 }; ////session.GetGamePackKeyEx().EncodePacket(ref roledata, roledata.Length); ////session.SendData(roledata); //// //NetMsg.MsgSelfRoleInfo rolemsg = new NetMsg.MsgSelfRoleInfo(); //rolemsg.Create(roledata, session.GetGamePackKeyEx()); //rolemsg.roletype = 140001; //rolemsg.roleid = play.GetTypeId(); //rolemsg.name = "测试角色" + play.GetTypeId().ToString(); //play.Name = rolemsg.name; //session.SendData(rolemsg.GetBuffer()); ////测试增加装备 测试装备 //NetMsg.MsgItemInfo item = new NetMsg.MsgItemInfo(); //item.Create(null, session.GetGamePackKeyEx()); //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_ARMOR; //item.id = 112434; //item.item_id = 135114; //item.amount = item.amount_limit = 1; //session.SendData(item.GetBuffer()); ////测试武器 //item = new NetMsg.MsgItemInfo(); //item.Create(null, session.GetGamePackKeyEx()); //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_WEAPONR; //item.id = 112435; //item.item_id = 440244; //item.amount = item.amount_limit = 1; //session.SendData(item.GetBuffer()); //NetMsg.MsgUpdateSP sp = new NetMsg.MsgUpdateSP(); //sp.Create(null, session.GetGamePackKeyEx()); //sp.role_id = play.GetTypeId(); //sp.value = 37; //sp.sp = 100; //session.SendData(sp.GetBuffer()); //sp = new NetMsg.MsgUpdateSP(); //sp.Create(null, session.GetGamePackKeyEx()); //sp.role_id = play.GetTypeId(); //session.SendData(sp.GetBuffer()); ////测试新增技能 //ushort[] skill = { 3011 };//, 3002, 1010, 3005, 3009, 8003 //for (int i = 0; i < skill.Length; i++) //{ // NetMsg.MsgMagicInfo magicinfo = new NetMsg.MsgMagicInfo(); // magicinfo.Create(null, session.GetGamePackKeyEx()); // magicinfo.id = play.GetTypeId(); // magicinfo.magicid = skill[i]; // magicinfo.level = 2; // session.SendData(magicinfo.GetBuffer()); //} ////进入地图 //NetMsg.MsgMapInfo mapinfo = new NetMsg.MsgMapInfo(); //mapinfo.Create(null, session.GetGamePackKeyEx()); //mapinfo.Init(play.mapid, play.mPoint.x, play.mPoint.y); //session.SendData(mapinfo.GetBuffer()); ////刷新可视列表; //play.RefreshVisibleObject(); //GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE); //play.PushAction(act); break; } } } } }
public static void Stop() { UserEngine.Instance().Stop(); mTcpServer.Dispose(); SessionManager.Instance().Dispose(); }
//添加交易道具 public void AddTradItem(uint itemid) { PlayerObject obj = UserEngine.Instance().FindPlayerObjectToTypeID(GetTradTarget()); RoleData_Eudemon eudemon = null; if (obj == null) { return; } GameStruct.RoleItemInfo info = null; if (itemid >= IDManager.eudemon_start_id) { eudemon = play.GetEudemonSystem().FindEudemon(itemid); if (eudemon == null) { return; } info = play.GetItemSystem().FindItem(eudemon.itemid); } else { info = play.GetItemSystem().FindItem(itemid); } if (info == null) { return; } //最多二十个道具 if (mListItem.Count >= 20) { return; } //对面包裹满了- if (info.postion == NetMsg.MsgItemInfo.ITEMPOSITION_BACKPACK) { if (obj.GetItemSystem().IsItemFull()) { play.LeftNotice("对方物品栏已满,无法放置更多道具"); return; } }//幻兽栏已满 else if (info.postion == NetMsg.MsgItemInfo.ITEMPOSITION_EUDEMON_PACK) { if (obj.GetEudemonSystem().IsEudemonFull()) { play.LeftNotice("对方幻兽栏已满,无法放置更多道具"); return; } } mListItem.Add(info); //幻兽数据 //发给对方道具数据 obj.GetItemSystem().SendItemInfo(info, NetMsg.MsgItemInfo.TAG_TRADITEM); if (info.postion == NetMsg.MsgItemInfo.ITEMPOSITION_EUDEMON_PACK) { eudemon = play.GetEudemonSystem().FindEudemon(itemid); if (eudemon != null) { mListEudemon.Add(eudemon); play.GetEudemonSystem().SendLookTradEudemonInfo(obj, eudemon); } } }