Kaynağa Gözat

【BUG】解决添加单位时的一些问题

johnclot69 1 yıl önce
ebeveyn
işleme
bb39196c48

BIN
Config/Excel/Monster.xlsx


+ 3 - 2
Config/GenJson/c/Monster.txt

@@ -1,4 +1,5 @@
 {"list":[
-{"_t":"Monster","_id":72000,"Name":"剑痴","Title":"","Level":50,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":-1,"MaxAttack":-1,"MaxDefence":-1,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":0,"DialogWords":"","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","IdleSpeakCoolDown":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":1,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
-{"_t":"Monster","_id":1009601,"Name":"羊","Title":"","Level":80,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":0,"MaxAttack":0,"MaxDefence":0,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":100,"DialogWords":"咩~~咩~~","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","IdleSpeakCoolDown":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":0,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"Meat-yang","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
+{"_t":"Monster","_id":101,"Name":"boss1","Title":"","Level":50,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":-1,"MaxAttack":-1,"MaxDefence":-1,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":0,"DialogWords":"","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","IdleSpeakCoolDown":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":1,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
+{"_t":"Monster","_id":102,"Name":"boss2","Title":"","Level":80,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":0,"MaxAttack":0,"MaxDefence":0,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":100,"DialogWords":"咩~~咩~~","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","IdleSpeakCoolDown":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":0,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"Meat-yang","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
+{"_t":"Monster","_id":103,"Name":"boss2","Title":"","Level":80,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":0,"MaxAttack":0,"MaxDefence":0,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":100,"DialogWords":"咩~~咩~~","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","IdleSpeakCoolDown":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":0,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"Meat-yang","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
 ]}

+ 3 - 2
Config/GenJson/s/Monster.txt

@@ -1,4 +1,5 @@
 {"list":[
-{"_t":"Monster","_id":72000,"Name":"剑痴","Title":"","Level":50,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":-1,"MaxAttack":-1,"MaxDefence":-1,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":0,"DialogWords":"","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":1,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
-{"_t":"Monster","_id":1009601,"Name":"羊","Title":"","Level":80,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":0,"MaxAttack":0,"MaxDefence":0,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":100,"DialogWords":"咩~~咩~~","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":0,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"Meat-yang","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
+{"_t":"Monster","_id":101,"Name":"boss1","Title":"","Level":50,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":-1,"MaxAttack":-1,"MaxDefence":-1,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":0,"DialogWords":"","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":1,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
+{"_t":"Monster","_id":102,"Name":"boss2","Title":"","Level":80,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":0,"MaxAttack":0,"MaxDefence":0,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":100,"DialogWords":"咩~~咩~~","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":0,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"Meat-yang","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
+{"_t":"Monster","_id":103,"Name":"boss2","Title":"","Level":80,"FightType":1,"LvRepress":0,"Qcolor":0,"Type":0,"MPValue":0,"SkillType":0,"FightCount":0,"AliveTime":0,"KillPlayerTime":0,"MaxHP":0,"MaxAttack":0,"MaxDefence":0,"CritRate":-1,"CritDamage":-1,"IgnoreDefencePer":0,"Prob1":0,"ReviveID1":0,"Prob2":0,"ReviveID2":0,"Prob3":0,"ReviveID3":0,"Prob4":0,"ReviveID4":0,"DialogChance":100,"DialogWords":"咩~~咩~~","DeadDialogChance":0,"DeadDialogWords":"","IdleSpeakChance":0,"IdleSpeakWords":"","FightSpeakChance":0,"FightSpeakWords":"","FightSpeakCoolDown":"","DeadSpeakWords":"","isAttack":0,"Ability":"","CallAbilityPerHP":"","AbilityPar":"","ShareType":0,"Icon":"","MonsterDes":"","MonsterRaid":"","Sex":0,"Atype":0,"FirstTc":"","Tc":"Meat-yang","TeamTc":"","PersonTc":"","AssistTC":"","BaseExp":0,"GoldBase":0,"ExpRatio":0},
 ]}

+ 2 - 2
Config/Proto/OuterMessage_C_10001.proto

@@ -240,7 +240,7 @@ message G2C_BindPlayer // IResponse
 }
 
 //ResponseType G2C_AddUnitsToMap
-message C2G_AddUnitsToMap // IActorLocationRequest
+message C2G_AddUnitsToMap // IRequest
 {
 	int32 RpcId = 1;
 	int32 UnitId = 2;	// 单位模板ID
@@ -250,7 +250,7 @@ message C2G_AddUnitsToMap // IActorLocationRequest
 	int32 Y = 6;
 }
 
-message G2C_AddUnitsToMap // IActorLocationResponse
+message G2C_AddUnitsToMap // IResponse
 {
 	int32 RpcId = 1;
 	int32 Error = 2;

+ 1 - 1
DotNet/Hotfix/Module/ActorLocation/LocationProxyComponentSystem.cs

@@ -10,7 +10,7 @@ namespace ET.Server
             LocationProxyComponent.Instance = self;
         }
     }
-    
+
     [ObjectSystem]
     public class LocationProxyComponentDestroySystem: DestroySystem<LocationProxyComponent>
     {

+ 10 - 1
DotNet/Hotfix/Scenes/Game/Handler/C2G_AddUnitsToMapHandler.cs

@@ -10,6 +10,16 @@ namespace ET.Server
     {
         protected override async ETTask Run(Session session, C2G_AddUnitsToMap request, G2C_AddUnitsToMap response, Action reply)
         {
+            if (session.DomainScene().SceneType != SceneType.Game)
+            {
+                Log.Debug($"Game 请求的Scene错误...SceneType={session.DomainScene().SceneType}");
+                session.Dispose();
+                return;
+            }
+
+            // 移除session自动超时组件
+            session.RemoveComponent<SessionAcceptTimeoutComponent>();
+
             WNPlayer player = session.GetComponent<SessionPlayerComponent>().GetMyPlayer();
             if (player == null)
             {
@@ -39,7 +49,6 @@ namespace ET.Server
             Struct.MonsterUnit unit = new Struct.MonsterUnit();
             unit.id = prop.Id;
             unit.force = request.Force;
-            unit.flag = "";
             if (!string.IsNullOrEmpty(request.Flag))
             {
                 unit.flag = request.Flag;

+ 1 - 3
DotNet/Hotfix/Scenes/Game/Handler/C2G_BindPlayerHandler.cs

@@ -103,8 +103,7 @@ namespace ET.Server
             player = await PlayerFactory.CreatPlayer(session, playerInfo);
 
             // 绑定选择的玩家
-            session.GetComponent<SessionPlayerComponent>().PlayerId = request.PlayerId > 0 ? request.PlayerId : player.GetId();
-            session.AddComponent<MailBoxComponent, MailboxType>(MailboxType.GateSession);
+            session.GetComponent<SessionPlayerComponent>().BindPlayerId(request.PlayerId > 0 ? request.PlayerId : player.GetId());
 
             // todo 分配场景
             Map map = MapHelper.BindPlayerDispatch(player);
@@ -120,7 +119,6 @@ namespace ET.Server
             response.Player.mapId = map.MapId;
 
             reply();
-            await ETTask.CompletedTask;
         }
     }
 }

+ 2 - 2
DotNet/Hotfix/Scenes/Game/Handler/C2G_LoginGameHandler.cs

@@ -34,8 +34,8 @@ namespace ET.Server
             // 移除session自动超时组件
             session.RemoveComponent<SessionAcceptTimeoutComponent>();
             // 添加session组件,用于绑定角色
-            session.AddComponent<SessionPlayerComponent>();
-            session.GetComponent<SessionPlayerComponent>().UserId = request.UserId;
+            session.AddComponent<SessionPlayerComponent>().UserId = request.UserId;
+            session.AddComponent<MailBoxComponent, MailboxType>(MailboxType.GateSession);
 
             response.Players = new List<PlayerBasic>();
 

+ 11 - 0
DotNet/Hotfix/Scenes/Game/Player/SessionPlayerComponentSystem.cs

@@ -52,6 +52,17 @@ namespace ET.Server
             }
         }
 
+        /// <summary>
+        /// 绑定玩家id
+        /// </summary>
+        /// <param name="self"></param>
+        /// <param name="playerId"></param>
+        public static void BindPlayerId(this SessionPlayerComponent self, long playerId)
+        {
+            Log.Debug($"session玩家绑定组件 绑定玩家id={playerId}");
+            self.PlayerId = playerId;
+        }
+
         /// <summary>
         /// 是否存在
         /// </summary>

+ 4 - 4
DotNet/Hotfix/Session/NetInnerComponentOnReadEvent.cs

@@ -17,7 +17,7 @@ namespace ET.Server
                 int fromProcess = instanceIdStruct.Process;
                 instanceIdStruct.Process = Options.Instance.Process;
                 long realActorId = instanceIdStruct.ToLong();
-                
+
                 // 收到actor消息,放入actor队列
                 switch (message)
                 {
@@ -36,12 +36,12 @@ namespace ET.Server
                                 ActorMessageSenderComponent.Instance.RunMessage(realActorId, response);
                                 return;
                             }
-                            
+
                             Session replySession = NetInnerComponent.Instance.Get(fromProcess);
                             // 发回真实的actorId 做查问题使用
                             replySession.Send(realActorId, response);
                         }
-                        
+
                         Entity entity = Root.Instance.Get(realActorId);
                         if (entity == null)
                         {
@@ -91,7 +91,7 @@ namespace ET.Server
                             Log.Error($"not found actor: {scene.Name} {realActorId} {message}");
                             break;
                         }
-                        
+
                         MailBoxComponent mailBoxComponent = entity.GetComponent<MailBoxComponent>();
                         if (mailBoxComponent == null)
                         {

+ 2 - 2
DotNet/Model/Generate/Message/OuterMessage_C_10001.cs

@@ -494,7 +494,7 @@ namespace ET
 	[ResponseType(nameof(G2C_AddUnitsToMap))]
 	[Message(OuterMessage.C2G_AddUnitsToMap)]
 	[ProtoContract]
-	public partial class C2G_AddUnitsToMap: ProtoObject, IActorLocationRequest
+	public partial class C2G_AddUnitsToMap: ProtoObject, IRequest
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
@@ -518,7 +518,7 @@ namespace ET
 
 	[Message(OuterMessage.G2C_AddUnitsToMap)]
 	[ProtoContract]
-	public partial class G2C_AddUnitsToMap: ProtoObject, IActorLocationResponse
+	public partial class G2C_AddUnitsToMap: ProtoObject, IResponse
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }

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

@@ -494,7 +494,7 @@ namespace ET
 	[ResponseType(nameof(G2C_AddUnitsToMap))]
 	[Message(OuterMessage.C2G_AddUnitsToMap)]
 	[ProtoContract]
-	public partial class C2G_AddUnitsToMap: ProtoObject, IActorLocationRequest
+	public partial class C2G_AddUnitsToMap: ProtoObject, IRequest
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }
@@ -518,7 +518,7 @@ namespace ET
 
 	[Message(OuterMessage.G2C_AddUnitsToMap)]
 	[ProtoContract]
-	public partial class G2C_AddUnitsToMap: ProtoObject, IActorLocationResponse
+	public partial class G2C_AddUnitsToMap: ProtoObject, IResponse
 	{
 		[ProtoMember(1)]
 		public int RpcId { get; set; }