[+] 接入ET8服务端

[+] 接入ET8服务端
This commit is contained in:
ALEXTANG
2023-07-13 12:23:48 +08:00
parent e0be062006
commit 336d4b2eb9
1316 changed files with 130657 additions and 626 deletions

View File

@@ -0,0 +1,29 @@
namespace ET.Client
{
public static partial class SceneChangeHelper
{
// 场景切换协程
public static async ETTask SceneChangeTo(Scene root, string sceneName, long sceneInstanceId)
{
root.RemoveComponent<AIComponent>();
CurrentScenesComponent currentScenesComponent = root.GetComponent<CurrentScenesComponent>();
currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene创建新的
Scene currentScene = CurrentSceneFactory.Create(sceneInstanceId, sceneName, currentScenesComponent);
UnitComponent unitComponent = currentScene.AddComponent<UnitComponent>();
// 可以订阅这个事件中创建Loading界面
EventSystem.Instance.Publish(root, new EventType.SceneChangeStart());
// 等待CreateMyUnit的消息
Wait_CreateMyUnit waitCreateMyUnit = await root.GetComponent<ObjectWait>().Wait<Wait_CreateMyUnit>();
M2C_CreateMyUnit m2CCreateMyUnit = waitCreateMyUnit.Message;
Unit unit = UnitFactory.Create(currentScene, m2CCreateMyUnit.Unit);
unitComponent.Add(unit);
root.RemoveComponent<AIComponent>();
EventSystem.Instance.Publish(currentScene, new EventType.SceneChangeFinish());
// 通知等待场景切换的协程
root.GetComponent<ObjectWait>().Notify(new Wait_SceneChangeFinish());
}
}
}