Explorar o código

【增加】实现事件开端,协议和接口

johnclot69 hai 1 ano
pai
achega
f1d4c38cc8

+ 14 - 0
Config/Proto/OuterMessage_C_10001.proto

@@ -351,4 +351,18 @@ message HttpGetVersionResponse
 	string Message = 2;
 	int64 Version = 3;	// 版本号
 	string Url = 4;	// 新包地址
+}
+
+//ResponseType G2C_GameStart
+message C2G_GameStart // IRequest
+{
+	int32 RpcId = 1;
+	string NameType = 2;
+}
+
+message G2C_GameStart // IResponse
+{
+	int32 RpcId = 1;
+	int32 Error = 2;
+	string Message = 3;
 }

+ 62 - 0
DotNet/Hotfix/Scenes/Game/Handler/C2G_GameStartHandler.cs

@@ -0,0 +1,62 @@
+using System;
+using System.Text.Json;
+
+namespace ET.Server
+{
+    /// <summary>
+    /// 游戏开始
+    /// </summary>
+    [MessageHandler(SceneType.Game)]
+    public class C2G_GameStartHandler : AMRpcHandler<C2G_GameStart, G2C_GameStart>
+    {
+        protected override async ETTask Run(Session session, C2G_GameStart request, G2C_GameStart response, Action reply)
+        {
+            WNPlayer player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
+            if (player == null)
+            {
+                Log.Debug($"操作错误, player is null");
+                response.Error = ErrorCode.ERR_OperationError;
+                reply();
+                return;
+            }
+
+            // 判断参数
+            if (string.IsNullOrEmpty(request.NameType.Trim()))
+            {
+                Log.Debug($"参数错误, request.NameType={request.NameType}");
+                response.Error = ErrorCode.ERR_ParameterError;
+                reply();
+                return;
+            }
+
+            long roomId = long.Parse(session.GetComponent<SessionPlayerComponent>().RoomId);
+            if (roomId <= 0)
+            {
+                Log.Debug($"操作错误, roomId is null");
+                response.Error = ErrorCode.ERR_OperationError;
+                reply();
+                return;
+            }
+
+            Scene scene = session.DomainScene();
+
+            Map map = scene.GetComponent<GameMapComponent>().GetMapByRoomId(roomId);
+            if (map == null)
+            {
+                Log.Debug($"操作错误, map is null");
+                response.Error = ErrorCode.ERR_OperationError;
+                reply();
+                return;
+            }
+
+            // 通知战斗服
+            Struct.TriggerEventNotify notifyMsg = new Struct.TriggerEventNotify();
+            notifyMsg.name = request.NameType;
+
+            player.GetXmdsManager().notifyBattleServer(player.Map.Id.ToString(), NotifyBSName.TriggerEvent, JsonSerializer.Serialize(notifyMsg));
+
+            reply();
+            await ETTask.CompletedTask;
+        }
+    }
+}

+ 9 - 1
DotNet/Model/Const/ConstGame.cs

@@ -1,4 +1,5 @@
-using System.ComponentModel.DataAnnotations;
+using System;
+using System.ComponentModel.DataAnnotations;
 
 namespace ET.Server
 {
@@ -20,6 +21,13 @@ namespace ET.Server
         public const int maxNum = 4; // 最多角色数量
     }
 
+    /** 通知战斗事件信息 */
+    public static class NotifyBSName
+    {
+        // public const string ZoneFlagNotify = "ZoneFlagNotifyR2B";
+        public const string TriggerEvent = "TriggerEventR2B";
+    }
+
     /// <summary>
     /// 性别类型
     /// </summary>

+ 9 - 0
DotNet/Model/Const/Struct.cs

@@ -286,5 +286,14 @@
                 this.y = y;
             }
         }
+
+        /// <summary>
+        /// 通知战斗服事件
+        /// </summary>
+        public class TriggerEventNotify
+        {
+            /** 事件名称 **/
+            public string name { get; set; }
+        }
     }
 }

+ 30 - 0
DotNet/Model/Generate/Message/OuterMessage_C_10001.cs

@@ -727,6 +727,34 @@ namespace ET
 
 	}
 
+	[ResponseType(nameof(G2C_GameStart))]
+	[Message(OuterMessage.C2G_GameStart)]
+	[ProtoContract]
+	public partial class C2G_GameStart: ProtoObject, IRequest
+	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
+		public string NameType { get; set; }
+
+	}
+
+	[Message(OuterMessage.G2C_GameStart)]
+	[ProtoContract]
+	public partial class G2C_GameStart: ProtoObject, IResponse
+	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
+		public int Error { get; set; }
+
+		[ProtoMember(3)]
+		public string Message { get; set; }
+
+	}
+
 	public static class OuterMessage
 	{
 		 public const ushort HttpGetRouterResponse = 10002;
@@ -778,5 +806,7 @@ namespace ET
 		 public const ushort R2C_Disconnect = 10048;
 		 public const ushort HttpDouyinApiCallbackResponse = 10049;
 		 public const ushort HttpGetVersionResponse = 10050;
+		 public const ushort C2G_GameStart = 10051;
+		 public const ushort G2C_GameStart = 10052;
 	}
 }

+ 0 - 11
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/BattleServerMsg_CS_40001.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 0f8b6369de1b9da448ac2f8d9642bfdc
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 30 - 0
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/OuterMessage_C_10001.cs

@@ -727,6 +727,34 @@ namespace ET
 
 	}
 
+	[ResponseType(nameof(G2C_GameStart))]
+	[Message(OuterMessage.C2G_GameStart)]
+	[ProtoContract]
+	public partial class C2G_GameStart: ProtoObject, IRequest
+	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
+		public string NameType { get; set; }
+
+	}
+
+	[Message(OuterMessage.G2C_GameStart)]
+	[ProtoContract]
+	public partial class G2C_GameStart: ProtoObject, IResponse
+	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+		[ProtoMember(2)]
+		public int Error { get; set; }
+
+		[ProtoMember(3)]
+		public string Message { get; set; }
+
+	}
+
 	public static class OuterMessage
 	{
 		 public const ushort HttpGetRouterResponse = 10002;
@@ -778,5 +806,7 @@ namespace ET
 		 public const ushort R2C_Disconnect = 10048;
 		 public const ushort HttpDouyinApiCallbackResponse = 10049;
 		 public const ushort HttpGetVersionResponse = 10050;
+		 public const ushort C2G_GameStart = 10051;
+		 public const ushort G2C_GameStart = 10052;
 	}
 }

+ 0 - 11
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/OuterMessage_C_10001.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 26923f18a432ab740b53d6d218076c02
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 11
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/PlayerProto_CS_30001.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: b804cc6168290bc4f9d5eaf118e400b3
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: