0312 修复请求不到战报后无法主线战斗异常只能重登的问题
| | |
| | | assetVersionUrl = $"{url}/S{serverID}/{date}/{PlayerDatas.Instance.baseData.PlayerID}/{mapID}/{guid}.tfr"; |
| | | } |
| | | Debug.Log($"请求战报: {assetVersionUrl}"); |
| | | HttpRequestEx.UnityWebRequestTurnFightGet(assetVersionUrl, guid, 3, OnGetTurnFightData); |
| | | HttpRequestEx.UnityWebRequestTurnFightGet(assetVersionUrl, guid, mapID, 3, OnGetTurnFightData); |
| | | } |
| | | |
| | | void OnGetTurnFightData(bool _ok, string guid, byte[] _result) |
| | | void OnGetTurnFightData(bool _ok, string guid, int mapID, byte[] _result) |
| | | { |
| | | if (_ok) |
| | | { |
| | |
| | | { |
| | | Debug.Log($"请求战报失败"); |
| | | UIManager.Instance.CloseWindow<MapLoadingWin>(); |
| | | if (mapID == 2) |
| | | { |
| | | AutoFightModel.Instance.isPause = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | //回合战报 |
| | | public static void UnityWebRequestTurnFightGet(string _url, string guid, int timeout = 5, Action<bool, string, byte[]> _result = null) |
| | | public static void UnityWebRequestTurnFightGet(string _url, string guid, int mapID, int timeout = 5, Action<bool, string, int, byte[]> _result = null) |
| | | { |
| | | GetTurnFightData(_url, guid, timeout, _result).Forget(); |
| | | GetTurnFightData(_url, guid, mapID, timeout, _result).Forget(); |
| | | } |
| | | |
| | | static async UniTask GetTurnFightData(string remoteURL, string guid, int timeout, Action<bool, string, byte[]> _result = null) |
| | | static async UniTask GetTurnFightData(string remoteURL, string guid, int mapID, int timeout, Action<bool, string,int, byte[]> _result = null) |
| | | { |
| | | |
| | | UnityWebRequest request = UnityWebRequest.Get(remoteURL); |
| | | request.timeout = timeout; |
| | | |
| | | try |
| | | { |
| | | UnityWebRequest request = UnityWebRequest.Get(remoteURL); |
| | | request.timeout = timeout; |
| | | await request.SendWebRequest(); |
| | | if (request.isDone) |
| | | { |
| | | if (request.result == UnityWebRequest.Result.Success) |
| | | { |
| | | _result(true, guid, request.downloadHandler.data); |
| | | _result(true, guid, mapID, request.downloadHandler.data); |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("GetDataBEx 失败 " + request.result.ToString()); |
| | | _result(false, guid, null); |
| | | _result(false, guid, mapID, null); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _result(false, guid, null); |
| | | _result(false, guid, mapID, null); |
| | | Debug.LogError($"GetDataBEx 异常 - URL: {remoteURL}, Exception: {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | request.Dispose(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |