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. 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. var task = clientScene.GetComponent<ObjectWait>().Wait<Wait_SceneChangeFinish>();
  27. Log.Debug("tell bat svr i'm ready.");
  28. //告诉战斗服 i am ready
  29. clientScene.GetComponent<SessionComponent>().Session.Send(new BattleClientReady());
  30. }
  31. catch (Exception e)
  32. {
  33. Log.Error(e);
  34. }
  35. }
  36. }
  37. }