EnterMapHelper.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. G2C_EnterMap g2CEnterMap = await clientScene.GetComponent<SessionComponent>().Session.Call(param) as G2C_EnterMap;
  12. if(g2CEnterMap.Error != 0)
  13. {
  14. //TODO: Error处理
  15. Log.Error(g2CEnterMap.Message);
  16. return;
  17. }
  18. var mapinfo = MapConfigCategory.Instance.Get(player.areaId);
  19. if(mapinfo == null)
  20. {
  21. Log.Error($"Not found map({player.areaId})");
  22. return;
  23. }
  24. SceneChangeHelper.SceneChangeTo(clientScene, mapinfo, g2CEnterMap.MapInstanceId).Coroutine();
  25. // 等待场景切换完成
  26. await clientScene.GetComponent<ObjectWait>().Wait<Wait_SceneChangeFinish>();
  27. //告诉战斗服 i am ready
  28. clientScene.GetComponent<SessionComponent>().Session.Send(new BattleClientReady());
  29. }
  30. catch (Exception e)
  31. {
  32. Log.Error(e);
  33. }
  34. }
  35. }
  36. }