浏览代码

【优化】进入场景优化

johnclot69 2 年之前
父节点
当前提交
e647a43e89

+ 7 - 3
Config/Proto/OuterMessage_C_10001.proto

@@ -58,13 +58,17 @@ message G2C_EnterMap // IResponse
 	int64 MapInstanceId = 4;
 }
 
-message G2C_EnterSceneReady // IActorMessage
+//ResponseType G2C_EnterSceneReady
+message C2G_EnterSceneReady // IRequest
+{
+	int32 RpcId = 1;
+}
+
+message G2C_EnterSceneReady // IResponse
 {
 	int32 RpcId = 1;
 	int32 Error = 2;
 	string Message = 3;
-	int32 MapId = 4;
-	int64 MapInstanceId = 5;
 }
 
 message MoveInfo

+ 12 - 0
Config/Proto/PlayerProto_CS_30001.proto

@@ -27,4 +27,16 @@ message Player
   int32 areaId = 13;
   int64 instanceId = 14;
   int32 mapId = 15;
+}
+
+message SkillKeyStruct
+{
+  int32 keyPos = 1;
+  int32 baseSkillId = 2;  //基础技能
+  int32 advancedSkillId = 3;  //当前佩戴的技能 
+  string icon = 4;  //当前佩戴的技能icon
+  int32 flag = 5; //0-为没开  1-为开启
+  int32 unlockLevel = 6;  //解锁等级
+  string name = 7;
+  string baseSkillIcon = 8;
 }

+ 1 - 0
DotNet/Hotfix/Helper/SceneFactory.cs

@@ -37,6 +37,7 @@ namespace ET.Server
                     scene.AddComponent<GameMapComponent>();
                     //战斗服的Ice会话组件
                     scene.AddComponent<BattleIceAgentComponent>();
+                    scene.AddComponent<ObjectWait>();
                     break;
                 case SceneType.Location:
                     scene.AddComponent<LocationComponent>();

+ 46 - 7
DotNet/Hotfix/Scenes/Game/Handler/C2G_EnterMapHandler.cs

@@ -1,4 +1,5 @@
 using System;
+using BattleIce;
 
 namespace ET.Server
 {
@@ -6,7 +7,7 @@ namespace ET.Server
     /// 加载100%
     /// </summary>
     [MessageHandler(SceneType.Game)]
-    public class C2G_EnterMapHandler : AMRpcHandler<C2G_EnterMap, G2C_EnterMap>
+    public class C2G_EnterMapHandler: AMRpcHandler<C2G_EnterMap, G2C_EnterMap>
     {
         protected override async ETTask Run(Session session, C2G_EnterMap request, G2C_EnterMap response, Action reply)
         {
@@ -26,7 +27,8 @@ namespace ET.Server
             // 当客户端所要进入的场景不为空且不等于当前场景,忽略掉本次请求
             if (request.InstanceId > 0 && map.Id != request.InstanceId)
             {
-                Log.Debug($"连续切图吗? playerId={player.GetId()}, name={player.GetName()}, mapId={map.MapId}, map.InstanceId={map.Id}, request.InstanceId={request.InstanceId}");
+                Log.Debug(
+                    $"连续切图吗? playerId={player.GetId()}, name={player.GetName()}, mapId={map.MapId}, map.InstanceId={map.Id}, request.InstanceId={request.InstanceId}");
                 response.Error = ErrorCode.ERR_OperationToFast;
                 reply();
                 return;
@@ -40,13 +42,50 @@ namespace ET.Server
                 return;
             }
 
-            map.PlayerEnterRequest(player);
-            map.OnPlayerEntered(player);
-            player.OnEndEnterScene();
+            // map.PlayerEnterRequest(player);
+            // map.OnPlayerEntered(player);
+            // player.OnEndEnterScene();
 
-            response.MapInstanceId = player.Map.Id;
-            reply();
+            // response.MapInstanceId = player.Map.Id;
+            // reply();
+
+            // player进入副本,把player基本信息上报给战斗服
+            map.GetZoneManager().begin_playerEnterRequest(player.GetId().ToString(), map.Id.ToString().Trim(), player.toJSON4EnterScene(map))
+                    .whenCompleted(() =>
+                        {
+                            response.MapInstanceId = player.Map.Id;
+                            reply();
+                            WaitPlayerReady(session.DomainScene(), request.InstanceId, player.Id).Coroutine();
+                        },
+                        (Ice.Exception ex) =>
+                        {
+                            if (ex != null)
+                            {
+                                Log.Error($"进入场景失败...{ex.Message}");
+                                response.Error = -1;
+                                response.Message = ex.Message;
+                                reply();
+                            }
+                        });
             await ETTask.CompletedTask;
         }
+
+        private static async ETTask WaitPlayerReady(Scene scene, long scnInstance, long playerid)
+        {
+            //等待client ready消息
+            await scene.GetComponent<ObjectWait>().Wait<Wait_PlayerReady>();
+            //告诉战斗服 i am ready
+
+            string playidstr = playerid.ToString();
+            //设置ice战斗服中player状态为ready
+            XmdsManagerPrx IceXmds = BattleIceAgentComponent.Instance.IceXmdsManager;
+            IceXmds.playerReady(playidstr);
+
+            //PKMode设置为All
+            IceXmds.refreshPlayerPKMode(playidstr, false, (int)PkModel.All);
+
+            //设置为自动战斗
+            IceXmds.autoBattle(scnInstance.ToString(), playidstr, true);
+        }
     }
 }

+ 12 - 12
DotNet/Hotfix/Scenes/Game/Handler/C2G_EnterSceneReady.cs

@@ -3,16 +3,16 @@ using ET;
 
 namespace ET.Server
 {
-    // [MessageHandler(SceneType.Game)]
-    // public class C2G_EnterSceneReadyHandler : AMRpcHandler<C2G_EnterSceneReady, G2C_EnterSceneReady>
-    // {
-    //     protected override async ETTask Run(Session session, C2G_EnterSceneReady request, G2C_EnterSceneReady response, Action reply)
-    //     {
-    //         Scene scene = session.DomainScene();
-    //         scene.GetComponent<ObjectWait>().Notify(new Wait_PlayerReady());
-    //
-    //         reply();
-    //         await ETTask.CompletedTask;
-    //     }
-    // }
+    [MessageHandler(SceneType.Game)]
+    public class C2G_EnterSceneReadyHandler : AMRpcHandler<C2G_EnterSceneReady, G2C_EnterSceneReady>
+    {
+        protected override async ETTask Run(Session session, C2G_EnterSceneReady request, G2C_EnterSceneReady response, Action reply)
+        {
+            Scene scene = session.DomainScene();
+            scene.GetComponent<ObjectWait>().Notify(new Wait_PlayerReady());
+
+            reply();
+            await ETTask.CompletedTask;
+        }
+    }
 }

+ 2 - 2
DotNet/Hotfix/Scenes/Game/Player/PlayerSystem.cs

@@ -177,8 +177,8 @@ namespace ET.Server
         /** 向客户端推送角色相关数据 **/
         public static void OnEndEnterScene(this WNPlayer self)
         {
-            self.GetXmdsManager().playerReady(self.GetId().ToString().Trim());
-            MessageHelper.SendToClient(self, new G2C_EnterSceneReady() { MapId = self.Map.MapId, MapInstanceId = self.Map.Id });
+            // self.GetXmdsManager().playerReady(self.GetId().ToString().Trim());
+            // MessageHelper.SendToClient(self, new G2C_EnterSceneReady() { MapId = self.Map.MapId, MapInstanceId = self.Map.Id });
         }
 
         /** 场景中角色需求数据 **/

+ 3 - 1
DotNet/Hotfix/Scenes/Realm/Handler/C2R_LoginHandler.cs

@@ -127,9 +127,11 @@ namespace ET.Server
 
             // 服务器列表
             List<StartSceneConfig> gameList = RealmGateAddressHelper.GetAllGame(session.DomainZone());
-            response.Address = new();
+
             if (gameList is { Count: > 0 })
             {
+                response.Address = new List<string>();
+
                 foreach (StartSceneConfig config in gameList)
                 {
                     response.Address.Add(config.InnerIPOutPort.ToString());

+ 44 - 39
DotNet/Model/Generate/Message/OuterMessage_C_10001.cs

@@ -117,9 +117,19 @@ namespace ET
 
 	}
 
+	[ResponseType(nameof(G2C_EnterSceneReady))]
+	[Message(OuterMessage.C2G_EnterSceneReady)]
+	[ProtoContract]
+	public partial class C2G_EnterSceneReady: ProtoObject, IRequest
+	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+	}
+
 	[Message(OuterMessage.G2C_EnterSceneReady)]
 	[ProtoContract]
-	public partial class G2C_EnterSceneReady: ProtoObject, IActorMessage
+	public partial class G2C_EnterSceneReady: ProtoObject, IResponse
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
@@ -130,12 +140,6 @@ namespace ET
 		[ProtoMember(3)]
 		public string Message { get; set; }
 
-		[ProtoMember(4)]
-		public int MapId { get; set; }
-
-		[ProtoMember(5)]
-		public long MapInstanceId { get; set; }
-
 	}
 
 	[Message(OuterMessage.MoveInfo)]
@@ -602,37 +606,38 @@ namespace ET
 		 public const ushort Actor_TransferResponse = 10007;
 		 public const ushort C2G_EnterMap = 10008;
 		 public const ushort G2C_EnterMap = 10009;
-		 public const ushort G2C_EnterSceneReady = 10010;
-		 public const ushort MoveInfo = 10011;
-		 public const ushort UnitInfo = 10012;
-		 public const ushort M2C_CreateUnits = 10013;
-		 public const ushort M2C_CreateMyUnit = 10014;
-		 public const ushort M2C_StartSceneChange = 10015;
-		 public const ushort M2C_RemoveUnits = 10016;
-		 public const ushort C2M_PathfindingResult = 10017;
-		 public const ushort M2C_PathfindingResult = 10018;
-		 public const ushort C2M_Stop = 10019;
-		 public const ushort M2C_Stop = 10020;
-		 public const ushort C2G_Ping = 10021;
-		 public const ushort G2C_Ping = 10022;
-		 public const ushort G2C_Test = 10023;
-		 public const ushort C2M_Reload = 10024;
-		 public const ushort M2C_Reload = 10025;
-		 public const ushort C2R_Login = 10026;
-		 public const ushort R2C_Login = 10027;
-		 public const ushort C2G_LoginGame = 10028;
-		 public const ushort G2C_LoginGame = 10029;
-		 public const ushort C2G_CreatePlayer = 10030;
-		 public const ushort G2C_CreatePlayer = 10031;
-		 public const ushort C2G_BindPlayer = 10032;
-		 public const ushort G2C_BindPlayer = 10033;
-		 public const ushort G2C_TestHotfixMessage = 10034;
-		 public const ushort C2M_TestRobotCase = 10035;
-		 public const ushort M2C_TestRobotCase = 10036;
-		 public const ushort C2M_TransferMap = 10037;
-		 public const ushort M2C_TransferMap = 10038;
-		 public const ushort C2G_Benchmark = 10039;
-		 public const ushort G2C_Benchmark = 10040;
-		 public const ushort R2C_Disconnect = 10041;
+		 public const ushort C2G_EnterSceneReady = 10010;
+		 public const ushort G2C_EnterSceneReady = 10011;
+		 public const ushort MoveInfo = 10012;
+		 public const ushort UnitInfo = 10013;
+		 public const ushort M2C_CreateUnits = 10014;
+		 public const ushort M2C_CreateMyUnit = 10015;
+		 public const ushort M2C_StartSceneChange = 10016;
+		 public const ushort M2C_RemoveUnits = 10017;
+		 public const ushort C2M_PathfindingResult = 10018;
+		 public const ushort M2C_PathfindingResult = 10019;
+		 public const ushort C2M_Stop = 10020;
+		 public const ushort M2C_Stop = 10021;
+		 public const ushort C2G_Ping = 10022;
+		 public const ushort G2C_Ping = 10023;
+		 public const ushort G2C_Test = 10024;
+		 public const ushort C2M_Reload = 10025;
+		 public const ushort M2C_Reload = 10026;
+		 public const ushort C2R_Login = 10027;
+		 public const ushort R2C_Login = 10028;
+		 public const ushort C2G_LoginGame = 10029;
+		 public const ushort G2C_LoginGame = 10030;
+		 public const ushort C2G_CreatePlayer = 10031;
+		 public const ushort G2C_CreatePlayer = 10032;
+		 public const ushort C2G_BindPlayer = 10033;
+		 public const ushort G2C_BindPlayer = 10034;
+		 public const ushort G2C_TestHotfixMessage = 10035;
+		 public const ushort C2M_TestRobotCase = 10036;
+		 public const ushort M2C_TestRobotCase = 10037;
+		 public const ushort C2M_TransferMap = 10038;
+		 public const ushort M2C_TransferMap = 10039;
+		 public const ushort C2G_Benchmark = 10040;
+		 public const ushort G2C_Benchmark = 10041;
+		 public const ushort R2C_Disconnect = 10042;
 	}
 }

+ 31 - 0
DotNet/Model/Generate/Message/PlayerProto_CS_30001.cs

@@ -75,9 +75,40 @@ namespace ET
 
 	}
 
+	[Message(PlayerProto.SkillKeyStruct)]
+	[ProtoContract]
+	public partial class SkillKeyStruct: ProtoObject
+	{
+		[ProtoMember(1)]
+		public int keyPos { get; set; }
+
+		[ProtoMember(2)]
+		public int baseSkillId { get; set; }
+
+		[ProtoMember(3)]
+		public int advancedSkillId { get; set; }
+
+		[ProtoMember(4)]
+		public string icon { get; set; }
+
+		[ProtoMember(5)]
+		public int flag { get; set; }
+
+		[ProtoMember(6)]
+		public int unlockLevel { get; set; }
+
+		[ProtoMember(7)]
+		public string name { get; set; }
+
+		[ProtoMember(8)]
+		public string baseSkillIcon { get; set; }
+
+	}
+
 	public static class PlayerProto
 	{
 		 public const ushort PlayerBasic = 30002;
 		 public const ushort Player = 30003;
+		 public const ushort SkillKeyStruct = 30004;
 	}
 }

+ 44 - 39
Unity/Assets/Scripts/Codes/Model/Client/Generate/Message/OuterMessage_C_10001.cs

@@ -117,9 +117,19 @@ namespace ET
 
 	}
 
+	[ResponseType(nameof(G2C_EnterSceneReady))]
+	[Message(OuterMessage.C2G_EnterSceneReady)]
+	[ProtoContract]
+	public partial class C2G_EnterSceneReady: ProtoObject, IRequest
+	{
+		[ProtoMember(1)]
+		public int RpcId { get; set; }
+
+	}
+
 	[Message(OuterMessage.G2C_EnterSceneReady)]
 	[ProtoContract]
-	public partial class G2C_EnterSceneReady: ProtoObject, IActorMessage
+	public partial class G2C_EnterSceneReady: ProtoObject, IResponse
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
@@ -130,12 +140,6 @@ namespace ET
 		[ProtoMember(3)]
 		public string Message { get; set; }
 
-		[ProtoMember(4)]
-		public int MapId { get; set; }
-
-		[ProtoMember(5)]
-		public long MapInstanceId { get; set; }
-
 	}
 
 	[Message(OuterMessage.MoveInfo)]
@@ -602,37 +606,38 @@ namespace ET
 		 public const ushort Actor_TransferResponse = 10007;
 		 public const ushort C2G_EnterMap = 10008;
 		 public const ushort G2C_EnterMap = 10009;
-		 public const ushort G2C_EnterSceneReady = 10010;
-		 public const ushort MoveInfo = 10011;
-		 public const ushort UnitInfo = 10012;
-		 public const ushort M2C_CreateUnits = 10013;
-		 public const ushort M2C_CreateMyUnit = 10014;
-		 public const ushort M2C_StartSceneChange = 10015;
-		 public const ushort M2C_RemoveUnits = 10016;
-		 public const ushort C2M_PathfindingResult = 10017;
-		 public const ushort M2C_PathfindingResult = 10018;
-		 public const ushort C2M_Stop = 10019;
-		 public const ushort M2C_Stop = 10020;
-		 public const ushort C2G_Ping = 10021;
-		 public const ushort G2C_Ping = 10022;
-		 public const ushort G2C_Test = 10023;
-		 public const ushort C2M_Reload = 10024;
-		 public const ushort M2C_Reload = 10025;
-		 public const ushort C2R_Login = 10026;
-		 public const ushort R2C_Login = 10027;
-		 public const ushort C2G_LoginGame = 10028;
-		 public const ushort G2C_LoginGame = 10029;
-		 public const ushort C2G_CreatePlayer = 10030;
-		 public const ushort G2C_CreatePlayer = 10031;
-		 public const ushort C2G_BindPlayer = 10032;
-		 public const ushort G2C_BindPlayer = 10033;
-		 public const ushort G2C_TestHotfixMessage = 10034;
-		 public const ushort C2M_TestRobotCase = 10035;
-		 public const ushort M2C_TestRobotCase = 10036;
-		 public const ushort C2M_TransferMap = 10037;
-		 public const ushort M2C_TransferMap = 10038;
-		 public const ushort C2G_Benchmark = 10039;
-		 public const ushort G2C_Benchmark = 10040;
-		 public const ushort R2C_Disconnect = 10041;
+		 public const ushort C2G_EnterSceneReady = 10010;
+		 public const ushort G2C_EnterSceneReady = 10011;
+		 public const ushort MoveInfo = 10012;
+		 public const ushort UnitInfo = 10013;
+		 public const ushort M2C_CreateUnits = 10014;
+		 public const ushort M2C_CreateMyUnit = 10015;
+		 public const ushort M2C_StartSceneChange = 10016;
+		 public const ushort M2C_RemoveUnits = 10017;
+		 public const ushort C2M_PathfindingResult = 10018;
+		 public const ushort M2C_PathfindingResult = 10019;
+		 public const ushort C2M_Stop = 10020;
+		 public const ushort M2C_Stop = 10021;
+		 public const ushort C2G_Ping = 10022;
+		 public const ushort G2C_Ping = 10023;
+		 public const ushort G2C_Test = 10024;
+		 public const ushort C2M_Reload = 10025;
+		 public const ushort M2C_Reload = 10026;
+		 public const ushort C2R_Login = 10027;
+		 public const ushort R2C_Login = 10028;
+		 public const ushort C2G_LoginGame = 10029;
+		 public const ushort G2C_LoginGame = 10030;
+		 public const ushort C2G_CreatePlayer = 10031;
+		 public const ushort G2C_CreatePlayer = 10032;
+		 public const ushort C2G_BindPlayer = 10033;
+		 public const ushort G2C_BindPlayer = 10034;
+		 public const ushort G2C_TestHotfixMessage = 10035;
+		 public const ushort C2M_TestRobotCase = 10036;
+		 public const ushort M2C_TestRobotCase = 10037;
+		 public const ushort C2M_TransferMap = 10038;
+		 public const ushort M2C_TransferMap = 10039;
+		 public const ushort C2G_Benchmark = 10040;
+		 public const ushort G2C_Benchmark = 10041;
+		 public const ushort R2C_Disconnect = 10042;
 	}
 }

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

@@ -75,9 +75,40 @@ namespace ET
 
 	}
 
+	[Message(PlayerProto.SkillKeyStruct)]
+	[ProtoContract]
+	public partial class SkillKeyStruct: ProtoObject
+	{
+		[ProtoMember(1)]
+		public int keyPos { get; set; }
+
+		[ProtoMember(2)]
+		public int baseSkillId { get; set; }
+
+		[ProtoMember(3)]
+		public int advancedSkillId { get; set; }
+
+		[ProtoMember(4)]
+		public string icon { get; set; }
+
+		[ProtoMember(5)]
+		public int flag { get; set; }
+
+		[ProtoMember(6)]
+		public int unlockLevel { get; set; }
+
+		[ProtoMember(7)]
+		public string name { get; set; }
+
+		[ProtoMember(8)]
+		public string baseSkillIcon { get; set; }
+
+	}
+
 	public static class PlayerProto
 	{
 		 public const ushort PlayerBasic = 30002;
 		 public const ushort Player = 30003;
+		 public const ushort SkillKeyStruct = 30004;
 	}
 }