| | |
| | | assetVersionUrl = $"{url}/S{serverID}/{date}/{PlayerDatas.Instance.baseData.PlayerID}/{mapID}/{guid}.tfr"; |
| | | } |
| | | Debug.Log($"请求战报: {assetVersionUrl}"); |
| | | HttpRequest.Instance.UnityWebRequestTurnFightGet(assetVersionUrl, guid, 3, OnGetTurnFightData); |
| | | HttpRequestEx.UnityWebRequestTurnFightGet(assetVersionUrl, guid, 3, OnGetTurnFightData); |
| | | } |
| | | |
| | | void OnGetTurnFightData(bool _ok, string guid, byte[] _result) |
| | |
| | | { |
| | | ReadTurnFightInfo(_result); |
| | | } |
| | | else |
| | | { |
| | | Debug.Log($"请求战报失败"); |
| | | UIManager.Instance.CloseWindow<MapLoadingWin>(); |
| | | } |
| | | } |
| | | |
| | | //战报存储的是B430封包,所以需要转发B430封包 |
| New file |
| | |
| | | using System; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine; |
| | | using UnityEngine.Networking; |
| | | |
| | | |
| | | public class HttpRequestEx |
| | | { |
| | | |
| | | |
| | | //回合战报 |
| | | public static void UnityWebRequestTurnFightGet(string _url, string guid, int timeout = 5, Action<bool, string, byte[]> _result = null) |
| | | { |
| | | GetTurnFightData(_url, guid, timeout, _result).Forget(); |
| | | } |
| | | |
| | | static async UniTask GetTurnFightData(string remoteURL, string guid, int timeout, Action<bool, string, byte[]> _result = null) |
| | | { |
| | | |
| | | UnityWebRequest request = UnityWebRequest.Get(remoteURL); |
| | | request.timeout = timeout; |
| | | |
| | | try |
| | | { |
| | | await request.SendWebRequest(); |
| | | if (request.isDone) |
| | | { |
| | | if (request.result == UnityWebRequest.Result.Success) |
| | | { |
| | | _result(true, guid, request.downloadHandler.data); |
| | | } |
| | | else |
| | | { |
| | | Debug.LogError("GetDataBEx 失败 " + request.result.ToString()); |
| | | _result(false, guid, null); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _result(false, guid, null); |
| | | Debug.LogError($"GetDataBEx 异常 - URL: {remoteURL}, Exception: {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | request.Dispose(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | fileFormatVersion: 2 |
| | | guid: ed6e4a4c512e51645bbbc07aef5a50f8 |
| | | MonoImporter: |
| | | externalObjects: {} |
| | | serializedVersion: 2 |
| | | defaultReferences: [] |
| | | executionOrder: 0 |
| | | icon: {instanceID: 0} |
| | | userData: |
| | | assetBundleName: |
| | | assetBundleVariant: |