|
@@ -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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|