| | |
| | | using System.Collections; |
| | | using System.IO; |
| | | using Cysharp.Threading.Tasks; |
| | | using UnityEngine.Networking; |
| | | |
| | | public class PackManager : GameSystemManager<PackManager> |
| | | { |
| | |
| | | |
| | | async UniTask ParsePackConfigIni() |
| | | { |
| | | string[] lines = await LoadConfigIni("MapServerConfig.ini"); |
| | | string[] lines = await LoadConfigIni("MapServerConfig"); |
| | | foreach (string line in lines) |
| | | { |
| | | if (line.StartsWith("PackCnt") && line.Contains("=")) |
| | |
| | | } |
| | | } |
| | | |
| | | public async UniTask<string[]> LoadConfigIni(string name) |
| | | public UniTask<string[]> LoadConfigIni(string name) |
| | | { |
| | | // string path = string.Empty; |
| | | // #if UNITY_EDITOR |
| | | // if (!AssetSource.isUseAssetBundle) |
| | | // { |
| | | // path = ResourcesPath.CONFIG_FODLER + "/" + name + ".ini"; |
| | | // } |
| | | // else |
| | | // #endif |
| | | // { |
| | | // //从服务端拷贝是ini,打包用txt统一处理 |
| | | // path = AssetVersionUtility.GetAssetFilePath($"Config/{name}.txt"); |
| | | // } |
| | | |
| | | return await ResManager.Instance.LoadConfigAsync(name, false); |
| | | |
| | | // return File.ReadAllLines(path); |
| | | return LoadConfigIniInternal(name); |
| | | } |
| | | |
| | | private async UniTask<string[]> LoadConfigIniInternal(string name) |
| | | { |
| | | string path; |
| | | |
| | | #if UNITY_EDITOR |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | | path = $"{ResourcesPath.CONFIG_FODLER}/{name}.ini"; |
| | | return File.ReadAllLines(path); |
| | | } |
| | | #endif |
| | | |
| | | path = AssetVersionUtility.GetAssetFilePath($"Config/{name}.txt"); |
| | | |
| | | using var req = UnityEngine.Networking.UnityWebRequest.Get(path); |
| | | await req.SendWebRequest(); |
| | | |
| | | if (req.result != UnityEngine.Networking.UnityWebRequest.Result.Success) |
| | | throw new Exception($"LoadConfigIni failed: {req.error}"); |
| | | |
| | | return req.downloadHandler.text |
| | | .Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); |
| | | } |
| | | public int GetCanBuyPackGirdCount(PackType type) |
| | | { |
| | | if (!PackMaxCountDict.ContainsKey((int)type)) |