CollectPartDataManager.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using ET;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using System.Text.RegularExpressions;
  7. namespace GFGGame
  8. {
  9. public class CollectPartDataManager : SingletonBase<CollectPartDataManager>
  10. {
  11. //部位数量
  12. public const int Count = 8;
  13. //普通最高段位
  14. public int MaxNormalRank = 5;
  15. //特殊最高段位
  16. public int MaxSpecialRank = 3;
  17. //最高等级
  18. public int MaxLevel = 9;
  19. //加成比值
  20. public int AddtitionRatio = 100;
  21. //搭配部位分类
  22. public Dictionary<int, List<float>> partScoreListDic = new Dictionary<int, List<float>>();
  23. //部位名
  24. public Dictionary<int, string> partNameDic = new Dictionary<int, string>()
  25. { [1] = "连衣裙或上下装及内搭",
  26. [2] = "发型",
  27. [3] = "外套",
  28. [4] = "袜子",
  29. [5] = "鞋子",
  30. [6] = "饰品",
  31. [7] = "手持物",
  32. [99] = "所有",
  33. };
  34. //部位图片
  35. public Dictionary<int, string> partImage = new Dictionary<int, string>
  36. {
  37. [1] = "part1",
  38. [2] = "hz_fenleitu_1",
  39. [3] = "hz_fenleitu_12",
  40. [4] = "hz_fenleitu_7",
  41. [5] = "hz_fenleitu_8",
  42. [6] = "hz_fenleitu_9",
  43. [7] = "hz_fenleitu_10",
  44. [99] = "part99",
  45. };
  46. //数据
  47. public Dictionary<int, List<int>> CollectPartDataDic = new Dictionary<int, List<int>>();
  48. //临时数据,后续通过服务器获取
  49. public void UpdateDic()
  50. {
  51. CollectPartDataDic.Clear();
  52. CollegeBoostCfg collectcfg;
  53. for (int i = 1; i <= Count; i++)
  54. {
  55. List<int> item = new List<int>() { 3, 9 };
  56. if (i == Count)
  57. {
  58. collectcfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(99, item[0], item[1]);
  59. if (collectcfg == null)
  60. {
  61. item.Add(0);
  62. }
  63. else
  64. {
  65. item.Add(collectcfg.value);
  66. }
  67. if (CollectPartDataDic.ContainsKey(99))
  68. {
  69. CollectPartDataDic[99] = item;
  70. }
  71. else
  72. {
  73. CollectPartDataDic.Add(99, item);
  74. }
  75. }
  76. else
  77. {
  78. collectcfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(i, item[0], item[1]);
  79. if (collectcfg == null)
  80. {
  81. item.Add(0);
  82. }
  83. else
  84. {
  85. item.Add(collectcfg.value);
  86. }
  87. if (CollectPartDataDic.ContainsKey(i))
  88. {
  89. CollectPartDataDic[i] = item;
  90. }
  91. else
  92. {
  93. CollectPartDataDic.Add(i, item);
  94. }
  95. }
  96. }
  97. }
  98. /// <summary>
  99. /// 穿戴部件的搭配加成
  100. /// </summary>
  101. public float GetEquipScoresWithPartId(int itemID)
  102. {
  103. CollegeSubTypesCfg[] typeCfgs = CollegeSubTypesCfgArray.Instance.dataArray;
  104. float addNum = 0;
  105. for (int j = 0; j < typeCfgs.Length; j++)
  106. {
  107. CollegeSubTypesCfg cfg = typeCfgs[j];
  108. for (int k = 0; k < cfg.subTypesArr.Length; k++)
  109. {
  110. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemID);
  111. if (itemCfg.subType == cfg.subTypesArr[k])
  112. {
  113. int partIndex = cfg.AdditionSite;
  114. int partIndexCommon = 0;
  115. partIndexCommon = partIndex;
  116. int level = CollectPartDataDic[partIndex][0];
  117. int levelNum = CollectPartDataDic[partIndex][1];
  118. if(levelNum == 0)
  119. {
  120. addNum += 0;
  121. break;
  122. }
  123. CollegeBoostCfg collegeCfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(partIndex, level, levelNum);
  124. addNum += (float)collegeCfg.value / 10000;
  125. break;
  126. }
  127. }
  128. }
  129. return addNum + 1;
  130. }
  131. //判断部分是否可以升级
  132. public bool CheckPartCanUP(int pardId)
  133. {
  134. int rankIndex = CollectPartDataDic[pardId][0];
  135. int rankLv = CollectPartDataDic[pardId][1];
  136. if (rankLv + 1 > CollectPartDataManager.Instance.MaxLevel)
  137. {
  138. rankIndex += 1;
  139. rankLv = 1;
  140. }
  141. else
  142. {
  143. rankLv += 1;
  144. }
  145. CollegeBoostCfg collegeBoostCfg = CollegeBoostCfgArray.Instance.GetCfgBytypePartsAndtypePhaseAndlayer(pardId,rankIndex,rankLv);
  146. if (collegeBoostCfg == null)
  147. {
  148. return false;
  149. }
  150. for (int i = 0; i < collegeBoostCfg.consumeArr.Length; i++)
  151. {
  152. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(collegeBoostCfg.consumeArr[i][0]);
  153. ItemData itemCount;
  154. long count;
  155. if (itemCfg.itemType == ConstItemType.DRESS_UP)
  156. {
  157. count = ItemDataManager.GetItemNum(collegeBoostCfg.consumeArr[i][0]);
  158. }
  159. else
  160. {
  161. if (BagDataManager.Instance.GetBagData().TryGetValue(collegeBoostCfg.consumeArr[i][0], out itemCount))
  162. {
  163. count = itemCount.num;
  164. }
  165. else
  166. {
  167. count = 0;
  168. }
  169. }
  170. if(count < collegeBoostCfg.consumeArr[i][1])
  171. {
  172. return false;
  173. }
  174. }
  175. return true;
  176. }
  177. //判断所有已开启部位是否可以升级
  178. public bool CheckAllOpenPartCanUP()
  179. {
  180. if(!FunctionOpenDataManager.Instance.CheckIsFunOpenById(typeof(ClothingSelectView).Name, false))
  181. {
  182. return false;
  183. }
  184. foreach(var item in CollectPartDataDic)
  185. {
  186. if(IsOpenRank(item.Key))
  187. {
  188. if(CheckPartCanUP(item.Key))
  189. {
  190. return true;
  191. }
  192. }
  193. }
  194. return false;
  195. }
  196. public bool IsOpenRank(int partIndex, int levelNum = 9)
  197. {
  198. List<int> openList;
  199. bool isRank = false;
  200. bool isLevel = false;
  201. bool isPassStory = false;
  202. CollegeRankOpenCfg openitem = CollegeRankOpenCfgArray.Instance.GetCfg(partIndex);
  203. openList = GetOpenList(partIndex);
  204. //判断段位
  205. if (openitem.OpenPreconditionArr == null || openitem.OpenPreconditionArr.Length == 0)
  206. {
  207. isRank = true;
  208. }
  209. else
  210. {
  211. if (CollectPartDataDic[openList[0]][0] >= openList[1])
  212. {
  213. if (CollectPartDataDic[openList[0]][1] >= openList[2])
  214. {
  215. isRank = true;
  216. }
  217. }
  218. }
  219. //判断等级
  220. if (RoleDataManager.lvl >= openitem.needRoleLv)
  221. {
  222. isLevel = true;
  223. }
  224. //判断关卡
  225. if (openitem.needStoryLevelId == 0 || InstanceZonesDataManager.CheckLevelPass(openitem.needStoryLevelId))
  226. {
  227. isPassStory = true;
  228. }
  229. else
  230. {
  231. isPassStory = false;
  232. }
  233. return isRank && isLevel && isPassStory;
  234. }
  235. public List<int> GetOpenList(int partIndex)
  236. {
  237. List<int> openList = new List<int>();
  238. string pattern = @"\d+";
  239. CollegeRankOpenCfg openitem = CollegeRankOpenCfgArray.Instance.GetCfg(partIndex);
  240. for (int i = 0; i < openitem.OpenPreconditionArr.Length; i++)
  241. {
  242. MatchCollection matches = Regex.Matches(openitem.OpenPreconditionArr[i], pattern);
  243. foreach (Match match in matches)
  244. {
  245. openList.Add(int.Parse(match.Value));
  246. }
  247. }
  248. return openList;
  249. }
  250. }
  251. }