1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 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 };
- var session = clientScene.GetComponent<SessionComponent>().Session;
- G2C_EnterMap g2CEnterMap = await 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
- session.Send(new BattleClientReady());
- }
- catch (Exception e)
- {
- Log.Error(e);
- }
- }
- }
- }
|