guodong 1 жил өмнө
parent
commit
16e24bf5b4

+ 11 - 7
GameClient/Assets/Game/HotUpdate/Controller/LoginController.cs

@@ -248,25 +248,27 @@ namespace GFGGame
                 ErrorCodeController.Handler(errorCode);
                 return;
             }
-            ViewManager.Hide<ModalStatusView>();
-            ViewManager.Hide<LoginView>();
-            ViewManager.Show<LoadingView>(0.01f);
-            LoadingView.Instance.SetProgress(99);
-            LoadingView.Instance.SetDesc("正在加载数据...");
-            LogServerHelper.SendNodeLog((int)LogNode.StartEnterGame);
             errorCode = await LoginHelper.EnterGame(GameGlobal.zoneScene);
             if (errorCode != ErrorCode.ERR_Success)
             {
                 ErrorCodeController.Handler(errorCode);
                 return;
             }
+            ViewManager.Hide<ModalStatusView>();
+            ViewManager.Hide<LoginView>();
+            ViewManager.Show<LoadingView>(0.01f);
+            LoadingView.Instance.SetProgress(99);
+            LoadingView.Instance.SetDesc("正在加载数据...");
+            LogServerHelper.SendNodeLog((int)LogNode.StartEnterGame);
+            await GameGlobal.zoneScene.GetComponent<ObjectWait>().Wait<ET.WaitType.Wait_SceneChangeFinish>();
+            AlertSystem.hide();
             await GameController.PreEnterGameAsync();
-
             LogServerHelper.SendNodeLog((int)LogNode.OnEnterGame);
         }
 
         public static async ETTask ReqReConnectGate()
         {
+            LogUtil.LogDev("ReqReConnectGate");
             ViewManager.Show<ModalStatusView>("重新连接中...");
             int errorCode = await LoginHelper.EnterGame(GameGlobal.zoneScene);
             if (errorCode != ErrorCode.ERR_Success)
@@ -282,8 +284,10 @@ namespace GFGGame
                         });
                 return;
             }
+            await GameGlobal.zoneScene.GetComponent<ObjectWait>().Wait<ET.WaitType.Wait_SceneChangeFinish>();
             EventAgent.DispatchEvent(ConstMessage.NUMERIC_CHANGE, NumericType.All);
             GameController.OnReconnected();
+            AlertSystem.hide();
             ViewManager.Hide<ModalStatusView>();
         }
     }

+ 0 - 21
GameClient/Assets/Game/HotUpdate/Data/QueueDataManager.cs

@@ -1,21 +0,0 @@
-namespace GFGGame
-{
-    public class QueueDataManager : SingletonBase<QueueDataManager>
-    {
-        public int Index { get; private set; }
-
-        public int Count { get; private set; }
-
-        public void UpQueueData(int index, int count)
-        {
-            Index = index;
-            count = count;
-        }
-
-        public void ClaerQueueData()
-        {
-            Index = 0;
-            Count = 0;
-        }
-    }
-}

+ 0 - 11
GameClient/Assets/Game/HotUpdate/Data/QueueDataManager.cs.meta

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

+ 6 - 9
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Login/LoginHelper.cs

@@ -167,7 +167,7 @@ namespace ET
 
             try
             {
-                a2C_GetRoles = (A2C_GetRoles)await zoneScene.GetComponent<SessionComponent>().AccountSession?.Call(new C2A_GetRoles()
+                a2C_GetRoles = (A2C_GetRoles)await zoneScene.GetComponent<SessionComponent>().AccountSession.Call(new C2A_GetRoles()
                 {
                     AccountId = zoneScene.GetComponent<AccountInfoComponent>().AccountId,
                     Token = zoneScene.GetComponent<AccountInfoComponent>().Token,
@@ -289,7 +289,6 @@ namespace ET
 
             zoneScene.GetComponent<AccountInfoComponent>().RealmKey = a2C_GetRealmKey.RealmKey;
             zoneScene.GetComponent<AccountInfoComponent>().RealmAddress = a2C_GetRealmKey.RealmAddress;
-            zoneScene.GetComponent<SessionComponent>().Disconnect();
 
             await ETTask.CompletedTask;
             return ErrorCode.ERR_Success;
@@ -323,7 +322,7 @@ namespace ET
                 return r2C_LoginRealm.Error;
             }
 
-            Log.Debug($"GateAddress : {r2C_LoginRealm.GateAddress}");
+            LogUtil.LogDev($"GateAddress : {r2C_LoginRealm.GateAddress}");
             Session gateSession = zoneScene.GetComponent<NetKcpComponent>().Create(NetworkHelper.ToIPEndPoint(r2C_LoginRealm.GateAddress));
             gateSession.AddComponent<PingComponent>();
             gateSession.AddComponent<DisConnectedCompnent>();
@@ -355,7 +354,7 @@ namespace ET
                 zoneScene.GetComponent<SessionComponent>().GateSession?.Dispose();
                 return g2C_LoginGate.Error;
             }
-            Log.Debug("登陆gate成功!");
+            LogUtil.LogDev("登陆gate成功!");
 
             //3.角色正式请求进入游戏逻辑服
             G2C_EnterGame g2C_EnterGame = null;
@@ -375,12 +374,10 @@ namespace ET
                 //Log.Error(g2C_EnterGame.Error.ToString());
                 return g2C_EnterGame.Error;
             }
-
-            Log.Debug("角色进入游戏成功!");
             zoneScene.GetComponent<PlayerComponent>().MyId = g2C_EnterGame.MyId;
-            await zoneScene.GetComponent<ObjectWait>().Wait<WaitType.Wait_SceneChangeFinish>();
-
-            await ETTask.CompletedTask;
+            await GameGlobal.zoneScene.GetComponent<ObjectWait>().Wait<ET.WaitType.Wait_SceneChangeStart>();
+            LogUtil.LogDev("角色进入游戏成功!");
+            zoneScene.GetComponent<SessionComponent>().DisconnectAccount();
             return ErrorCode.ERR_Success;
         }
 

+ 20 - 2
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Scene/M2C_StartSceneChangeHandler.cs

@@ -1,4 +1,5 @@
-using System;
+using GFGGame;
+using System;
 
 namespace ET
 {
@@ -6,7 +7,24 @@ namespace ET
     {
         protected override async ETTask Run(Session session, M2C_StartSceneChange message)
         {
-            await SceneChangeHelper.SceneChangeTo(GFGGame.GameGlobal.zoneScene, message.SceneName, message.SceneInstanceId);
+            LogUtil.LogDev("Notify Wait_SceneChangeStart");
+            // 通知等待场景切换的协程
+            GameGlobal.zoneScene.GetComponent<ObjectWait>().Notify(new WaitType.Wait_SceneChangeStart());
+
+            CurrentScenesComponent currentScenesComponent = GameGlobal.zoneScene.GetComponent<CurrentScenesComponent>();
+
+            currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
+            Scene currentScene = SceneFactory.CreateCurrentScene(message.SceneInstanceId, GameGlobal.zoneScene.Zone, message.SceneName, currentScenesComponent);
+
+            // 等待CreateMyUnit的消息
+            WaitType.Wait_CreateMyUnit waitCreateMyUnit = await GameGlobal.zoneScene.GetComponent<ObjectWait>().Wait<WaitType.Wait_CreateMyUnit>();
+            M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;
+            Unit unit = UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);
+            GameGlobal.myNumericComponent = unit.GetComponent<NumericComponent>();
+
+            LogUtil.LogDev("Notify Wait_SceneChangeFinish");
+            // 通知等待场景切换的协程
+            GameGlobal.zoneScene.GetComponent<ObjectWait>().Notify(new WaitType.Wait_SceneChangeFinish());
         }
     }
 }

+ 0 - 24
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Scene/SceneChangeHelper.cs

@@ -1,24 +0,0 @@
-using GFGGame;
-
-namespace ET
-{
-    public static class SceneChangeHelper
-    {
-        // 场景切换协程
-        public static async ETTask SceneChangeTo(Scene zoneScene, string sceneName, long sceneInstanceId)
-        {
-            CurrentScenesComponent currentScenesComponent = zoneScene.GetComponent<CurrentScenesComponent>();
-            currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
-            Scene currentScene = SceneFactory.CreateCurrentScene(sceneInstanceId, zoneScene.Zone, sceneName, currentScenesComponent);
-
-            // 等待CreateMyUnit的消息
-            WaitType.Wait_CreateMyUnit waitCreateMyUnit = await zoneScene.GetComponent<ObjectWait>().Wait<WaitType.Wait_CreateMyUnit>();
-            M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;
-            Unit unit = UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);
-            GameGlobal.myNumericComponent = unit.GetComponent<NumericComponent>();
-
-            // 通知等待场景切换的协程
-            zoneScene.GetComponent<ObjectWait>().Notify(new WaitType.Wait_SceneChangeFinish());
-        }
-    }
-}

+ 0 - 11
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Scene/SceneChangeHelper.cs.meta

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

+ 10 - 1
GameClient/Assets/Game/HotUpdate/ETCodes/Hotfix/App/Session/SessionComponentSystem.cs

@@ -5,18 +5,27 @@
 		public override void Destroy(SessionComponent self)
 		{
 			self.AccountSession?.Dispose();
+			self.AccountSession = null;
 			self.GateSession?.Dispose();
+			self.GateSession = null;
 		}
 	}
 
 	public static class SessionComponentComponent
     {
-		public static void Disconnect(this SessionComponent self)
+		public static void DisconnectAccount(this SessionComponent self)
 		{
 			self.AccountSession?.GetComponent<DisConnectedCompnent>()?.CancelAlert();
 			self.AccountSession?.Dispose();
+			self.AccountSession = null;
+		}
+
+		public static void Disconnect(this SessionComponent self)
+		{
+			self.DisconnectAccount();
 			self.GateSession?.GetComponent<DisConnectedCompnent>()?.CancelAlert();
 			self.GateSession?.Dispose();
+			self.GateSession = null;
 		}
     }
 }

+ 10 - 1
GameClient/Assets/Game/HotUpdate/ETCodes/Model/App/WaitType.cs

@@ -21,7 +21,16 @@
 
             public M2C_CreateMyUnit Message;
         }
-        
+
+        public struct Wait_SceneChangeStart : IWaitType
+        {
+            public int Error
+            {
+                get;
+                set;
+            }
+        }
+
         public struct Wait_SceneChangeFinish: IWaitType
         {
             public int Error

+ 1 - 1
GameClient/Assets/Game/HotUpdate/GameConfig.cs

@@ -31,7 +31,7 @@ namespace GFGGame
             var result = JsonMapper.ToObject<Result>(json);
             LoginAddress = result.loginApiUrl;
             // LoginAddress = "http://login.gfg.com:10005";
-            //LoginAddress = "127.0.0.1:10005";//测试地址
+            //LoginAddress = "10.108.64.100:10005";//测试地址
             showGM = int.Parse(result.showGM);
             if(!string.IsNullOrEmpty(result.openTime))
             {

+ 10 - 3
GameClient/Assets/Game/HotUpdate/ServerProxy/QueueSProxy.cs

@@ -7,7 +7,11 @@ namespace GFGGame
         protected override async ETTask Run(Session session, G2C_UpdateQueue message)
         {
             Log.Debug(JsonHelper.ToJson(message));
-            QueueDataManager.Instance.UpQueueData(message.Index, message.Count);
+
+            AlertSystem.Show($"您前面还有{message.Index}人", "当前人数爆满,正在为您排队")
+                .SetLeftButton(true, "取消", (obj) => {
+                    QueueSProxy.ReqSevenCancelQueue().Coroutine();
+                });
             EventAgent.DispatchEvent(ConstMessage.UPDATE_QUEUE);
             await ETTask.CompletedTask;
         }
@@ -19,10 +23,13 @@ namespace GFGGame
         /// 请求服务端取消排队
         /// </summary>
         /// <returns></returns>
-        public static async ETTask<bool> ReqSevenCancelQueue()
+        public static async ETTask ReqSevenCancelQueue()
         {
             var response = (G2C_CancelQueue)await MessageHelper.SendToServer(new C2G_CancelQueue());
-            return response is { Error: ErrorCode.ERR_Success };
+            if(response.Error == ErrorCode.ERR_Success)
+            {
+                ViewManager.Hide<ModalStatusView>();
+            }
         }
     }
 }