using ET; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Text.RegularExpressions; namespace GFGGame { public class CollectPartDataManager : SingletonBase { //部位数量 public const int Count = 8; //普通最高段位 public int MaxNormalRank = 5; //特殊最高段位 public int MaxSpecialRank = 3; //最高等级 public int MaxLevel = 9; //加成比值 public int AddtitionRatio = 100; //搭配部位分类 public Dictionary> partScoreListDic = new Dictionary>(); //部位名 public Dictionary partNameDic = new Dictionary() { [1] = "连衣裙或上下装及内搭", [2] = "发型", [3] = "外套", [4] = "袜子", [5] = "鞋子", [6] = "饰品", [7] = "手持物", [99] = "所有", }; //部位图片 public Dictionary partImage = new Dictionary { [1] = "part1", [2] = "hz_fenleitu_1", [3] = "hz_fenleitu_12", [4] = "hz_fenleitu_7", [5] = "hz_fenleitu_8", [6] = "hz_fenleitu_9", [7] = "hz_fenleitu_10", [99] = "part99", }; //数据 public Dictionary> CollectPartDataDic = new Dictionary>(); //临时数据,后续通过服务器获取 public void UpdateDic() { CollectPartDataDic.Clear(); CollegeBoostCfg collectcfg; for (int i = 1; i <= Count; i++) { List item = new List() { 3, 9 }; if (i == Count) { collectcfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(99, item[0], item[1]); if (collectcfg == null) { item.Add(0); } else { item.Add(collectcfg.value); } if (CollectPartDataDic.ContainsKey(99)) { CollectPartDataDic[99] = item; } else { CollectPartDataDic.Add(99, item); } } else { collectcfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(i, item[0], item[1]); if (collectcfg == null) { item.Add(0); } else { item.Add(collectcfg.value); } if (CollectPartDataDic.ContainsKey(i)) { CollectPartDataDic[i] = item; } else { CollectPartDataDic.Add(i, item); } } } } /// /// 穿戴部件的搭配加成 /// public float GetEquipScoresWithPartId(int itemID) { CollegeSubTypesCfg[] typeCfgs = CollegeSubTypesCfgArray.Instance.dataArray; float addNum = 0; for (int j = 0; j < typeCfgs.Length; j++) { CollegeSubTypesCfg cfg = typeCfgs[j]; for (int k = 0; k < cfg.subTypesArr.Length; k++) { ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID); if (itemCfg.subType == cfg.subTypesArr[k]) { int partIndex = cfg.AdditionSite; int partIndexCommon = 0; partIndexCommon = partIndex; int level = CollectPartDataDic[partIndex][0]; int levelNum = CollectPartDataDic[partIndex][1]; if(levelNum == 0) { addNum += 0; break; } CollegeBoostCfg collegeCfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(partIndex, level, levelNum); addNum += (float)collegeCfg.value / 10000; break; } } } return addNum + 1; } //判断部分是否可以升级 public bool CheckPartCanUP(int pardId) { int rankIndex = CollectPartDataDic[pardId][0]; int rankLv = CollectPartDataDic[pardId][1]; if (rankLv + 1 > CollectPartDataManager.Instance.MaxLevel) { rankIndex += 1; rankLv = 1; } else { rankLv += 1; } CollegeBoostCfg collegeBoostCfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(pardId,rankIndex,rankLv); if (collegeBoostCfg == null) { return false; } for (int i = 0; i < collegeBoostCfg.consumeArr.Length; i++) { ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(collegeBoostCfg.consumeArr[i][0]); ItemData itemCount; long count; if (itemCfg.itemType == ConstItemType.DRESS_UP) { count = ItemDataManager.GetItemNum(collegeBoostCfg.consumeArr[i][0]); } else { if (BagDataManager.Instance.GetBagData().TryGetValue(collegeBoostCfg.consumeArr[i][0], out itemCount)) { count = itemCount.num; } else { count = 0; } } if(count < collegeBoostCfg.consumeArr[i][1]) { return false; } } return true; } //判断所有已开启部位是否可以升级 public bool CheckAllOpenPartCanUP() { if(!FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(ClothingSelectView).Name, false)) { return false; } foreach(var item in CollectPartDataDic) { if(IsOpenRank(item.Key)) { if(CheckPartCanUP(item.Key)) { return true; } } } return false; } public bool IsOpenRank(int partIndex, int levelNum = 9) { List openList; bool isRank = false; bool isLevel = false; bool isPassStory = false; CollegeRankOpenCfg openitem = CollegeRankOpenCfgArray.Instance.GetCfg(partIndex); openList = GetOpenList(partIndex); //判断段位 if (openitem.OpenPreconditionArr == null || openitem.OpenPreconditionArr.Length == 0) { isRank = true; } else { if (CollectPartDataDic[openList[0]][0] >= openList[1]) { if (CollectPartDataDic[openList[0]][1] >= openList[2]) { isRank = true; } } } //判断等级 if (RoleDataManager.lvl >= openitem.needRoleLv) { isLevel = true; } //判断关卡 if (openitem.needStoryLevelId == 0 || InstanceZonesDataManager.CheckLevelPass(openitem.needStoryLevelId)) { isPassStory = true; } else { isPassStory = false; } return isRank && isLevel && isPassStory; } public List GetOpenList(int partIndex) { List openList = new List(); string pattern = @"\d+"; CollegeRankOpenCfg openitem = CollegeRankOpenCfgArray.Instance.GetCfg(partIndex); for (int i = 0; i < openitem.OpenPreconditionArr.Length; i++) { MatchCollection matches = Regex.Matches(openitem.OpenPreconditionArr[i], pattern); foreach (Match match in matches) { openList.Add(int.Parse(match.Value)); } } return openList; } } }