public void RPC_ItemAdd2Bag(RPC.PackageWriter pkg, CSCommon.Data.ItemData data, System.Byte bag, System.UInt16 pos) { pkg.Write(data); pkg.Write(bag); pkg.Write(pos); pkg.SetMethod(4); }
public void RPC_Whisper(string targetName, string msg, RPC.DataReader hyperlink, RPC.RPCForwardInfo fwd) { sbyte success = 0; RPC.DataWriter data = new RPC.DataWriter(); if (hyperlink != null) { hyperlink.Read(out success); data.Write(success); if (success == (sbyte)1)//物品 { CSCommon.Data.ItemData item = new CSCommon.Data.ItemData(); hyperlink.Read(item, true); data.Write(item, true); } } msg = CheckMaskWord(msg); RPC.PackageWriter pkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_SayToRole(pkg, this.Id, targetName, msg, data); pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut) { sbyte result = -1; _io.Read(out result); if (result < 0) { SendTalkMsg2Client(this, (sbyte)CSCommon.eSayChannel.WhisperChannel, "", "无效发送对象", new RPC.DataWriter()); } else { SendTalkMsg2Client(this, (sbyte)CSCommon.eSayChannel.WhisperChannel, this.RoleName, msg, data); } }; }
public void RPC_SayToRole(ulong roleId, string tarName, string msg, RPC.DataReader hyperlink, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd) { sbyte success = 0; RPC.DataWriter data = new RPC.DataWriter(); if (hyperlink != null) { hyperlink.Read(out success); data.Write(success); if (success == (sbyte)1)//物品 { CSCommon.Data.ItemData item = new CSCommon.Data.ItemData(); hyperlink.Read(item, true); data.Write(item, true); } } RPC.PackageWriter pkg = new RPC.PackageWriter(); var tarRole = GetRole(tarName); if (tarRole == null) { pkg.Write((sbyte)-1); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } if (tarRole.PlanesConnect == null) { pkg.Write((sbyte)-2); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } var role = GetRole(roleId); if (role == null) { Log.Log.Common.Print("RPC_SayToRole role is null,{0}", roleId); pkg.Write((sbyte)-3); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } if (tarRole.RoleData.RoleId == roleId) { pkg.Write((sbyte)-4); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); return; } RPC.PackageWriter retPkg = new RPC.PackageWriter(); H_RPCRoot.smInstance.HGet_PlanesServer(retPkg).RPC_DSTalkMsg(retPkg, tarRole.RoleData.PlanesId, role.RoleData.Name, (sbyte)CSCommon.eSayChannel.WhisperChannel, tarRole.RoleData.RoleId, msg, data); retPkg.DoCommand(tarRole.PlanesConnect, RPC.CommandTargetType.DefaultType); pkg.Write((sbyte)1); pkg.DoReturnCommand2(connect, fwd.ReturnSerialId); }
public sbyte UpdateItem(ulong roleId, CSCommon.Data.ItemData item) { var pd = this.PlayerManager.FindPlayerData(roleId); if (pd == null) { return(-1); } string condition = "ItemId = " + item.ItemId; ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.ReplaceData(condition, item, true); Thread.DBConnectManager.Instance.PushSave(pd, dbOp); return(1); }
public static Item DangerousCreateItemById(RoleActor owner, int templateId, int stackNum) { CSCommon.Data.ItemData data = new CSCommon.Data.ItemData(); data.ItemTemlateId = templateId; data.StackNum = stackNum; if (owner != null) { data.OwnerId = owner.Id; } data.ItemId = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.Item); data.CreateTime = System.DateTime.Now; Item result = new Item(data); return(result); }
public static bool CheckTaskItem(RoleActor picker, CSCommon.Data.ItemData itemData) { // PlayerInstance player = picker as PlayerInstance; // if (player == null) // return false; // // foreach (var i in player.TaskManager.AcceptTasks) // { // var conditions = i.TaskData.Template.KillCondition; // for (sbyte j = 0; j < conditions.Count; j++) // { // if (conditions[j].DropItem == itemData.ItemTemlateId && player.Bag.GetItemCount(conditions[j].DropItem) <= conditions[j].Number) //我接了调这个物品的任务,并且任务物品不够时 // return true; // } // } return(false); }
public static Item DangerousCreateItem(RoleActor owner, CSCommon.Data.ItemData data, bool bAllocItemId) { if (data.Template == null) { return(null); } data.Inventory = (byte)CSCommon.eItemInventory.Unknown; if (owner != null) { data.OwnerId = owner.Id; } if (bAllocItemId) { data.ItemId = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.Item); data.CreateTime = System.DateTime.Now; } Item result = new Item(data); return(result); }
public void UpdateItem(RPC.PackageWriter pkg, System.UInt64 roleId, CSCommon.Data.ItemData item) { pkg.Write(roleId); pkg.Write(item); pkg.SetMethod(9); }
public Item(CSCommon.Data.ItemData item) { mItemTemplate = item.Template; mItemData = item; mPosition = item.Position; }
// 生成代码 private void button4_Click(object sender, EventArgs e) { bool bIsClient = this.textBox_Callee.Text == Config.Instance.CurProjectConfig.ClientCallee; if (System.IO.File.Exists(this.textBox_Callee.Text)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(this.textBox_Callee.Text); if (sw != null) { if (bIsClient) { sw.Write(this.textBoxCallee.Text.Replace("SlimDX", "UnityEngine")); } else { sw.Write(this.textBoxCallee.Text); } sw.Close(); } } if (System.IO.File.Exists(this.textBox_Caller.Text)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(this.textBox_Caller.Text); if (sw != null) { if (bIsClient) { sw.Write(this.textBoxCaller.Text.Replace("SlimDX", "UnityEngine")); } else { sw.Write(this.textBoxCaller.Text); } sw.Close(); } } if (bIsClient) { if (System.IO.File.Exists(Config.Instance.CurProjectConfig.ServCppCaller)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(Config.Instance.CurProjectConfig.ServCppCaller); if (sw != null) { sw.Write(this.textBoxCaller.Text.Replace("UnityEngine", "SlimDX")); sw.Close(); } } } else { if (System.IO.File.Exists(Config.Instance.CurProjectConfig.ClientServCaller)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(Config.Instance.CurProjectConfig.ClientServCaller); if (sw != null) { sw.Write(ServCallerToClient.Replace("SlimDX", "UnityEngine")); sw.Close(); } } } //====================== 客户端同步服务器的类结构 ====================== string outStruct = ""; //GetCppStructureDefine只发送基础属性 byte[] x = new byte[3], list<int> y = new list<int>();类似属性都将不发送 outStruct += new CSCommon.Data.RoleInfo().GetCppStructureDefine(); outStruct += new CSCommon.Data.NPCData().GetCppStructureDefine(); outStruct += new CSCommon.Data.RoleDetail().GetCppStructureDefine(); outStruct += new CSCommon.Data.RoleSyncInfo().GetCppStructureDefine(); outStruct += new CSCommon.Data.ItemData().GetCppStructureDefine(); outStruct += new CSCommon.Data.SocialData().GetCppStructureDefine(); outStruct += new CSCommon.Data.SocialRoleInfo().GetCppStructureDefine(); outStruct += new CSCommon.Data.GiftData().GetCppStructureDefine(); outStruct += new CSCommon.Data.TaskData().GetCppStructureDefine(); outStruct += new CSCommon.Data.MailData().GetCppStructureDefine(); outStruct += new CSCommon.Data.GuildCom().GetCppStructureDefine(); outStruct += new CSCommon.Data.RoleCom().GetCppStructureDefine(); outStruct += new CSCommon.Data.Message().GetCppStructureDefine(); outStruct += new CSCommon.Data.SkillData().GetCppStructureDefine(); outStruct += new CSCommon.Data.MartialData().GetCppStructureDefine(); outStruct += new CSCommon.Data.AchieveData().GetCppStructureDefine(); outStruct += new CSCommon.Data.AttrStruct().GetCppStructureDefine(); outStruct += new CSCommon.Data.CityForceData().GetCppStructureDefine(); outStruct += new CSCommon.Data.EfficiencyData().GetCppStructureDefine(); outStruct += new CSCommon.Data.CampForceData().GetCppStructureDefine(); //=================================================================== if (System.IO.File.Exists(Config.Instance.CurProjectConfig.ClientHeader)) { System.IO.StreamWriter sw = new System.IO.StreamWriter(Config.Instance.CurProjectConfig.ClientHeader); if (sw != null) { sw.Write(outStruct); sw.Close(); } } }