ArenaDataManager.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using UnityEngine;
  5. using FairyGUI;
  6. namespace GFGGame
  7. {
  8. public class ArenaDataManager : SingletonBase<ArenaDataManager>
  9. {
  10. public List<int> ThemeList = new List<int>() { 1, 2, 3 };//本周主题列表
  11. public string Tag = "未央";//本周标签
  12. public int SeasonId = 1;// 赛季id
  13. public int Grade = 1;//本赛季段位
  14. public int Rank = 10000;//本赛季段位内排名
  15. public int HighestGrade = 1;//本赛季最高段位
  16. public int HighestRank = 10000; //本赛最高季段位内排名
  17. public List<FightRoleData> DressupList = new List<FightRoleData>();//我的搭配列表
  18. public List<ArenaTargetData> Targets = new List<ArenaTargetData>();//对手
  19. public ArenaTargetData SelfData = new ArenaTargetData();//自己的排行榜信息
  20. public Dictionary<int, List<ArenaTargetData>> RankDatasDic = new Dictionary<int, List<ArenaTargetData>>();//排行榜数据
  21. public List<ArenaHistoryData> HistoryDatas = new List<ArenaHistoryData>();//获取竞技场历史记录
  22. /*************************************************************************************************************************************/
  23. public Dictionary<int, Texture2D> TextureDic = new Dictionary<int, Texture2D>();
  24. public List<int> roundTime = new List<int>();
  25. public List<int> targetRoundTime = new List<int>();
  26. //Dictionary<回合下标, Dictionary<partId, Dictionary<战斗节点, List<PassivitySkillLvlCfg>>>>
  27. public Dictionary<int, Dictionary<int, Dictionary<int, List<PassivitySkillLvlCfg>>>> vaildSkills = new Dictionary<int, Dictionary<int, Dictionary<int, List<PassivitySkillLvlCfg>>>>();
  28. public Dictionary<int, Dictionary<int, Dictionary<int, List<PassivitySkillLvlCfg>>>> targetVaildSkills = new Dictionary<int, Dictionary<int, Dictionary<int, List<PassivitySkillLvlCfg>>>>();
  29. public int SelectThemeIndex = 0;//当前选中换装主题(ThemeList)的下标
  30. public int SelectTargetIndex = -1;//当前选中挑战对象的下标
  31. public int CurFightIndex = 0;//当前挑战场次下标
  32. public List<long> myScore = new List<long>();//对战数据,三轮分数
  33. public List<long> targetScore = new List<long>();//对战数据,三轮分数
  34. public List<long> myFightScore = new List<long>();//对战数据,竞技场战力,搭配战力,卓越点击战力,卡牌战力
  35. public List<long> targetFightScore = new List<long>();//对战数据,对手竞技场战力,搭配战力,卓越点击战力,卡牌战力
  36. /*************************************************************************************************************************************/
  37. public int LastGrade;//战斗前段位
  38. public int LastRank;//战斗前排行
  39. public OtherRoleInfoData LastTargetInfo = new OtherRoleInfoData();//战斗对手角色信息
  40. public int RewardId;//段位提升奖励
  41. public List<ItemData> BonusList;//战斗结算奖励
  42. /*************************************************************************************************************************************/
  43. /// <summary>
  44. /// 是否快速挑战
  45. /// </summary>
  46. /// <value></value>
  47. public bool QuickFight
  48. {
  49. get
  50. {
  51. return StorageDataManager.Instance.GetStorageValue(ConstStorageId.ARENA_QUICK_FIGHT) == 1 ? true : false;
  52. }
  53. set
  54. {
  55. StorageSProxy.ReqSetClientValue(ConstStorageId.ARENA_QUICK_FIGHT, value == true ? 1 : 0).Coroutine();
  56. }
  57. }
  58. public void Clear()
  59. {
  60. DressupList.Clear();
  61. Targets.Clear();
  62. RankDatasDic.Clear();
  63. HistoryDatas.Clear();
  64. HistoryDatas = null;
  65. TextureDic.Clear();
  66. }
  67. /// <summary>
  68. /// 试图更新最高段位、排行数据
  69. /// </summary>
  70. public void TryUpdateHighest()
  71. {
  72. HighestGrade = HighestGrade >= Grade ? HighestGrade : Grade;
  73. HighestRank = HighestRank >= Rank ? HighestRank : Rank;
  74. }
  75. //获取竞技场对手角色战斗数据
  76. public FightRoleData GetArenaRoleData(int index, ArenaTargetData arenaTarget)
  77. {
  78. return arenaTarget.RoleDressupList[index];
  79. }
  80. //获取竞技场机器人战斗数据
  81. public FightRobotData GetArenaRobotData(int index, ArenaTargetData arenaTarget)
  82. {
  83. return arenaTarget.RobotDressupList[index];
  84. }
  85. /// <summary>
  86. /// 获取推荐卡牌
  87. /// </summary>
  88. public int GetRecommentCardId(int scoreType, List<int> itemList)
  89. {
  90. List<CardData> cardDatas = FightDataManager.Instance.SortCardList(CardDataManager.GetCardListByRarity(0), itemList, scoreType);
  91. int cardId = 0;
  92. for (int j = 0; j < cardDatas.Count; j++)
  93. {
  94. bool isSame = false;
  95. for (int k = 0; k < ArenaDataManager.Instance.ThemeList.Count; k++)
  96. {
  97. FightRoleData roleData = ArenaDataManager.Instance.DressupList[k];
  98. if (cardDatas[j].id == roleData.cardId)
  99. {
  100. isSame = true;
  101. break;
  102. }
  103. }
  104. if (isSame == false)
  105. {
  106. cardId = cardDatas[j].id;
  107. break;
  108. }
  109. }
  110. return cardId;
  111. }
  112. /// <summary>
  113. /// 获取推荐列表
  114. /// </summary>
  115. /// <param name="scoreType"></param>
  116. /// <param name="tags"></param>
  117. /// <returns></returns>
  118. public List<int> GetRecommentItemList(int scoreType, string[] tags)
  119. {
  120. Dictionary<int, List<int>> itemListDic = new Dictionary<int, List<int>>();
  121. Dictionary<int, List<int>> itemDatasDic = DressUpMenuItemDataManager.ItemDatasBySubTypeDic;
  122. foreach (int subType in itemDatasDic.Keys)
  123. {
  124. int key = subType;
  125. if (itemDatasDic.Count == 0) continue;
  126. if (DressUpMenuItemCfg1Array.Instance.CheckIsSceneTypeBySubType(subType)) continue;
  127. List<int> dressList = SortDressList(itemDatasDic[subType], scoreType, tags);
  128. int max = subType == (int)ConstDressUpItemType.TE_SHU ? 3 : 1;
  129. max = Math.Min(max, dressList.Count);
  130. if (DressUpMenuItemCfg1Array.Instance.CheckIsOrnamentsTypeBySubType(subType))
  131. {
  132. key = ConstDressUpItemType.TE_SHU;//饰品全放在一个列表里
  133. }
  134. if (!itemListDic.ContainsKey(key))
  135. {
  136. itemListDic[key] = new List<int>();
  137. }
  138. itemListDic[key].AddRange(dressList.GetRange(0, max));
  139. }
  140. if (itemListDic.ContainsKey(ConstDressUpItemType.LIAN_YI_QUN) &&
  141. (!itemListDic.ContainsKey(ConstDressUpItemType.SHANG_YI) ||
  142. !itemListDic.ContainsKey(ConstDressUpItemType.XIA_ZHUANG) ||
  143. !itemListDic.ContainsKey(ConstDressUpItemType.NEI_DA)))
  144. {
  145. itemListDic.Remove(ConstDressUpItemType.SHANG_YI);
  146. itemListDic.Remove(ConstDressUpItemType.XIA_ZHUANG);
  147. itemListDic.Remove(ConstDressUpItemType.NEI_DA);
  148. }
  149. else if (!itemListDic.ContainsKey(ConstDressUpItemType.LIAN_YI_QUN) &&
  150. (itemListDic.ContainsKey(ConstDressUpItemType.SHANG_YI) &&
  151. itemListDic.ContainsKey(ConstDressUpItemType.XIA_ZHUANG) &&
  152. itemListDic.ContainsKey(ConstDressUpItemType.NEI_DA)))
  153. {
  154. itemListDic.Remove(ConstDressUpItemType.LIAN_YI_QUN);
  155. }
  156. if (itemListDic.ContainsKey(ConstDressUpItemType.LIAN_YI_QUN) && itemListDic.ContainsKey(ConstDressUpItemType.SHANG_YI) && itemListDic.ContainsKey(ConstDressUpItemType.XIA_ZHUANG) && itemListDic.ContainsKey(ConstDressUpItemType.NEI_DA))
  157. {
  158. bool hasTagLYQ = ItemDataManager.CheckItemTagsRight(itemListDic[ConstDressUpItemType.LIAN_YI_QUN][0], tags);
  159. bool hasTagSY = ItemDataManager.CheckItemTagsRight(itemListDic[ConstDressUpItemType.SHANG_YI][0], tags);
  160. bool hasTagXZ = ItemDataManager.CheckItemTagsRight(itemListDic[ConstDressUpItemType.XIA_ZHUANG][0], tags);
  161. bool hasTagND = ItemDataManager.CheckItemTagsRight(itemListDic[ConstDressUpItemType.NEI_DA][0], tags);
  162. if (hasTagLYQ && !hasTagSY && !hasTagXZ)
  163. {
  164. itemListDic.Remove(ConstDressUpItemType.SHANG_YI);
  165. itemListDic.Remove(ConstDressUpItemType.XIA_ZHUANG);
  166. itemListDic.Remove(ConstDressUpItemType.NEI_DA);
  167. }
  168. else if (!hasTagLYQ && (hasTagSY || hasTagXZ))
  169. {
  170. itemListDic.Remove(ConstDressUpItemType.LIAN_YI_QUN);
  171. }
  172. else
  173. {
  174. int scoreLYQ = ItemDataManager.GetItemAdditionScore(itemListDic[ConstDressUpItemType.LIAN_YI_QUN][0], scoreType, tags);
  175. int scoreSY = ItemDataManager.GetItemAdditionScore(itemListDic[ConstDressUpItemType.SHANG_YI][0], scoreType, tags);
  176. int scoreXZ = ItemDataManager.GetItemAdditionScore(itemListDic[ConstDressUpItemType.XIA_ZHUANG][0], scoreType, tags);
  177. int scoreND = ItemDataManager.GetItemAdditionScore(itemListDic[ConstDressUpItemType.NEI_DA][0], scoreType, tags);
  178. if (scoreLYQ > scoreSY + scoreXZ + scoreND)
  179. {
  180. itemListDic.Remove(ConstDressUpItemType.SHANG_YI);
  181. itemListDic.Remove(ConstDressUpItemType.XIA_ZHUANG);
  182. itemListDic.Remove(ConstDressUpItemType.NEI_DA);
  183. }
  184. else
  185. {
  186. itemListDic.Remove(ConstDressUpItemType.LIAN_YI_QUN);
  187. }
  188. }
  189. }
  190. ET.Log.Debug("scoreType:" + scoreType);
  191. List<int> itemList = new List<int>();
  192. foreach (int subType in itemListDic.Keys)
  193. {
  194. ET.Log.Debug("subType:" + subType + " item:" + itemListDic[subType]);
  195. DressUpMenuItemDataManager.SortItemListByHighScore(itemListDic[subType]);
  196. if (subType == ConstDressUpItemType.TE_SHU)
  197. {
  198. int max = Math.Min(itemListDic[subType].Count, 5);
  199. itemList.AddRange(itemListDic[subType].GetRange(0, max));
  200. }
  201. else
  202. {
  203. itemList.AddRange(itemListDic[subType]);
  204. }
  205. }
  206. // ET.Log.Debug("itemList:" + itemList);
  207. return itemList;
  208. }
  209. private List<int> SortDressList(List<int> dressList, int scoreType, string[] tags)
  210. {
  211. dressList.Sort((int a, int b) =>
  212. {
  213. ItemCfg cfgA = ItemCfgArray.Instance.GetCfg(a);
  214. ItemCfg cfgB = ItemCfgArray.Instance.GetCfg(b);
  215. if (ItemDataManager.CheckItemTagsRight(a, tags) && !ItemDataManager.CheckItemTagsRight(b, tags)) return -1;
  216. if (ItemDataManager.CheckItemTagsRight(b, tags) && !ItemDataManager.CheckItemTagsRight(a, tags)) return 1;
  217. int scoreA = ItemDataManager.GetItemAdditionScore(a, scoreType, tags);
  218. int scoreB = ItemDataManager.GetItemAdditionScore(b, scoreType, tags);
  219. return scoreB - scoreA;
  220. });
  221. return dressList;
  222. }
  223. /// <summary>
  224. /// 获取符合标签的服装总个数
  225. /// </summary>
  226. /// <param name="itemList">服装列表</param>
  227. /// <param name="tags">标签</param>
  228. /// <returns></returns>
  229. public int GetTagsCount(List<int> itemList, string[] tags)
  230. {
  231. int count = 0;
  232. for (int i = 0; i < itemList.Count; i++)
  233. {
  234. if (ItemDataManager.CheckItemTagsRight(itemList[i], tags))
  235. {
  236. if (ItemUtilCS.GetItemSubType(itemList[i]) == ConstDressUpItemType.LIAN_YI_QUN)
  237. {
  238. count += 3;
  239. }
  240. {
  241. count++;
  242. }
  243. }
  244. }
  245. return count;
  246. }
  247. /*********************************************************************************************************************/
  248. /// <summary>
  249. /// 获取三套服装总战力
  250. /// </summary>
  251. /// <param name="roleType"></param>
  252. /// <param name="roleDatas"></param>
  253. /// <param name="robotDatas"></param>
  254. /// <returns></returns>
  255. public long GetAllFightScore(int roleType, List<FightRoleData> roleDatas, List<FightRobotData> robotDatas)
  256. {
  257. long fightScore = 0;
  258. List<long> fightScoreDatas = GetFightScoreList(roleType, roleDatas, robotDatas);
  259. for (int i = 0; i < fightScoreDatas.Count; i++)
  260. {
  261. fightScore += fightScoreDatas[i];
  262. }
  263. return fightScore;
  264. }
  265. /// <summary>
  266. /// index=0:搭配战力
  267. /// index=1:卓越点击战力
  268. /// index=2:卡牌战力/技能战力
  269. /// </summary>
  270. /// <param name="roleType"></param>
  271. /// <param name="roleDatas"></param>
  272. /// <param name="robotDatas"></param>
  273. /// <returns></returns>
  274. public List<long> GetFightScoreList(int roleType, List<FightRoleData> roleDatas, List<FightRobotData> robotDatas)
  275. {
  276. List<long> fightScoreDatas = new List<long>();
  277. long itemSum = 0;
  278. long clickScore = 0;
  279. long skillScore = 0;
  280. for (int i = 0; i < ThemeList.Count; i++)
  281. {
  282. if (roleType == ArenaFightTargetType.PLAYER)
  283. {
  284. itemSum += GetItemScoreSum(roleDatas[i].itemScoreList);
  285. clickScore += GetPerfectClickScore(roleDatas[i]) / (long)ConstScoreSystem.PART_SCORE;
  286. skillScore += FightDataManager.Instance.GetSkillFightScore(itemSum, roleDatas[i].baseScore, roleDatas[i].cardId, roleDatas[i].cardScore, roleDatas[i].skillLvs);
  287. }
  288. else
  289. {
  290. itemSum += GetItemScoreSum(robotDatas[i].itemScoreList);
  291. clickScore += GetRobotPerfectClickScore(robotDatas[i]) / (long)ConstScoreSystem.PART_SCORE;
  292. skillScore += FightDataManager.Instance.GetSkillFightScore(itemSum, robotDatas[i].baseScore, robotDatas[i].cardId, robotDatas[i].cardScore, robotDatas[i].skillLvs);
  293. }
  294. }
  295. fightScoreDatas.Add(itemSum);
  296. fightScoreDatas.Add(clickScore);
  297. fightScoreDatas.Add(skillScore);
  298. return fightScoreDatas;
  299. }
  300. /// <summary>
  301. /// 所有部件主属性和
  302. /// </summary>
  303. /// <returns></returns>
  304. public long GetItemScoreSum(List<int> itemScoreList)
  305. {
  306. long scoreSum = 0;
  307. for (int i = 0; i < itemScoreList.Count; i++)
  308. {
  309. scoreSum += (long)itemScoreList[i];
  310. }
  311. return scoreSum;
  312. }
  313. //玩家卓越点击战力
  314. private long GetPerfectClickScore(FightRoleData roleData)
  315. {
  316. long clickScore = 0;
  317. foreach (int key in roleData.pardScoreListDic.Keys)
  318. {
  319. clickScore += (long)ScoreSystemData.Instance.GetPartScore(roleData, key, ClickType.PREFACT_CLICK, 0);
  320. }
  321. return clickScore;
  322. }
  323. //机器人卓越点击战力
  324. private long GetRobotPerfectClickScore(FightRobotData robotData)
  325. {
  326. long clickScore = 0;
  327. FightScoreCfg[] scoreCfg = FightScoreCfgArray.Instance.dataArray;
  328. for (int i = 0; i < scoreCfg.Length; i++)
  329. {
  330. clickScore += (long)ScoreSystemData.Instance.GetRobotPartScore(robotData, i + 1, ClickType.PREFACT_CLICK, 0);
  331. }
  332. return clickScore;
  333. }
  334. /************************************************************************************************************/
  335. public void SetTestInfo()
  336. {
  337. Targets.Add(ArenaSproxy.GetArenaTargetData(GetArenaTargetProto()));
  338. Targets[0].RoleDressupList[0].cardId = 2000009;
  339. Targets[0].RoleDressupList[0].cardScore = 100;
  340. Targets[0].RoleDressupList[0].skillLvs = new List<int>() { 1, 1, 1 };
  341. Targets[0].RoleDressupList[0].itemScoreList = new List<int>() { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 };
  342. Targets[0].RoleDressupList[1].cardId = 2000009;
  343. Targets[0].RoleDressupList[1].cardScore = 100;
  344. Targets[0].RoleDressupList[1].skillLvs = new List<int>() { 1, 1, 1 };
  345. Targets[0].RoleDressupList[1].itemScoreList = new List<int>() { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; Targets[0].RoleDressupList[2].cardId = 2000009;
  346. Targets[0].RoleDressupList[2].cardScore = 100;
  347. Targets[0].RoleDressupList[2].skillLvs = new List<int>() { 1, 1, 1 };
  348. Targets[0].RoleDressupList[2].itemScoreList = new List<int>() { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 };
  349. Targets.Add(ArenaSproxy.GetArenaTargetData(GetArenaTargetProto()));
  350. Targets[1].RoleDressupList[0].cardId = 2000009;
  351. Targets[1].RoleDressupList[0].cardScore = 100;
  352. Targets[1].RoleDressupList[0].skillLvs = new List<int>() { 1, 1, 1 };
  353. Targets[1].RoleDressupList[0].itemScoreList = new List<int>() { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 };
  354. Targets[1].RoleDressupList[1].cardId = 2000009;
  355. Targets[1].RoleDressupList[1].cardScore = 100;
  356. Targets[1].RoleDressupList[1].skillLvs = new List<int>() { 1, 1, 1 };
  357. Targets[1].RoleDressupList[1].itemScoreList = new List<int>() { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; Targets[1].RoleDressupList[2].cardId = 2000009;
  358. Targets[1].RoleDressupList[2].cardScore = 100;
  359. Targets[1].RoleDressupList[2].skillLvs = new List<int>() { 1, 1, 1 };
  360. Targets[1].RoleDressupList[2].itemScoreList = new List<int>() { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 };
  361. Targets.Add(ArenaSproxy.GetArenaTargetData(GetArenaTargetProto1()));
  362. Targets[2].RobotDressupList[0] = ArenaSproxy.GetFightRobotData(GetArenaTargetProto1().RobotDressupInfo, 0);
  363. Targets[2].RobotDressupList[1] = ArenaSproxy.GetFightRobotData(GetArenaTargetProto1().RobotDressupInfo, 0);
  364. Targets[2].RobotDressupList[2] = ArenaSproxy.GetFightRobotData(GetArenaTargetProto1().RobotDressupInfo, 0);
  365. DressupList.Add(new FightRoleData());
  366. DressupList[0].tags = new string[] { Tag };
  367. DressupList.Add(new FightRoleData());
  368. DressupList.Add(new FightRoleData());
  369. // DressupList[0].skillLvs = new List<int>() { 1, 1, 1 };
  370. // DressupList[1].skillLvs = new List<int>() { 1, 1, 1 };
  371. // DressupList[2].skillLvs = new List<int>() { 1, 1, 1 };
  372. }
  373. private ArenaTargetProto GetArenaTargetProto()
  374. {
  375. ArenaTargetProto proto = new ArenaTargetProto();
  376. proto.Grade = 1;
  377. proto.RankInGrade = 10000;
  378. proto.Type = ArenaFightTargetType.PLAYER;
  379. proto.RoleInfo = new OtherRoleInfoProto();
  380. proto.RoleInfo.RoleName = "玩家";
  381. proto.RoleInfo.HeadItemId = 5000002;
  382. proto.RoleInfo.RoleLvl = 10;
  383. ArenaDressupProto dressupProto0 = new ArenaDressupProto();
  384. dressupProto0.CardId = 2000009;
  385. dressupProto0.EquipIds = new List<int>(SuitCfgArray.Instance.GetCfg(201005).partsArr);
  386. proto.PlayerDressupList.Add(dressupProto0);
  387. ArenaDressupProto dressupProto1 = new ArenaDressupProto();
  388. dressupProto1.CardId = 2000010;
  389. dressupProto1.EquipIds = new List<int>(SuitCfgArray.Instance.GetCfg(201006).partsArr);
  390. proto.PlayerDressupList.Add(dressupProto1);
  391. ArenaDressupProto dressupProto2 = new ArenaDressupProto();
  392. dressupProto2.CardId = 2000011;
  393. dressupProto2.EquipIds = new List<int>(SuitCfgArray.Instance.GetCfg(201007).partsArr);
  394. proto.PlayerDressupList.Add(dressupProto2);
  395. return proto;
  396. }
  397. private ArenaTargetProto GetArenaTargetProto1()
  398. {
  399. ArenaTargetProto proto = new ArenaTargetProto();
  400. proto.Grade = 1;
  401. proto.RankInGrade = 10000;
  402. proto.Type = ArenaFightTargetType.ROBOT;
  403. proto.RoleInfo = new OtherRoleInfoProto();
  404. proto.RoleInfo.RoleName = "机器人";
  405. ArenaRobotProto robotProto = new ArenaRobotProto();
  406. robotProto.RobotId = 5;
  407. robotProto.Random = 9000;
  408. robotProto.CardIdList = new List<int>() { 2000009, 2000010, 20000011 };
  409. robotProto.SuitList = new List<int>() { 201011, 201012, 201013 };
  410. proto.RobotDressupInfo = robotProto;
  411. return proto;
  412. }
  413. }
  414. }