|
@@ -1,3 +1,4 @@
|
|
|
+using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using ET;
|
|
@@ -17,7 +18,11 @@ namespace GFGGame
|
|
|
|
|
|
public void InitServerData(SuitFosterData suitFosterData)
|
|
|
{
|
|
|
- _suitInfoBySuitIdDic.Add(suitFosterData.suitId, suitFosterData);
|
|
|
+ if (!_suitInfoBySuitIdDic.ContainsKey(suitFosterData.suitId))
|
|
|
+ {
|
|
|
+ _suitInfoBySuitIdDic.Add(suitFosterData.suitId, suitFosterData);
|
|
|
+ }
|
|
|
+ _suitInfoBySuitIdDic[suitFosterData.suitId] = suitFosterData;
|
|
|
}
|
|
|
public void SetMaintainSuit(int suitId, int maintainStep)
|
|
|
{
|
|
@@ -42,94 +47,124 @@ namespace GFGGame
|
|
|
|
|
|
public SuitFosterData GetSuitFosterData(int suitId)
|
|
|
{
|
|
|
-
|
|
|
- return _suitInfoBySuitIdDic.ContainsKey(suitId) ? _suitInfoBySuitIdDic[suitId] : new SuitFosterData() { suitId = suitId, maintainStep = 0, maintainBonusSteps = new List<int>(), makeNewState = 0 };
|
|
|
+ if (_suitInfoBySuitIdDic.ContainsKey(suitId))
|
|
|
+ {
|
|
|
+ return _suitInfoBySuitIdDic[suitId];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SuitFosterData suitFosterData = new SuitFosterData() { suitId = suitId, maintainStep = 0, maintainBonusSteps = new List<int>(), makeNewState = 0 };
|
|
|
+ InitServerData(suitFosterData);
|
|
|
+ return suitFosterData;
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
//加成属性服装占比
|
|
|
- public List<KeyValuePair<string, int>> GetPropertyPercentData(int suitId, int index)
|
|
|
+ public List<KeyValuePair<int, string>> GetPropertyPercentData(int suitId, int index)
|
|
|
{
|
|
|
- SuitFosterCfg cfg = SuitFosterCfgArray.Instance.GetCfgs(suitId)[index];
|
|
|
- Dictionary<string, int> _data = new Dictionary<string, int>();
|
|
|
- int count = 0;
|
|
|
- for (int i = 0; i < cfg.partsArr.Length; i++)
|
|
|
+ SuitFosterCfg[] cfgs = SuitFosterCfgArray.Instance.GetCfgs(suitId);
|
|
|
+ Dictionary<int, int> _data = new Dictionary<int, int>();
|
|
|
+
|
|
|
+ for (int i = 0; i < cfgs.Length; i++)
|
|
|
{
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.partsArr[i][0]);
|
|
|
- string type = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).name;
|
|
|
- int num = 0;
|
|
|
- if (_data.ContainsKey(type))
|
|
|
+ int[][] partsArr = cfgs[i].partsArr;
|
|
|
+ for (int j = 0; j < partsArr.Length; j++)
|
|
|
{
|
|
|
- num = _data[type];
|
|
|
- }
|
|
|
- num = num + cfg.partsArr[i][1];
|
|
|
- _data.Add(type, num);
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(partsArr[j][0]);
|
|
|
+ // int id = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType).i;
|
|
|
+ if (index < cfgs.Length && index == i || index >= cfgs.Length)
|
|
|
+ {
|
|
|
+ int num = 0;
|
|
|
+
|
|
|
+ if (!_data.ContainsKey(itemCfg.id))
|
|
|
+ {
|
|
|
+ _data.Add(itemCfg.id, num);
|
|
|
+ }
|
|
|
+
|
|
|
+ num = _data[itemCfg.id];
|
|
|
+ num = num + partsArr[j][1];
|
|
|
+ _data[itemCfg.id] = num;
|
|
|
|
|
|
- count += cfg.partsArr[i][1];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- int percentCount = 0;
|
|
|
- int dicIndex = 0;
|
|
|
ICollection keys = _data.Keys;
|
|
|
- Dictionary<string, int> _dataPercent = new Dictionary<string, int>();
|
|
|
- foreach (string key in keys)
|
|
|
+ Dictionary<int, string> _dataPercent = new Dictionary<int, string>();
|
|
|
+ foreach (int key in keys)
|
|
|
{
|
|
|
- if (dicIndex == _data.Count - 1)
|
|
|
- {
|
|
|
- _dataPercent.Add(key, 100 - percentCount);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- _dataPercent.Add(key, Mathf.FloorToInt(_data[key] * 100 / count));
|
|
|
- }
|
|
|
- percentCount += _dataPercent[key];
|
|
|
- dicIndex++;
|
|
|
+
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(key);
|
|
|
+ float mainScore = ItemDataManager.GetItemScoreValue(key, itemCfg.mainScore);
|
|
|
+ float addScore = _data[key];
|
|
|
+ float percent = (addScore / mainScore * 100);
|
|
|
+ _dataPercent.Add(key, percent.ToString("0.00"));
|
|
|
+
|
|
|
}
|
|
|
- return new List<KeyValuePair<string, int>>(_dataPercent);
|
|
|
+ return new List<KeyValuePair<int, string>>(_dataPercent);
|
|
|
}
|
|
|
|
|
|
//获取当前阶段部件属性总值
|
|
|
public void GetPropertyData(int suitId, int index, out SortedList _propertyData, out SortedList _addPropertyData)
|
|
|
{
|
|
|
- SortedList propertyData = new SortedList();
|
|
|
- SortedList addPropertyData = new SortedList();
|
|
|
- int[][] partsArr = SuitFosterCfgArray.Instance.GetCfgs(suitId)[index].partsArr;
|
|
|
- for (int i = 0; i < partsArr.Length; i++)
|
|
|
+ _propertyData = new SortedList();
|
|
|
+ _addPropertyData = new SortedList();
|
|
|
+
|
|
|
+ int[] parts = SuitCfgArray.Instance.GetCfg(suitId).partsArr;
|
|
|
+ for (int i = 0; i < parts.Length; i++)
|
|
|
{
|
|
|
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(partsArr[i][0]);
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(parts[i]);
|
|
|
+ // Debug.Log("zoya:" + itemCfg.id + " " + ItemDataManager.GetScore(itemCfg.id, 1) + " " + ItemDataManager.GetScore(itemCfg.id, 2) + " " + ItemDataManager.GetScore(itemCfg.id, 3) + " " + ItemDataManager.GetScore(itemCfg.id, 4));
|
|
|
for (int j = 0; j < ConstDressUpScoreType.scoreTypeList().Count; j++)
|
|
|
{
|
|
|
int score = j + 1;
|
|
|
int count = ItemDataManager.GetScore(itemCfg.id, score);
|
|
|
- if (propertyData.ContainsKey(score))
|
|
|
- {
|
|
|
- count = count + (int)propertyData[score];
|
|
|
- propertyData[score] = count;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- propertyData.Add(score, count);
|
|
|
- }
|
|
|
|
|
|
- int addCount = 0;
|
|
|
- if (score == itemCfg.mainScore)
|
|
|
+ if (_propertyData.ContainsKey(score))
|
|
|
{
|
|
|
- addCount = partsArr[i][1];
|
|
|
+ count = count + (int)_propertyData[score];
|
|
|
+ _propertyData[score] = count;
|
|
|
}
|
|
|
- if (addPropertyData.ContainsKey(score))
|
|
|
+ else
|
|
|
{
|
|
|
- addCount = addCount + (int)addPropertyData[itemCfg.mainScore];
|
|
|
+ _propertyData.Add(score, count);
|
|
|
}
|
|
|
- else
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SuitFosterCfg[] cfgs = SuitFosterCfgArray.Instance.GetCfgs(suitId);
|
|
|
+ for (int i = 0; i < cfgs.Length; i++)
|
|
|
+ {
|
|
|
+ int[][] partsArr = cfgs[i].partsArr;
|
|
|
+ for (int j = 0; j < partsArr.Length; j++)
|
|
|
+ {
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(partsArr[j][0]);
|
|
|
+ for (int k = 0; k < ConstDressUpScoreType.scoreTypeList().Count; k++)
|
|
|
{
|
|
|
- addPropertyData.Add(score, addCount);
|
|
|
+ int score = k + 1;
|
|
|
+ if (index < cfgs.Length && index == i || index >= cfgs.Length)
|
|
|
+ {
|
|
|
+
|
|
|
+ int addCount = 0;
|
|
|
+ if (score == itemCfg.mainScore)
|
|
|
+ {
|
|
|
+ addCount = partsArr[j][1];
|
|
|
+ }
|
|
|
+ if (_addPropertyData.ContainsKey(score))
|
|
|
+ {
|
|
|
+ addCount = addCount + (int)_addPropertyData[score];
|
|
|
+ _addPropertyData[score] = addCount;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _addPropertyData.Add(score, addCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- _propertyData = propertyData;
|
|
|
- _addPropertyData = addPropertyData;
|
|
|
}
|
|
|
-
|
|
|
//0:已完成,1:养护中,2未养护
|
|
|
public int GetFosterState(int suitId, int index)
|
|
|
{
|
|
@@ -146,38 +181,39 @@ namespace GFGGame
|
|
|
return 2;
|
|
|
}
|
|
|
|
|
|
- public SortedList GetSuitFosterRewards(int suitId)
|
|
|
+ public List<SuitFosterCfg> GetSuitFosterRewards(int suitId)
|
|
|
{
|
|
|
- SuitFosterCfg[] cfg = SuitFosterCfgArray.Instance.GetCfgs(suitId);
|
|
|
- List<SuitFosterCfg> list = new List<SuitFosterCfg>(cfg);
|
|
|
- list = SortRewardList(list, suitId);
|
|
|
-
|
|
|
- SortedList sortedList = new SortedList();
|
|
|
- for (int i = 0; i < list.Count; i++)
|
|
|
+ SuitFosterCfg[] cfgs = SuitFosterCfgArray.Instance.GetCfgs(suitId);
|
|
|
+ List<SuitFosterCfg> list = new List<SuitFosterCfg>(cfgs);
|
|
|
+ for (int i = list.Count - 1; i >= 0; i--)
|
|
|
{
|
|
|
- if (list[i].rewardsArr.Length > 0)
|
|
|
+ if (list[i].rewardsArr.Length == 0)
|
|
|
{
|
|
|
- sortedList.Add((i + 1), list[i]);
|
|
|
+ list.RemoveAt(i);
|
|
|
}
|
|
|
}
|
|
|
+ list = SortRewardList(list, suitId);
|
|
|
|
|
|
- return sortedList;
|
|
|
+ return list;
|
|
|
}
|
|
|
private List<SuitFosterCfg> SortRewardList(List<SuitFosterCfg> list, int suitId)
|
|
|
{
|
|
|
SuitFosterData fosterData = GetSuitFosterData(suitId);
|
|
|
+ SuitFosterCfg[] cfgs = SuitFosterCfgArray.Instance.GetCfgs(suitId);
|
|
|
+
|
|
|
list.Sort((SuitFosterCfg a, SuitFosterCfg b) =>
|
|
|
{
|
|
|
- int indexA = list.IndexOf(a) + 1;
|
|
|
- int indexB = list.IndexOf(b) + 1;
|
|
|
+ int indexA = Array.IndexOf(cfgs, a) + 1;
|
|
|
+ int indexB = Array.IndexOf(cfgs, b) + 1;
|
|
|
if (fosterData.maintainBonusSteps.IndexOf(indexA) >= 0 && fosterData.maintainBonusSteps.IndexOf(indexB) < 0)
|
|
|
{
|
|
|
- return -1;
|
|
|
+ return 1;
|
|
|
}
|
|
|
else if (fosterData.maintainBonusSteps.IndexOf(indexA) < 0 && fosterData.maintainBonusSteps.IndexOf(indexB) >= 0)
|
|
|
{
|
|
|
- return 1;
|
|
|
+ return -1;
|
|
|
}
|
|
|
+
|
|
|
return 0;
|
|
|
});
|
|
|
return list;
|
|
@@ -188,7 +224,7 @@ namespace GFGGame
|
|
|
{
|
|
|
SuitFosterData fosterData = GetSuitFosterData(suitId);
|
|
|
|
|
|
- return fosterData.maintainBonusSteps.IndexOf(step) > 0;
|
|
|
+ return fosterData.maintainBonusSteps.IndexOf(step) >= 0;
|
|
|
}
|
|
|
//当前奖励状态:state 0:未领1:不可领2:已完成
|
|
|
//当前奖励Index
|