123456789101112131415161718192021222324252627282930313233343536373839 |
- using System;
- namespace ET.Client
- {
- public static class EnterMapHelper
- {
- public static async ETTask EnterMapAsync(Scene clientScene, Player player, long scnInstanceId)
- {
- try
- {
- var param = new C2G_EnterMap() { InstanceId = scnInstanceId };
- G2C_EnterMap g2CEnterMap = await clientScene.GetComponent<SessionComponent>().Session.Call(param) as G2C_EnterMap;
- if(g2CEnterMap.Error != 0)
- {
- //TODO: Error处理
- Log.Error(g2CEnterMap.Message);
- return;
- }
- var mapinfo = MapConfigCategory.Instance.Get(player.areaId);
- if(mapinfo == null)
- {
- Log.Error($"Not found map({player.areaId})");
- return;
- }
- SceneChangeHelper.SceneChangeTo(clientScene, mapinfo, g2CEnterMap.MapInstanceId).Coroutine();
- // 等待场景切换完成
- await clientScene.GetComponent<ObjectWait>().Wait<Wait_SceneChangeFinish>();
- //告诉战斗服 i am ready
- clientScene.GetComponent<SessionComponent>().Session.Send(new BattleClientReady());
- }
- catch (Exception e)
- {
- Log.Error(e);
- }
- }
- }
- }
|