| | |
| | | {
|
| | | private Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> firstTypeDict = null;
|
| | | private Dictionary<int, List<ItemCompoundConfig>> secondTypeDict = null;
|
| | | private Dictionary<int, List<int>> composeJobLimitDict = new Dictionary<int, List<int>>();
|
| | | private FuncConfigConfig addonsFormulaModel;
|
| | | |
| | | public event Action ResetModelEvent;
|
| | | SelectEquipModel _selectModel;
|
| | | SelectEquipModel selectModel
|
| | |
| | |
|
| | | public override void Init()
|
| | | {
|
| | | addonsFormulaModel = Config.Instance.Get<FuncConfigConfig>("ComposeAddonsFormula");
|
| | | composeJobLimitDict.Clear();
|
| | | FuncConfigConfig funcConfig = Config.Instance.Get<FuncConfigConfig>("ComposeJobLimit");
|
| | | JsonData limitData = JsonMapper.ToObject(funcConfig.Numerical1);
|
| | | foreach(var job in limitData.Keys)
|
| | | {
|
| | | List<int> idlist = new List<int>();
|
| | | composeJobLimitDict.Add(int.Parse(job),idlist);
|
| | | if(limitData[job].IsArray)
|
| | | {
|
| | | for(int i= 0; i < limitData[job].Count; i++)
|
| | | {
|
| | | int id = int.Parse(limitData[job][i].ToString());
|
| | | idlist.Add(id);
|
| | | }
|
| | | }
|
| | | }
|
| | | ParseFuncConfig();
|
| | | ParseItemComoundConfig();
|
| | | }
|
| | |
|
| | | public override void UnInit()
|
| | |
| | | playerPack.RefreshItemCountAct += OnItemCntRefresh;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerLvUpdate;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerLvUpdate;
|
| | | UpdateComposeDataByLevel();
|
| | | }
|
| | |
|
| | | public void ResetModel()
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | private void PlayerLvUpdate(PlayerDataRefresh type)
|
| | | {
|
| | | if (type != PlayerDataRefresh.LV) return;
|
| | |
|
| | | UpdateComposeDataByLevel();
|
| | | SetComposeTypeRed();
|
| | | RefreshComposeRed();
|
| | | }
|
| | |
|
| | | #region 解析本地数据
|
| | | private FuncConfigConfig addonsFormulaModel;
|
| | | private Dictionary<int, List<int>> composeJobLimitDict = new Dictionary<int, List<int>>();
|
| | | public void ParseFuncConfig()
|
| | | {
|
| | | addonsFormulaModel = Config.Instance.Get<FuncConfigConfig>("ComposeAddonsFormula");
|
| | | composeJobLimitDict.Clear();
|
| | | FuncConfigConfig funcConfig = Config.Instance.Get<FuncConfigConfig>("ComposeJobLimit");
|
| | | JsonData limitData = JsonMapper.ToObject(funcConfig.Numerical1);
|
| | | foreach (var job in limitData.Keys)
|
| | | {
|
| | | List<int> idlist = new List<int>();
|
| | | composeJobLimitDict.Add(int.Parse(job), idlist);
|
| | | if (limitData[job].IsArray)
|
| | | {
|
| | | for (int i = 0; i < limitData[job].Count; i++)
|
| | | {
|
| | | int id = int.Parse(limitData[job][i].ToString());
|
| | | idlist.Add(id);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public Dictionary<int, ComposeFirstTypeData> composeDataDict = new Dictionary<int, ComposeFirstTypeData>();
|
| | | public void ParseItemComoundConfig()
|
| | | {
|
| | | composeDataDict.Clear();
|
| | | List<ItemCompoundConfig> itemCompounds = Config.Instance.GetAllValues<ItemCompoundConfig>();
|
| | | for(int i = 0; i < itemCompounds.Count; i++)
|
| | | {
|
| | | AddComposeData(itemCompounds[i],composeDataDict);
|
| | | }
|
| | | }
|
| | |
|
| | | public void AddComposeData(ItemCompoundConfig itemCompound, Dictionary<int, ComposeFirstTypeData> keyValues)
|
| | | {
|
| | | if (itemCompound == null) return;
|
| | |
|
| | | if (!keyValues.ContainsKey(itemCompound.firstType))
|
| | | {
|
| | | var firstData = new ComposeFirstTypeData();
|
| | | firstData.firstType = itemCompound.firstType;
|
| | | firstData.secondTypeDict = new Dictionary<int, ComposeSecondTypeData>();
|
| | | ComposeSecondTypeData secondData = new ComposeSecondTypeData();
|
| | | secondData.secondType = itemCompound.secondType;
|
| | | secondData.thirdTypeDict = new Dictionary<int, List<ComposeThirdTypeData>>();
|
| | | List<ComposeThirdTypeData> thirdTypeDatas = new List<ComposeThirdTypeData>();
|
| | | ComposeThirdTypeData thirdData = new ComposeThirdTypeData();
|
| | | thirdData.thirdType = itemCompound.thirdType;
|
| | | thirdData.itemCompound = itemCompound;
|
| | | thirdTypeDatas.Add(thirdData);
|
| | | firstData.secondTypeDict.Add(secondData.secondType, secondData);
|
| | | secondData.thirdTypeDict.Add(thirdData.thirdType, thirdTypeDatas);
|
| | | keyValues.Add(firstData.firstType, firstData);
|
| | | }
|
| | | else
|
| | | {
|
| | | ComposeSecondTypeData secondData = new ComposeSecondTypeData();
|
| | | secondData.secondType = itemCompound.secondType;
|
| | | var secondTypeDict = keyValues[itemCompound.firstType].secondTypeDict;
|
| | | if (!secondTypeDict.ContainsKey(secondData.secondType))
|
| | | {
|
| | | secondTypeDict.Add(secondData.secondType, secondData);
|
| | | secondData.thirdTypeDict = new Dictionary<int, List<ComposeThirdTypeData>>();
|
| | | List<ComposeThirdTypeData> thirdTypeDatas = new List<ComposeThirdTypeData>();
|
| | | ComposeThirdTypeData thirdData = new ComposeThirdTypeData();
|
| | | thirdData.thirdType = itemCompound.thirdType;
|
| | | thirdData.itemCompound = itemCompound;
|
| | | thirdTypeDatas.Add(thirdData);
|
| | | secondData.thirdTypeDict.Add(thirdData.thirdType, thirdTypeDatas);
|
| | | }
|
| | | else
|
| | | {
|
| | | ComposeThirdTypeData thirdData = new ComposeThirdTypeData();
|
| | | thirdData.thirdType = itemCompound.thirdType;
|
| | | thirdData.itemCompound = itemCompound;
|
| | | var thirdTypeDict = secondTypeDict[secondData.secondType].thirdTypeDict;
|
| | | if (!thirdTypeDict.ContainsKey(thirdData.thirdType))
|
| | | {
|
| | | List<ComposeThirdTypeData> thirdTypeDatas = new List<ComposeThirdTypeData>();
|
| | | thirdTypeDatas.Add(thirdData);
|
| | | thirdTypeDict.Add(thirdData.thirdType, thirdTypeDatas);
|
| | | }
|
| | | else
|
| | | {
|
| | | thirdTypeDict[thirdData.thirdType].Add(thirdData);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public class ComposeFirstTypeData
|
| | | {
|
| | | public int firstType;
|
| | | public Dictionary<int,ComposeSecondTypeData> secondTypeDict = null;
|
| | | }
|
| | | public class ComposeSecondTypeData
|
| | | {
|
| | | public int secondType;
|
| | | public Dictionary<int,List<ComposeThirdTypeData>> thirdTypeDict= null;
|
| | | }
|
| | | public class ComposeThirdTypeData
|
| | | {
|
| | | public int thirdType;
|
| | | public ItemCompoundConfig itemCompound = null;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region 数据变动
|
| | | public Dictionary<int, ComposeFirstTypeData> composeOpenDataDict = new Dictionary<int, ComposeFirstTypeData>();
|
| | | public void UpdateComposeDataByLevel()
|
| | | {
|
| | | composeOpenDataDict.Clear();
|
| | | int playerLv = PlayerDatas.Instance.baseData.LV;
|
| | | foreach (var first in composeDataDict.Keys)
|
| | | {
|
| | | var secondTypeDict = composeDataDict[first].secondTypeDict;
|
| | | foreach (var second in secondTypeDict.Keys)
|
| | | {
|
| | | var thirdTypeDict = secondTypeDict[second].thirdTypeDict;
|
| | | foreach (var third in thirdTypeDict.Keys)
|
| | | {
|
| | | for(int i = 0; i < thirdTypeDict[third].Count; i++)
|
| | | {
|
| | | var thirdData = thirdTypeDict[third][i];
|
| | | if(playerLv >= thirdData.itemCompound.levelNeed
|
| | | ||(thirdData.itemCompound.trailerLevel != 0 && playerLv >= thirdData.itemCompound.trailerLevel))
|
| | | {
|
| | | AddComposeData(thirdData.itemCompound, composeOpenDataDict);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public bool TryGetFirstTypeData(int firstType,out ComposeFirstTypeData firstTypeData)
|
| | | {
|
| | | firstTypeData = null;
|
| | | return composeDataDict.TryGetValue(firstType,out firstTypeData);
|
| | | }
|
| | |
|
| | | public bool TryGetSecondTypeData(int firstType,int secondType,out ComposeSecondTypeData secondTypeData)
|
| | | {
|
| | | ComposeFirstTypeData firstTypeData = null;
|
| | | secondTypeData = null;
|
| | | bool isFirst = TryGetFirstTypeData(firstType,out firstTypeData);
|
| | | if(isFirst)
|
| | | {
|
| | | return firstTypeData.secondTypeDict.TryGetValue(secondType,out secondTypeData);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool TryGetThirdTypeData(int firstType, int secondType, int thirdType, out List<ComposeThirdTypeData> thirdTypeDatas)
|
| | | {
|
| | | ComposeSecondTypeData secondTypeData = null;
|
| | | thirdTypeDatas = null;
|
| | | bool isSecond = TryGetSecondTypeData(firstType, secondType, out secondTypeData);
|
| | | if (isSecond)
|
| | | {
|
| | | return secondTypeData.thirdTypeDict.TryGetValue(thirdType, out thirdTypeDatas);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool TryGetThirdTypeData(int firstType, int secondType,int thirdType,out ComposeThirdTypeData thirdTypeData)
|
| | | {
|
| | | ComposeSecondTypeData secondTypeData = null;
|
| | | thirdTypeData = null;
|
| | | bool isSecond = TryGetSecondTypeData(firstType,secondType ,out secondTypeData);
|
| | | if (isSecond)
|
| | | {
|
| | | List<ComposeThirdTypeData> thirdTypeDatas = null;
|
| | | bool isThird = secondTypeData.thirdTypeDict.TryGetValue(thirdType, out thirdTypeDatas);
|
| | | if(isThird)
|
| | | {
|
| | | thirdTypeData = thirdTypeDatas[0];
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public ItemCompoundConfig CurComposeModel { get; private set; }
|
| | | public void SetCurComposeModel(ItemCompoundConfig compoundModel)
|
| | | {
|
| | | CurComposeModel = compoundModel;
|
| | | }
|
| | |
|
| | | public event Action<int> UpdateThirdTypeEvent;
|
| | | public void UpdateThirdType(int thirdType)
|
| | | {
|
| | | if (UpdateThirdTypeEvent != null)
|
| | | {
|
| | | UpdateThirdTypeEvent(thirdType);
|
| | | }
|
| | | }
|
| | | public event Action<int> UpdateSecondTypeEvent;
|
| | | public void UpdateSecondType(int secondType)
|
| | | {
|
| | | if (UpdateSecondTypeEvent != null)
|
| | | {
|
| | | UpdateSecondTypeEvent(secondType);
|
| | | }
|
| | | }
|
| | |
|
| | | public bool TryGetIncreaseRateItemIndex(ItemCompoundConfig itemCompound,bool IsIncrease, out List<int> indexlist)
|
| | | {
|
| | | indexlist = null;
|
| | | if (!IsIncrease || itemCompound == null) return false;
|
| | |
|
| | | SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
| | | int[] increases = itemCompound.successRateIncrease;
|
| | | indexlist = singlePack.ItemIndexlist(increases[0], increases[1]);
|
| | | return true;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | public bool IsComposeJobLimit(int composeId)
|
| | | {
|
| | |
| | | return modellist;
|
| | | }
|
| | |
|
| | | public bool IsTrailerByLevel(ItemCompoundConfig itemCompound)
|
| | | {
|
| | | if (itemCompound.trailerLevel <= 0) return false;
|
| | | |
| | | int playerLv = PlayerDatas.Instance.baseData.LV;
|
| | | if(playerLv >= itemCompound.trailerLevel && playerLv < itemCompound.levelNeed)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public int GetTicketId(int firstType, int secondType, int thirdType)
|
| | | {
|
| | | var itemId = 0;
|
| | |
| | | _secondTypeDict.TryGetValue(thirdType, out modellist);
|
| | | if (modellist != null && modellist.Count > 0)
|
| | | {
|
| | | int.TryParse(modellist[0].makeID, out itemId);
|
| | | itemId = modellist[0].makeID[0];
|
| | | }
|
| | | }
|
| | | return itemId;
|
| | | }
|
| | |
|
| | | public ItemCompoundConfig CurComposeModel { get; private set; }
|
| | | public void SetCurComposeModel(ItemCompoundConfig compoundModel)
|
| | | {
|
| | | CurComposeModel = compoundModel;
|
| | | }
|
| | |
|
| | | public bool IsEnoughUnfixedMat(ItemCompoundConfig compoundModel)
|
| | |
| | | Dictionary<int, Dictionary<int, int>> fixedMatIsBindDict = new Dictionary<int, Dictionary<int, int>>(); //id , isBind, count
|
| | | Dictionary<int, Dictionary<int, int>> unfixedMatIsBindDict = new Dictionary<int, Dictionary<int, int>>();
|
| | |
|
| | | public void SendComposeRequest(ItemCompoundConfig compoundModel, Dictionary<int, List<int>> fixedItemIndexDict,UIEffect composEffect,int composeCount = 1,int successRate = 10000)
|
| | | public void SendComposeRequest(ItemCompoundConfig compoundModel, Dictionary<int, List<int>> fixedItemIndexDict,UIEffect composEffect,int composeCount = 1,int successRate = 10000,bool isIncrease = false)
|
| | | {
|
| | | fixedMatIsBindDict.Clear();
|
| | | unfixedMatIsBindDict.Clear();
|
| | |
| | | {
|
| | | if (sure)
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount,isIncrease);
|
| | | }
|
| | | });
|
| | | return;
|
| | | }
|
| | | else
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | if (sure)
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | });
|
| | | return;
|
| | | }
|
| | | else
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | {
|
| | | if (isCompose)
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | });
|
| | | }
|
| | | else
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | }
|
| | | else
|
| | |
| | | {
|
| | | if (isCompose)
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | {
|
| | | if (isCompose)
|
| | | {
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
| | | SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount, isIncrease);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void SendComposeQuest(ItemCompoundConfig compoundModel,UIEffect composEffect,byte[] unfixedIndexArray, int composeCount)
|
| | | public void SendComposeQuest(ItemCompoundConfig compoundModel,UIEffect composEffect,byte[] unfixedIndexArray, int composeCount,bool isIncrease)
|
| | | {
|
| | | composEffect.Play();
|
| | | CA303_tagCMItemCompound itemCompose = null;
|
| | |
| | | itemCompose.AddonsItemIndexCnt = (byte)selectModel.GetHaveAddSelectItem().Count;
|
| | | itemCompose.AddonsItemIndex = DictToArray(selectModel.GetHaveAddSelectItem());
|
| | | itemCompose.AddonsItemCount = addonsReduceArray;
|
| | | List<int> increaseIndexlist = null;
|
| | | TryGetIncreaseRateItemIndex(compoundModel,isIncrease,out increaseIndexlist);
|
| | | byte[] increaseRateIndexArray = null;
|
| | | if (increaseIndexlist != null)
|
| | | {
|
| | | increaseRateIndexArray = ListToArray(increaseIndexlist);
|
| | | itemCompose.RateIncreaseItemIndexCnt = (byte)increaseRateIndexArray.Length;
|
| | | itemCompose.RateIncreaseItemIndex = increaseRateIndexArray;
|
| | | }
|
| | | else
|
| | | {
|
| | | itemCompose.RateIncreaseItemIndexCnt = 0;
|
| | | itemCompose.RateIncreaseItemIndex = new byte[0];
|
| | | }
|
| | | GameNetSystem.Instance.SendInfo(itemCompose);
|
| | | }
|
| | |
|
| | |
| | | return itemArray;
|
| | | }
|
| | |
|
| | | private byte[] ListToArray(List<int> list)
|
| | | {
|
| | | byte[] itemArray = new byte[list.Count];
|
| | | int i = 0;
|
| | | for (i = 0; i < list.Count; i++)
|
| | | {
|
| | | itemArray[i] = (byte)list[i];
|
| | | }
|
| | |
|
| | | return itemArray;
|
| | | }
|
| | |
|
| | | private byte[] DictToArray(Dictionary<int, List<int>> itemDict)
|
| | | {
|
| | | int itemArrayLength = 0;
|
| | |
| | | if (getFirstModel[secondType].ContainsKey(0))
|
| | | {
|
| | | ItemCompoundConfig compoundConfig = getFirstModel[secondType][0][0];
|
| | | int[] fixedIDs = ConfigParse.GetMultipleStr<int>(compoundConfig.itemID);
|
| | | int[] fixedCnt = ConfigParse.GetMultipleStr<int>(compoundConfig.itemCount);
|
| | | int[] fixedIDs = compoundConfig.itemID;
|
| | | int[] fixedCnt = compoundConfig.itemCount;
|
| | | for (int i = 0; i < fixedIDs.Length; i++)
|
| | | {
|
| | | int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, fixedIDs[i]);
|
| | |
| | | List<ItemCompoundConfig> compoundlist = firstDict[3][thirdType];
|
| | | for(int i = 0; i < compoundlist.Count; i++)
|
| | | {
|
| | | int makeID = ConfigParse.GetMultipleStr<int>(compoundlist[i].makeID)[i];
|
| | | int makeID = compoundlist[i].makeID[i];
|
| | | string key = StringUtility.Contact(3, 10, thirdType);
|
| | | if (IsComposeJobLimit(makeID) && IsEnoughFixedMat(compoundlist[i]))
|
| | | {
|
| | |
| | | fixedItem,
|
| | | unfixedItem,
|
| | | addItem,
|
| | | IncreaseItem,
|
| | | }
|
| | |
|
| | | public enum DisplayItemArray
|