using GFGGame; using System; namespace ET { public class M2C_StartSceneChangeHandler : AMHandler { protected override async ETTask Run(Session session, M2C_StartSceneChange message) { LogUtil.LogDev("Notify Wait_SceneChangeStart"); // 通知等待场景切换的协程 GameGlobal.zoneScene.GetComponent().Notify(new WaitType.Wait_SceneChangeStart()); CurrentScenesComponent currentScenesComponent = GameGlobal.zoneScene.GetComponent(); 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().Wait(); M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message; Unit unit = UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit); GameGlobal.myNumericComponent = unit.GetComponent(); LogUtil.LogDev("Notify Wait_SceneChangeFinish"); // 通知等待场景切换的协程 GameGlobal.zoneScene.GetComponent().Notify(new WaitType.Wait_SceneChangeFinish()); } } }