123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- using ET;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Text.RegularExpressions;
- namespace GFGGame
- {
- public class CollectPartDataManager : SingletonBase<CollectPartDataManager>
- {
- //部位数量
- public const int Count = 8;
- //普通最高段位
- public int MaxNormalRank = 5;
- //特殊最高段位
- public int MaxSpecialRank = 3;
- //最高等级
- public int MaxLevel = 9;
- //加成比值
- public int AddtitionRatio = 100;
- //搭配部位分类
- public Dictionary<int, List<float>> partScoreListDic = new Dictionary<int, List<float>>();
- //部位名
- public Dictionary<int, string> partNameDic = new Dictionary<int, string>()
- { [1] = "连衣裙或上下装及内搭",
- [2] = "发型",
- [3] = "外套",
- [4] = "袜子",
- [5] = "鞋子",
- [6] = "饰品",
- [7] = "手持物",
- [99] = "所有",
- };
- //部位图片
- public Dictionary<int, string> partImage = new Dictionary<int, string>
- {
- [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<int, List<int>> CollectPartDataDic = new Dictionary<int, List<int>>();
- //临时数据,后续通过服务器获取
- public void UpdateDic()
- {
- CollectPartDataDic.Clear();
- CollegeBoostCfg collectcfg;
- for (int i = 1; i <= Count; i++)
- {
- List<int> item = new List<int>() { 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);
- }
- }
- }
- }
- /// <summary>
- /// 穿戴部件的搭配加成
- /// </summary>
- 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<int> 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<int> GetOpenList(int partIndex)
- {
- List<int> openList = new List<int>();
- 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;
- }
- }
- }
|