| 123456789101112131415161718192021222324252627282930 | using GFGGame;using System;namespace ET{    public class M2C_StartSceneChangeHandler : AMHandler<M2C_StartSceneChange>    {        protected override async ETTask Run(Session session, M2C_StartSceneChange message)        {            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());        }    }}
 |