Просмотр исходного кода

protobuf消息调试完美,客户端出现小人没问题

tanghai 8 лет назад
Родитель
Сommit
dcbd15bd4b

+ 1 - 0
Server/Hotfix/Handler/C2G_EnterMapHandler.cs

@@ -11,6 +11,7 @@ namespace Hotfix
 			G2C_EnterMap response = new G2C_EnterMap();
 			try
 			{
+				Log.Debug(MongoHelper.ToJson(message));
 				Player player = session.GetComponent<SessionPlayerComponent>().Player;
 				// 在map服务器上创建战斗Unit
 				string mapAddress = Game.Scene.GetComponent<StartConfigComponent>().MapConfigs[0].GetComponent<InnerConfig>().Address;

+ 4 - 0
Server/Model/Base/Message/AActorMessage.cs

@@ -3,10 +3,14 @@ using ProtoBuf;
 
 namespace Model
 {
+	[ProtoContract]
 	[BsonKnownTypes(typeof(Actor_Test))]
 	[BsonKnownTypes(typeof(AFrameMessage))]
 	[BsonKnownTypes(typeof(Actor_CreateUnits))]
 	[BsonKnownTypes(typeof(FrameMessage))]
+	[ProtoInclude(10000, typeof(FrameMessage))]
+	[ProtoInclude(10001, typeof(AFrameMessage))]
+	[ProtoInclude(10002, typeof(Actor_CreateUnits))]
 	public abstract class AActorMessage : AMessage
 	{
 	}

+ 3 - 1
Unity/Assets/Scripts/Base/Message/AActorMessage.cs

@@ -4,7 +4,9 @@ using ProtoBuf;
 namespace Model
 {
 	[ProtoContract]
-	[ProtoInclude(20000, typeof(AFrameMessage))]
+	[ProtoInclude(10000, typeof(FrameMessage))]
+	[ProtoInclude(10001, typeof(AFrameMessage))]
+	[ProtoInclude(10002, typeof(Actor_CreateUnits))]
 	public abstract class AActorMessage : AMessage
 	{
 	}

+ 9 - 0
Unity/Assets/Scripts/Entity/Message/OuterMessage.cs

@@ -88,16 +88,22 @@ namespace Model
 		public int Count;
 	}
 
+	[ProtoContract]
 	public class UnitInfo
 	{
+		[ProtoMember(1)]
 		public long UnitId;
+		[ProtoMember(2)]
 		public int X;
+		[ProtoMember(3)]
 		public int Z;
 	}
 
+	[ProtoContract]
 	[Message(Opcode.Actor_CreateUnits)]
 	public class Actor_CreateUnits : AActorMessage
 	{
+		[ProtoMember(1)]
 		public List<UnitInfo> Units = new List<UnitInfo>();
 	}
 
@@ -107,10 +113,13 @@ namespace Model
 		public AMessage Message;
 	}
 
+	[ProtoContract]
 	[Message(Opcode.FrameMessage)]
 	public class FrameMessage : AActorMessage
 	{
+		[ProtoMember(1)]
 		public int Frame;
+		[ProtoMember(2)]
 		public List<AFrameMessage> Messages = new List<AFrameMessage>();
 	}
 

+ 1 - 6
Unity/Unity.sln

@@ -1,8 +1,6 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27004.2006
-MinimumVisualStudioVersion = 10.0.40219.1
+# Visual Studio 2017
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Plugins", "Unity.Plugins.csproj", "{D1FDB199-0FB7-099D-3771-C6A942E4E326}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity", "Unity.csproj", "{CF118143-7E37-744F-BE45-3F55345FEC40}"
@@ -43,7 +41,4 @@ Global
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-		SolutionGuid = {8AAB8C81-7B77-4817-A4EA-BBC4628E4FA0}
-	EndGlobalSection
 EndGlobal