|
@@ -1,3 +1,4 @@
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace GFGGame
|
|
@@ -197,13 +198,122 @@ namespace GFGGame
|
|
|
|
|
|
public static void PutOnRecommendItems2()
|
|
|
{
|
|
|
- GetRecommendItems(out Dictionary<int, List<int>> needListBySubType, out Dictionary<int, List<int>> recommendListBySubType);
|
|
|
+ Dictionary<int, List<int>> itemsDic = GetRecommendItems();
|
|
|
+ List<int> recommendList = new List<int>();
|
|
|
+ foreach (int key in itemsDic.Keys)
|
|
|
+ {
|
|
|
+ if (key == ConstDressUpItemType.SHANG_YI || key == ConstDressUpItemType.XIA_ZHUANG || key == ConstDressUpItemType.LIAN_YI_QUN) continue;
|
|
|
+ recommendList.AddRange(itemsDic[key]);
|
|
|
+ }
|
|
|
+ StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
|
|
|
+ StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
|
|
|
+ SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(fightCfg.needSuitId);
|
|
|
+ int[] suitParts = suitCfg == null ? new int[] { } : suitCfg.partsArr;
|
|
|
+ int shangyiId = itemsDic.ContainsKey(ConstDressUpItemType.SHANG_YI) && itemsDic[ConstDressUpItemType.SHANG_YI].Count > 0 ? itemsDic[ConstDressUpItemType.SHANG_YI][0] : 0;
|
|
|
+ int xiazhuangId = itemsDic.ContainsKey(ConstDressUpItemType.XIA_ZHUANG) && itemsDic[ConstDressUpItemType.XIA_ZHUANG].Count > 0 ? itemsDic[ConstDressUpItemType.XIA_ZHUANG][0] : 0;
|
|
|
+ int lianyiqunId = itemsDic.ContainsKey(ConstDressUpItemType.LIAN_YI_QUN) && itemsDic[ConstDressUpItemType.LIAN_YI_QUN].Count > 0 ? itemsDic[ConstDressUpItemType.LIAN_YI_QUN][0] : 0;
|
|
|
+ if (shangyiId == fightCfg.needItemId || Array.IndexOf(suitParts, shangyiId) >= 0 || xiazhuangId == fightCfg.needItemId || Array.IndexOf(suitParts, xiazhuangId) >= 0)
|
|
|
+ {
|
|
|
+ recommendList.Add(shangyiId);
|
|
|
+ recommendList.Add(xiazhuangId);
|
|
|
+ }
|
|
|
+ else if (lianyiqunId == fightCfg.needItemId || Array.IndexOf(suitParts, lianyiqunId) >= 0)
|
|
|
+ {
|
|
|
+ recommendList.Add(lianyiqunId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int shangyiScore = ItemDataManager.GetItemAdditionScore(shangyiId, InstanceZonesDataManager.currentScoreType);
|
|
|
+ int xiazhuangScore = ItemDataManager.GetItemAdditionScore(xiazhuangId, InstanceZonesDataManager.currentScoreType);
|
|
|
+ int lianyiqunScore = ItemDataManager.GetItemAdditionScore(lianyiqunId, InstanceZonesDataManager.currentScoreType);
|
|
|
+ if (lianyiqunScore > (shangyiScore + xiazhuangScore))
|
|
|
+ {
|
|
|
+ recommendList.Add(lianyiqunId);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ recommendList.Add(shangyiId);
|
|
|
+ recommendList.Add(xiazhuangId);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ dressUpObj.PutOnItemList(recommendList);
|
|
|
+ }
|
|
|
+ private static Dictionary<int, List<int>> GetRecommendItems()
|
|
|
+ {
|
|
|
+ GetClassifyDictionaty(out Dictionary<int, List<int>> needListBySubType, out Dictionary<int, List<int>> recommendListBySubType);
|
|
|
+ DressUpMenuItemCfg1[] menuCfg1s = DressUpMenuItemCfg1Array.Instance.dataArray;
|
|
|
+ Dictionary<int, List<int>> itemsDic = new Dictionary<int, List<int>>();
|
|
|
+ for (int i = 0; i < menuCfg1s.Length - 4; i++)//最后四个不处理(套装、动作、道具、背景)
|
|
|
+ {
|
|
|
+ DressUpMenuItemCfg1 menuCfg1 = menuCfg1s[i];
|
|
|
+ List<int> recommendItems = new List<int>();
|
|
|
+ itemsDic[menuCfg1.id] = recommendItems;
|
|
|
+ if (menuCfg1.subMenusArr.Length == 0)//普通部件有必需品就用必需品,没有必需品就用推荐品
|
|
|
+ {
|
|
|
+ if (needListBySubType.ContainsKey(menuCfg1.type) && needListBySubType[menuCfg1.type].Count > 0)
|
|
|
+ {
|
|
|
+ recommendItems.Add(needListBySubType[menuCfg1.type][0]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (recommendListBySubType.ContainsKey(menuCfg1.type) && recommendListBySubType[menuCfg1.type].Count > 0)
|
|
|
+ {
|
|
|
+ recommendItems.Add(recommendListBySubType[menuCfg1.type][0]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ List<int> needOrnament = new List<int>();//饰品的必需品列表
|
|
|
+ List<int> recommecdOrnament = new List<int>();//饰品的推荐品列表
|
|
|
+ for (int j = 0; j < menuCfg1.subMenusArr.Length; j++)
|
|
|
+ {
|
|
|
+ DressUpMenuItemCfg2 menuCfg2 = DressUpMenuItemCfg2Array.Instance.GetCfg(menuCfg1.subMenusArr[j]);
|
|
|
+
|
|
|
+ if (menuCfg2.type != (int)ConstDressUpItemType.TE_SHU)
|
|
|
+ {
|
|
|
+ if (needListBySubType.ContainsKey(menuCfg2.type) && needListBySubType[menuCfg2.type].Count > 0)
|
|
|
+ {
|
|
|
+ needOrnament.AddRange(needListBySubType[menuCfg2.type]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (recommendListBySubType.ContainsKey(menuCfg2.type) && recommendListBySubType[menuCfg2.type].Count > 0)
|
|
|
+ {
|
|
|
+ recommecdOrnament.AddRange(recommendListBySubType[menuCfg2.type]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (needListBySubType.ContainsKey(menuCfg2.type) && needListBySubType[menuCfg2.type].Count > 0)
|
|
|
+ {
|
|
|
+ needOrnament.AddRange(needListBySubType[menuCfg2.type]);
|
|
|
+ }
|
|
|
+ if (recommendListBySubType.ContainsKey(menuCfg2.type) && recommendListBySubType[menuCfg2.type].Count > 0)
|
|
|
+ {
|
|
|
+ int needCount = Math.Min(recommendListBySubType[menuCfg2.type].Count, 3 - needListBySubType[menuCfg2.type].Count);
|
|
|
+ //特殊部件必需品不足三件,从推荐品里补足
|
|
|
+ recommendListBySubType[menuCfg2.type] = recommendListBySubType[menuCfg2.type].GetRange(0, needCount);
|
|
|
+ recommecdOrnament.AddRange(recommendListBySubType[menuCfg2.type]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ recommendItems.AddRange(needOrnament);
|
|
|
|
|
|
+ if (recommendItems.Count < GlobalCfgArray.globalCfg.dressLimitCount)
|
|
|
+ {
|
|
|
+ DressUpMenuItemDataManager.SortItemListByHighScore(recommecdOrnament);
|
|
|
+ int count = Math.Min(recommecdOrnament.Count, GlobalCfgArray.globalCfg.dressLimitCount - recommendItems.Count);
|
|
|
+ recommecdOrnament = recommecdOrnament.GetRange(0, count);
|
|
|
+ recommendItems.AddRange(recommecdOrnament);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return itemsDic;
|
|
|
}
|
|
|
|
|
|
- //获取每个类型里分数最高的服装部件Dictionary
|
|
|
- private static void GetRecommendItems(out Dictionary<int, List<int>> needListBySubType, out Dictionary<int, List<int>> recommendListBySubType)
|
|
|
+ //获取本关卡所有必需品Dictionary和每个类型的最高分推荐Dictionary,两个Dictionary内部件互斥(必需品不会出现在推荐品里)
|
|
|
+ private static void GetClassifyDictionaty(out Dictionary<int, List<int>> needListBySubType, out Dictionary<int, List<int>> recommendListBySubType)
|
|
|
{
|
|
|
StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
|
|
|
StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
|
|
@@ -243,19 +353,17 @@ namespace GFGGame
|
|
|
}
|
|
|
DressUpMenuItemDataManager.SortItemListByHighScore(needListBySubType[subType]);
|
|
|
int maxCount = subType == (int)ConstDressUpItemType.TE_SHU ? 3 : 1;//特殊部件最多穿3个,其他部件只能穿一个;
|
|
|
- needListBySubType[subType] = needListBySubType[subType].GetRange(0, maxCount);//多余3个取前三
|
|
|
-
|
|
|
-
|
|
|
+ needListBySubType[subType] = needListBySubType[subType].Count > maxCount ? needListBySubType[subType].GetRange(0, maxCount) : needListBySubType[subType];
|
|
|
+ if (!recommendListBySubType.ContainsKey(subType))
|
|
|
+ {
|
|
|
+ recommendListBySubType.Add(subType, new List<int>());
|
|
|
+ }
|
|
|
int index = 0;
|
|
|
- while (recommendListBySubType[subType].Count < maxCount && itemDatasDic[subType].Count > index)//不足3个从列表里补足
|
|
|
+ while (recommendListBySubType[subType].Count < maxCount && itemDatas.Count > index)//不足3个从列表里补足
|
|
|
{
|
|
|
- int partId = itemDatasDic[subType][index];
|
|
|
+ int partId = itemDatas[index];
|
|
|
if (needListBySubType[subType].IndexOf(partId) < 0)//必需品列表里还没有此部件才会被添加进去
|
|
|
{
|
|
|
- if (!recommendListBySubType.ContainsKey(subType))
|
|
|
- {
|
|
|
- recommendListBySubType.Add(subType, new List<int>());
|
|
|
- }
|
|
|
recommendListBySubType[subType].Add(partId);
|
|
|
}
|
|
|
index++;
|