| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using LitJson; |
| | | using System.Text.RegularExpressions; |
| | | using System.Collections; |
| | | using System.IO; |
| | | |
| | | public class PackManager : GameSystemManager<PackManager> |
| | | //public class PackModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk |
| | | { |
| | | public Dictionary<int, int> PackMaxCountDict = new Dictionary<int, int>(); //背包类型:背包格子最大数量 |
| | | public Dictionary<int, int> PackInitCountDict = new Dictionary<int, int>(); //背包类型:初始数量 |
| | | public int initBagGridCount { get; private set; } //初始物品背包格子数 |
| | | public int[] itemPackSortTyps { get; private set; } //背包物品的按类型排序 |
| | | |
| | | public static string StrengthAttrShift_RecordKey = ""; |
| | | public const string RecordKnapsackTitle = "RecordKnapsackTitle"; |
| | | |
| | |
| | | DeleteItemDictByGUID(type, guid); |
| | | } |
| | | } |
| | | refrechPackEvent?.Invoke(type); |
| | | } |
| | | |
| | | public void RemoveItem(H0709_tagClearItem clearItem) |
| | |
| | | #region 玩家装备特殊逻辑 |
| | | void ParseConfig() |
| | | { |
| | | |
| | | |
| | | var config = FuncConfigConfig.Get("CommonShowAwards"); |
| | | commonShowAwardEvents = JsonMapper.ToObject<List<string>>(config.Numerical1); |
| | | |
| | | config= FuncConfigConfig.Get("InitBagCellCount"); |
| | | initBagGridCount = int.Parse(config.Numerical1); |
| | | PackInitCountDict = ConfigParse.ParseIntDict(config.Numerical2); |
| | | |
| | | config = FuncConfigConfig.Get("PackageSortPriority"); |
| | | itemPackSortTyps = ConfigParse.GetMultipleStr<int>(config.Numerical1); |
| | | ParsePackConfigIni(); |
| | | } |
| | | |
| | | void ParsePackConfigIni() |
| | | { |
| | | string[] lines = LoadConfigIni("MapServerConfig"); |
| | | foreach (string line in lines) |
| | | { |
| | | if (line.StartsWith("PackCnt") && line.Contains("=")) |
| | | { |
| | | string[] parts = line.Split('='); |
| | | if (parts.Length == 2 && int.TryParse(parts[1], out int count)) |
| | | { |
| | | string packTypeStr = parts[0].Replace("PackCnt", ""); |
| | | if (int.TryParse(packTypeStr, out int packTypeIndex)) |
| | | { |
| | | PackMaxCountDict[packTypeIndex] = count; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public string[] LoadConfigIni(string name) |
| | | { |
| | | string path = string.Empty; |
| | | #if UNITY_EDITOR |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | | path = ResourcesPath.CONFIG_FODLER + "/" + name + ".ini"; |
| | | } |
| | | else |
| | | #endif |
| | | { |
| | | path = AssetVersionUtility.GetAssetFilePath($"Config/{name}.ini"); |
| | | } |
| | | |
| | | return File.ReadAllLines(path); |
| | | } |
| | | |
| | | |
| | | private void UpdateSecond() |
| | |
| | | public SinglePack GetSinglePack(PackType type) |
| | | { |
| | | SinglePack singlePack = null; |
| | | playerPackDict.TryGetValue(type, out singlePack); |
| | | if (!playerPackDict.TryGetValue(type, out singlePack)) |
| | | { |
| | | singlePack = new SinglePack(type); |
| | | playerPackDict.Add(type, singlePack); |
| | | } |
| | | return singlePack; |
| | | } |
| | | |