EnterMapHelper.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. namespace ET.Client
  3. {
  4. public static class EnterMapHelper
  5. {
  6. public static async ETTask EnterMapAsync(Scene clientScene, Player player, long scnInstanceId)
  7. {
  8. try
  9. {
  10. var param = new C2G_EnterMap() { InstanceId = scnInstanceId };
  11. var session = clientScene.GetComponent<SessionComponent>().Session;
  12. G2C_EnterMap g2CEnterMap = await session.Call(param) as G2C_EnterMap;
  13. if(g2CEnterMap.Error != 0)
  14. {
  15. //TODO: Error处理
  16. Log.Error(g2CEnterMap.Message);
  17. return;
  18. }
  19. var mapinfo = MapConfigCategory.Instance.Get(player.areaId);
  20. if(mapinfo == null)
  21. {
  22. Log.Error($"Not found map({player.areaId})");
  23. return;
  24. }
  25. SceneChangeHelper.SceneChangeTo(clientScene, mapinfo, g2CEnterMap.MapInstanceId).Coroutine();
  26. // 等待场景切换完成
  27. await clientScene.GetComponent<ObjectWait>().Wait<Wait_SceneChangeFinish>();
  28. //告诉战斗服 i am ready
  29. session.Send(new BattleClientReady());
  30. }
  31. catch (Exception e)
  32. {
  33. Log.Error(e);
  34. }
  35. }
  36. }
  37. }