using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using Snxxz.UI;
|
using TableConfig;
|
using LitJson;
|
|
[XLua.LuaCallCSharp]
|
public class ComposeWinModel : Model, IBeforePlayerDataInitialize,IPlayerLoginOk
|
{
|
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
|
{
|
get { return _selectModel ?? (_selectModel = ModelCenter.Instance.GetModel<SelectEquipModel>()); }
|
}
|
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel { get { return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>()); } }
|
|
GetItemPathModel _itemPathModel;
|
GetItemPathModel itemPathModel
|
{
|
get { return _itemPathModel ?? (_itemPathModel = ModelCenter.Instance.GetModel<GetItemPathModel>()); }
|
}
|
|
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);
|
}
|
}
|
}
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
firstTypeDict = null;
|
secondTypeDict = null;
|
secondType = 0;
|
thirdType = 0;
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
SetComposeTypeRed();
|
RefreshComposeRed();
|
playerPack.RefreshItemCountAct -= OnItemCntRefresh;
|
playerPack.RefreshItemCountAct += OnItemCntRefresh;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerLvUpdate;
|
PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerLvUpdate;
|
}
|
|
public void ResetModel()
|
{
|
if (ResetModelEvent != null)
|
{
|
ResetModelEvent();
|
}
|
}
|
|
|
private void PlayerLvUpdate(PlayerDataRefresh type)
|
{
|
if (type != PlayerDataRefresh.LV) return;
|
|
SetComposeTypeRed();
|
RefreshComposeRed();
|
}
|
|
public bool IsComposeJobLimit(int composeId)
|
{
|
int playerJob = PlayerDatas.Instance.baseData.Job;
|
if (composeJobLimitDict.ContainsKey(playerJob))
|
{
|
if(composeJobLimitDict[playerJob].Contains(composeId))
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> GetFirstTypeModel(int firstType)
|
{
|
firstTypeDict = null;
|
firstTypeDict = ItemCompoundConfig.GetFirstComposeTypeDict((int)firstType);
|
return firstTypeDict;
|
}
|
|
public Dictionary<int, List<ItemCompoundConfig>> GetSecondTypeModel(int firstType,int secondType)
|
{
|
GetFirstTypeModel(firstType);
|
secondTypeDict = null;
|
if (firstTypeDict != null)
|
{
|
firstTypeDict.TryGetValue(secondType, out secondTypeDict);
|
}
|
return secondTypeDict;
|
}
|
|
public List<ItemCompoundConfig> GetThirdTypeModellist(int firstType,int secondType,int thirdType)
|
{
|
List<ItemCompoundConfig> modellist = null;
|
GetSecondTypeModel(firstType, secondType);
|
if(secondTypeDict != null)
|
{
|
secondTypeDict.TryGetValue(thirdType, out modellist);
|
}
|
return modellist;
|
}
|
|
public int GetTicketId(int firstType, int secondType, int thirdType)
|
{
|
var itemId = 0;
|
var dict = ItemCompoundConfig.GetFirstComposeTypeDict(firstType);
|
Dictionary<int, List<ItemCompoundConfig>> _secondTypeDict = null;
|
dict.TryGetValue(secondType, out _secondTypeDict);
|
if (_secondTypeDict != null)
|
{
|
List<ItemCompoundConfig> modellist = null;
|
_secondTypeDict.TryGetValue(thirdType, out modellist);
|
if (modellist != null && modellist.Count > 0)
|
{
|
int.TryParse(modellist[0].makeID, out itemId);
|
}
|
}
|
return itemId;
|
}
|
|
public ItemCompoundConfig CurComposeModel { get; private set; }
|
public void SetCurComposeModel(ItemCompoundConfig compoundModel)
|
{
|
CurComposeModel = compoundModel;
|
}
|
|
public bool IsEnoughUnfixedMat(ItemCompoundConfig compoundModel)
|
{
|
if (selectModel.GetHaveUnfixedSelectItem().Count < compoundModel.unfixedItemCount)
|
{
|
return false;
|
}
|
return true;
|
}
|
|
public bool IsEnoughFixedMat(ItemCompoundConfig config)
|
{
|
if (config == null) return false;
|
int[] fixedIds = ItemCompoundConfig.GetDisplayArrayByType(config.id,DisplayItemArray.FixedIds);
|
int[] fixedCounts = ItemCompoundConfig.GetDisplayArrayByType(config.id, DisplayItemArray.FixedCounts);
|
for ( int i = 0; i < fixedCounts.Length; i++)
|
{
|
int haveCount = playerPack.GetItemCountByID(PackType.rptItem,fixedIds[i]);
|
if (haveCount < fixedCounts[i])
|
{
|
return false;
|
}
|
}
|
|
return true;
|
}
|
|
public bool IsEnoughMoney(ItemCompoundConfig compoundModel)
|
{
|
ulong needMoney = (ulong)compoundModel.money;
|
if (UIHelper.GetMoneyCnt(3) < needMoney)
|
{
|
return false;
|
}
|
return true;
|
}
|
/// <summary>
|
/// 发送合成请求
|
/// </summary>
|
private byte[] fixedIndexArray = null;
|
private byte[] addonsReduceArray = null;
|
private byte[] unfixedIndexArray = null;
|
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)
|
{
|
fixedMatIsBindDict.Clear();
|
unfixedMatIsBindDict.Clear();
|
|
if (compoundModel == null)
|
{
|
return;
|
}
|
|
int i = 0;
|
if (!IsEnoughUnfixedMat(compoundModel))
|
{
|
MessageWin.Inst.ShowFixedTip(Language.Get("Compose101"));
|
return;
|
}
|
|
int[] fixedIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedIds);
|
int[] fixedCounts = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedCounts);
|
for (i = 0; i < fixedCounts.Length; i++)
|
{
|
int haveCount = playerPack.GetItemCountByID(PackType.rptItem,fixedIds[i]);
|
if (haveCount < fixedCounts[i])
|
{
|
ItemConfig fixedConfig = Config.Instance.Get<ItemConfig>(fixedIds[i]);
|
if (fixedConfig.GetWay.Length < 1)
|
{
|
ItemAttrData attrData = new ItemAttrData(fixedConfig.ID);
|
itemTipsModel.SetItemTipsModel(attrData);
|
}
|
else
|
{
|
itemPathModel.SetChinItemModel(fixedConfig.ID);
|
}
|
return;
|
}
|
}
|
|
if(!IsEnoughMoney(compoundModel))
|
{
|
ItemConfig fixedConfig = Config.Instance.Get<ItemConfig>(2100);
|
if (fixedConfig.GetWay.Length < 1)
|
{
|
ItemAttrData attrData = new ItemAttrData(fixedConfig.ID);
|
itemTipsModel.SetItemTipsModel(attrData);
|
}
|
else
|
{
|
itemPathModel.SetChinItemModel(fixedConfig.ID);
|
}
|
return;
|
}
|
|
fixedIndexArray = DictToArray(fixedItemIndexDict);
|
addonsReduceArray = new byte[selectModel.GetHaveAddSelectItem().Count];
|
for (i = 0; i < addonsReduceArray.Length; i++)
|
{
|
addonsReduceArray[i] = 1;
|
}
|
|
if(fixedIndexArray != null)
|
{
|
for(i= 0; i < fixedIndexArray.Length;i++ )
|
{
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptItem,fixedIndexArray[i]);
|
SetMatIsBindDict(itemModel,fixedMatIsBindDict);
|
}
|
}
|
|
if(compoundModel.unfixedItemCount > 0)
|
{
|
unfixedIndexArray = DictToArray(selectModel.GetHaveUnfixedSelectItem());
|
}
|
else
|
{
|
unfixedIndexArray = null;
|
}
|
|
if (unfixedIndexArray != null)
|
{
|
for (i = 0; i < unfixedIndexArray.Length; i++)
|
{
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptItem, unfixedIndexArray[i]);
|
SetMatIsBindDict(itemModel,unfixedMatIsBindDict);
|
}
|
}
|
|
if(composeCount < 2)
|
{
|
bool isBind = IsBindByFixedAndUnFixedMat(fixedMatIsBindDict, unfixedMatIsBindDict);
|
bool isHaveRefineMat = IsEatHaveRefineMat();
|
if (compoundModel.successUpper > 0)
|
{
|
if (successRate < compoundModel.successUpper)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ComposeSucRate"),
|
(bool isOk) =>
|
{
|
if (isOk)
|
{
|
if (isBind)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("Compose104"),
|
(bool isCompose) =>
|
{
|
if (isCompose)
|
{
|
if (successRate < 10000)
|
{
|
if (isHaveRefineMat)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("Compose108"), (bool sure) =>
|
{
|
if (sure)
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
});
|
return;
|
}
|
else
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
}
|
else
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
}
|
|
});
|
return;
|
}
|
else
|
{
|
if (successRate < 10000)
|
{
|
if (isHaveRefineMat)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("Compose108"), (bool sure) =>
|
{
|
if (sure)
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
});
|
return;
|
}
|
else
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
}
|
else
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
}
|
}
|
});
|
return;
|
}
|
}
|
|
if (isBind)
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("Compose104"),
|
(bool isCompose) =>
|
{
|
if (isCompose)
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
});
|
}
|
else
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
}
|
else
|
{
|
List<int> idlist = fixedMatIsBindDict.Keys.ToList();
|
if(idlist.Count > 1)
|
{
|
int minBindCnt = 0;
|
int startBindCnt = 0;
|
int nextBindCnt = 0;
|
if(fixedMatIsBindDict[idlist[0]].ContainsKey(1))
|
{
|
startBindCnt = fixedMatIsBindDict[idlist[0]][1];
|
}
|
if(fixedMatIsBindDict[idlist[1]].ContainsKey(1))
|
{
|
nextBindCnt = fixedMatIsBindDict[idlist[1]][1];
|
}
|
minBindCnt = startBindCnt > nextBindCnt ? nextBindCnt : startBindCnt;
|
|
int minNoBindCnt = 0;
|
int startNoBindCnt = 0;
|
int nextNoBindCnt = 0;
|
if (fixedMatIsBindDict[idlist[0]].ContainsKey(0))
|
{
|
startNoBindCnt = fixedMatIsBindDict[idlist[0]][0];
|
}
|
if (fixedMatIsBindDict[idlist[1]].ContainsKey(0))
|
{
|
nextNoBindCnt = fixedMatIsBindDict[idlist[1]][0];
|
}
|
minNoBindCnt = startNoBindCnt > nextNoBindCnt ? nextNoBindCnt : startNoBindCnt;
|
|
int remainNum = composeCount - minBindCnt - minNoBindCnt;
|
|
if(startBindCnt > minBindCnt)
|
{
|
if(remainNum > startBindCnt - minBindCnt)
|
{
|
minBindCnt = startBindCnt;
|
}
|
else
|
{
|
minBindCnt += remainNum;
|
}
|
}
|
else if(nextBindCnt > minBindCnt)
|
{
|
if (remainNum > nextBindCnt - minBindCnt)
|
{
|
minBindCnt = nextBindCnt;
|
}
|
else
|
{
|
minBindCnt += remainNum;
|
}
|
}
|
|
minNoBindCnt = composeCount - minBindCnt;
|
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("Compose107",GetComposeInfoStr(minBindCnt,minNoBindCnt)),
|
(bool isCompose) =>
|
{
|
if (isCompose)
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
});
|
}
|
else
|
{
|
int bindCnt = 0;
|
int noBindCnt = 0;
|
if(fixedMatIsBindDict[idlist[0]].ContainsKey(1))
|
{
|
bindCnt = fixedMatIsBindDict[idlist[0]][1];
|
}
|
|
if(fixedMatIsBindDict[idlist[0]].ContainsKey(0))
|
{
|
noBindCnt = fixedMatIsBindDict[idlist[0]][0];
|
}
|
|
int remainBind = bindCnt % fixedCounts[0];
|
int remainNOBind = noBindCnt % fixedCounts[0];
|
bindCnt = bindCnt / fixedCounts[0];
|
noBindCnt = noBindCnt / fixedCounts[0];
|
if (bindCnt + noBindCnt < composeCount)
|
{
|
bindCnt = composeCount - noBindCnt;
|
}
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("Compose107",GetComposeInfoStr(bindCnt,noBindCnt)),
|
(bool isCompose) =>
|
{
|
if (isCompose)
|
{
|
SendComposeQuest(compoundModel, composEffect, unfixedIndexArray, composeCount);
|
}
|
});
|
}
|
}
|
}
|
|
public void SendComposeQuest(ItemCompoundConfig compoundModel,UIEffect composEffect,byte[] unfixedIndexArray, int composeCount)
|
{
|
composEffect.Play();
|
CA303_tagCMItemCompound itemCompose = null;
|
itemCompose = new CA303_tagCMItemCompound();
|
itemCompose.ID = (uint)compoundModel.id;
|
itemCompose.CompoundCnt = (ushort)composeCount;
|
itemCompose.UnfixedItemIndexCnt = (byte)selectModel.GetHaveUnfixedSelectItem().Count;
|
itemCompose.UnfixedItemIndex = unfixedIndexArray;
|
itemCompose.FixedItemIndexCnt = (byte)fixedIndexArray.Length;
|
itemCompose.FixedItemIndex = fixedIndexArray;
|
itemCompose.AddonsItemIndexCnt = (byte)selectModel.GetHaveAddSelectItem().Count;
|
itemCompose.AddonsItemIndex = DictToArray(selectModel.GetHaveAddSelectItem());
|
itemCompose.AddonsItemCount = addonsReduceArray;
|
GameNetSystem.Instance.SendInfo(itemCompose);
|
}
|
|
public bool IsBindByFixedAndUnFixedMat(Dictionary<int, Dictionary<int, int>> fixedMat, Dictionary<int, Dictionary<int, int>>unfixedMat)
|
{
|
bool isFixedBind = false;
|
bool fixedNoBindRecord = false;
|
foreach (var id in fixedMat.Keys)
|
{
|
foreach (var bind in fixedMat[id].Keys)
|
{
|
if (bind == 1)
|
{
|
isFixedBind = true;
|
}
|
else
|
{
|
fixedNoBindRecord = true;
|
}
|
}
|
}
|
|
bool isUnFixedBind = false;
|
bool unfixedNoBindRecord = false;
|
foreach (var id in unfixedMat.Keys)
|
{
|
foreach (var bind in unfixedMat[id].Keys)
|
{
|
if (bind == 1)
|
{
|
isUnFixedBind = true;
|
}
|
else
|
{
|
unfixedNoBindRecord = true;
|
}
|
}
|
}
|
|
if(fixedMat.Count > 0 && unfixedMat.Count > 0)
|
{
|
if(isFixedBind != isUnFixedBind
|
|| (isFixedBind == isUnFixedBind && fixedNoBindRecord != unfixedNoBindRecord))
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
else if(fixedMat.Count > 0)
|
{
|
if(isFixedBind && fixedNoBindRecord)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
else if(unfixedMat.Count > 0)
|
{
|
if (isUnFixedBind && unfixedNoBindRecord)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
return false;
|
}
|
|
private bool IsEatHaveRefineMat()
|
{
|
Dictionary<int,ItemModel> unfixedDic = selectModel.GetHaveUnfixedSelectItem();
|
bool isRefineMat = false;
|
foreach(var model in unfixedDic.Values)
|
{
|
if(model.GetUseDataModel((int)ItemUseDataKey.Def_IudetWingMaterialItemID) != null)
|
{
|
isRefineMat = true;
|
break;
|
}
|
}
|
return isRefineMat;
|
}
|
|
private void SetMatIsBindDict(ItemModel itemModel,Dictionary<int, Dictionary<int, int>> matDict)
|
{
|
if (itemModel == null) return;
|
|
if (!matDict.ContainsKey(itemModel.itemId))
|
{
|
Dictionary<int, int> bindDict = new Dictionary<int, int>();
|
if (!bindDict.ContainsKey(itemModel.itemInfo.IsBind))
|
{
|
bindDict.Add(itemModel.itemInfo.IsBind, itemModel.itemInfo.ItemCount);
|
}
|
matDict.Add(itemModel.itemId, bindDict);
|
}
|
else
|
{
|
if (!matDict[itemModel.itemId].ContainsKey(itemModel.itemInfo.IsBind))
|
{
|
matDict[itemModel.itemId].Add(itemModel.itemInfo.IsBind, itemModel.itemInfo.ItemCount);
|
}
|
else
|
{
|
matDict[itemModel.itemId][itemModel.itemInfo.IsBind] += itemModel.itemInfo.ItemCount;
|
}
|
}
|
}
|
|
private string GetComposeInfoStr(int bindCnt,int noBindCnt)
|
{
|
if (CurComposeModel == null) return string.Empty;
|
int[] makeIds = ItemCompoundConfig.GetDisplayArrayByType(CurComposeModel.id,DisplayItemArray.MakeIds);
|
ItemConfig config = Config.Instance.Get<ItemConfig>(makeIds[0]);
|
StringBuilder stringBuilder = new StringBuilder();
|
if (bindCnt > 0)
|
{
|
string s = StringUtility.Contact(config.ItemName,Language.Get("Compose105"), "x", bindCnt, "</r>");
|
stringBuilder.Append(s);
|
}
|
|
if (noBindCnt > 0)
|
{
|
string s = StringUtility.Contact(config.ItemName,Language.Get("Compose106"), "x", noBindCnt);
|
stringBuilder.Append(s);
|
}
|
|
return stringBuilder.ToString();
|
}
|
|
private byte[] DictToArray(Dictionary<int, ItemModel> itemDict)
|
{
|
byte[] itemArray = new byte[itemDict.Count];
|
int[] itemIndexs = itemDict.Keys.ToArray();
|
int i = 0;
|
for (i = 0; i < itemIndexs.Length; i++)
|
{
|
itemArray[i] = (byte)itemIndexs[i];
|
}
|
|
return itemArray;
|
}
|
|
private byte[] DictToArray(Dictionary<int, List<int>> itemDict)
|
{
|
int itemArrayLength = 0;
|
foreach (List<int> list in itemDict.Values)
|
{
|
itemArrayLength += list.Count;
|
}
|
byte[] itemArray = new byte[itemArrayLength];
|
int i = 0;
|
foreach (List<int> list in itemDict.Values)
|
{
|
int j = 0;
|
for (j = 0; j < list.Count; j++)
|
{
|
itemArray[i] = (byte)list[j];
|
i++;
|
}
|
|
|
}
|
return itemArray;
|
}
|
|
public void GetBindOrNoBindMinCnt(out int minBindCnt,out int minNoBindCnt)
|
{
|
minBindCnt = 0;
|
minNoBindCnt = 0;
|
if (CurComposeModel == null) return;
|
|
Dictionary<int, int> bindCntDic = new Dictionary<int, int>();
|
Dictionary<int, int> noBindCntDic = new Dictionary<int, int>();
|
int[] fixedIds = ItemCompoundConfig.GetDisplayArrayByType(CurComposeModel.id,DisplayItemArray.FixedIds);
|
for (int i = 0; i < fixedIds.Length;i++)
|
{
|
List<ItemModel> list = null;
|
playerPack.GetSinglePackModel(PackType.rptItem).GetItemCountByID(fixedIds[i],out list);
|
if(list != null)
|
{
|
int bindCnt = 0;
|
int noBindCnt = 0;
|
for (int j = 0; j < list.Count;j++)
|
{
|
if (list[j].itemInfo.IsBind == 1)
|
{
|
bindCnt += list[j].itemInfo.ItemCount;
|
|
}
|
else if (list[j].itemInfo.IsBind == 0)
|
{
|
noBindCnt += list[j].itemInfo.ItemCount;
|
}
|
}
|
bindCntDic.Add(fixedIds[i], bindCnt);
|
noBindCntDic.Add(fixedIds[i], noBindCnt);
|
}
|
}
|
|
List<int> bindCntlist = bindCntDic.Values.ToList();
|
bindCntlist.Sort();
|
if(bindCntlist.Count > 0)
|
{
|
minBindCnt = bindCntlist[0];
|
}
|
|
List<int> noBindCntlist = noBindCntDic.Values.ToList();
|
noBindCntlist.Sort();
|
if (noBindCntlist.Count > 0)
|
{
|
minNoBindCnt = noBindCntlist[0];
|
}
|
|
}
|
|
/// <summary>
|
/// 计算附加材料增加的成功率
|
/// </summary>
|
/// <param name="tagItemCompound"></param>
|
/// <param name="itemModel"></param>
|
/// <param name="successRate"></param>
|
/// <param name="addRate"></param>
|
/// <returns></returns>
|
public int GetComposeSuccessRate(ItemCompoundConfig tagItemCompound, ItemModel itemModel, int successRate)
|
{
|
Equation.Instance.Clear();
|
Equation.Instance.AddKeyValue("itemClassLV", itemModel.chinItemModel.LV);
|
Equation.Instance.AddKeyValue("itemColor", itemModel.chinItemModel.ItemColor);
|
int minRate = Equation.Instance.Eval<int>(addonsFormulaModel.Numerical1);
|
if (tagItemCompound.successUpper != 0)
|
{
|
if (successRate < tagItemCompound.successUpper)
|
{
|
successRate += minRate;
|
}
|
|
if (successRate >= tagItemCompound.successUpper)
|
{
|
successRate = tagItemCompound.successUpper;
|
}
|
}
|
else
|
{
|
successRate += minRate;
|
}
|
|
return successRate;
|
}
|
|
/// <summary>
|
/// 判断是否可以合成门票
|
/// </summary>
|
/// <param name="composeItemID"></param>
|
/// <returns></returns>
|
public bool IsComposeTicketByType(int secondType)
|
{
|
bool isEnough = true;
|
Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> getFirstModel = ItemCompoundConfig.GetFirstComposeTypeDict((int)ComposeFuncType.Ticket);
|
if (getFirstModel.ContainsKey(secondType))
|
{
|
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);
|
for (int i = 0; i < fixedIDs.Length; i++)
|
{
|
int haveCnt = playerPack.GetItemCountByID(PackType.rptItem, fixedIDs[i]);
|
if (fixedCnt[i] > haveCnt)
|
{
|
isEnough = false;
|
break;
|
}
|
}
|
}
|
else
|
{
|
isEnough = false;
|
}
|
}
|
else
|
{
|
isEnough = false;
|
}
|
return isEnough;
|
}
|
|
#region 处理跳转界面数据
|
|
public bool CheckComposeItemById(int itemId,out int jumpId)
|
{
|
jumpId = 0;
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(itemId);
|
if (itemConfig == null) return false;
|
|
int[] composeCondi = itemConfig.JumpComposeCondi;
|
if (composeCondi.Length < 3) return false;
|
ItemCompoundConfig itemCompound = ItemCompoundConfig.GetItemCompoundByType(composeCondi[0], composeCondi[1], composeCondi[2]);
|
if(itemCompound != null)
|
{
|
if (itemCompound.levelNeed <= PlayerDatas.Instance.baseData.LV)
|
{
|
switch (itemCompound.firstType)
|
{
|
case 1:
|
jumpId = (int)JumpUIType.ComposeFunc1;
|
break;
|
case 2:
|
jumpId = (int)JumpUIType.ComposeFunc2;
|
break;
|
case 3:
|
jumpId = (int)JumpUIType.ComposeFunc3;
|
break;
|
case 4:
|
jumpId = (int)JumpUIType.ComposeFunc4;
|
break;
|
case 5:
|
jumpId = (int)JumpUIType.ComposeFunc5;
|
break;
|
}
|
this.secondType = itemCompound.secondType;
|
|
if (itemCompound.firstType == 5 && itemCompound.secondType == 3)
|
{
|
this.thirdType = PlayerDatas.Instance.baseData.Job;
|
}
|
else
|
{
|
this.thirdType = itemCompound.thirdType;
|
}
|
return true;
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("TicketComposeUnlock", itemCompound.levelNeed, itemCompound.secondTypeName);
|
return false;
|
}
|
}
|
|
return false;
|
}
|
|
public bool CheckIsComposeByType(int firstType,int secondType,int thirdType)
|
{
|
ItemCompoundConfig itemCompound = ItemCompoundConfig.GetItemCompoundByType(firstType, secondType, thirdType);
|
if (itemCompound == null) return false;
|
|
if (itemCompound.levelNeed <= PlayerDatas.Instance.baseData.LV)
|
{
|
return true;
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("TicketComposeUnlock", itemCompound.levelNeed, itemCompound.secondTypeName);
|
return false;
|
}
|
}
|
|
public int secondType { get; private set; }
|
public int thirdType { get; private set;}
|
public void SetJumpToModel(ComposeFuncType type,int secondType,int thirdType)
|
{
|
this.secondType = secondType;
|
this.thirdType = thirdType;
|
GetFirstTypeModel((int)type);
|
Dictionary<int, List<ItemCompoundConfig>> dict = GetSecondTypeModel((int)type,secondType);
|
if(dict == null)
|
{
|
SysNotifyMgr.Instance.ShowTip("FuncLimit_Level");
|
ResetJumpToModel();
|
}
|
}
|
|
public void ResetJumpToModel()
|
{
|
this.secondType = 0;
|
this.thirdType = 0;
|
AchievementGoto.guideAchievementId = 0;
|
}
|
#endregion
|
|
#region 红点逻辑
|
public const int COMPOSE_REDKEY = 109;
|
public const int COMPOSETOOL_REDKEY = 10905;
|
public const int COMPOSEBTN_REDKEY = 10910;
|
public Redpoint composeRed = new Redpoint(MainRedDot.RedPoint_key,COMPOSE_REDKEY);
|
public Redpoint composeBtnRed = new Redpoint(COMPOSEBTN_REDKEY);
|
public Redpoint composeToolRed = new Redpoint(COMPOSE_REDKEY,COMPOSETOOL_REDKEY);
|
public Dictionary<int, Redpoint> secondTypeRedDict = new Dictionary<int, Redpoint>();
|
public Dictionary<string, Redpoint> thirdTypeRedDict = new Dictionary<string, Redpoint>();
|
public void SetComposeTypeRed()
|
{
|
secondTypeRedDict.Clear();
|
thirdTypeRedDict.Clear();
|
Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> firstDict = ItemCompoundConfig.GetFirstComposeTypeDict((int)ComposeFuncType.Item);
|
if (firstDict == null) return;
|
|
foreach(var secondType in firstDict.Keys)
|
{
|
int secondRedKey = COMPOSETOOL_REDKEY * 100 + secondType;
|
Redpoint secondRed = new Redpoint(COMPOSETOOL_REDKEY, secondRedKey);
|
secondTypeRedDict.Add(secondType, secondRed);
|
foreach(var thirdType in firstDict[secondType].Keys)
|
{
|
int thirdRedKey = secondRedKey*100 + thirdType;
|
Redpoint thirdRed = new Redpoint(secondRedKey,thirdRedKey);
|
string key = StringUtility.Contact(secondType,10,thirdType);
|
thirdTypeRedDict.Add(key,thirdRed);
|
}
|
}
|
}
|
|
private void OnItemCntRefresh(PackType type, int index, int id)
|
{
|
if (type != PackType.rptItem) return;
|
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(id);
|
if(itemConfig != null && itemConfig.Type == (int)ItemType.ComposeSuitStone)
|
{
|
RefreshComposeRed();
|
}
|
}
|
|
public void RefreshComposeRed()
|
{
|
Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> firstDict = ItemCompoundConfig.GetFirstComposeTypeDict((int)ComposeFuncType.Item);
|
if (firstDict == null || !FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Compose)) return;
|
|
if (firstDict.ContainsKey(3))
|
{
|
foreach(var thirdType in firstDict[3].Keys)
|
{
|
List<ItemCompoundConfig> compoundlist = firstDict[3][thirdType];
|
for(int i = 0; i < compoundlist.Count; i++)
|
{
|
int makeID = ConfigParse.GetMultipleStr<int>(compoundlist[i].makeID)[i];
|
string key = StringUtility.Contact(3, 10, thirdType);
|
if (IsComposeJobLimit(makeID) && IsEnoughFixedMat(compoundlist[i]))
|
{
|
if (thirdTypeRedDict[key].state != RedPointState.Simple)
|
{
|
thirdTypeRedDict[key].state = RedPointState.Simple;
|
}
|
}
|
else
|
{
|
if (thirdTypeRedDict[key].state != RedPointState.None)
|
{
|
thirdTypeRedDict[key].state = RedPointState.None;
|
}
|
}
|
}
|
|
}
|
}
|
}
|
#endregion
|
|
}
|
|
public enum ComposeFuncType
|
{
|
Wings = 1,
|
Ticket = 2,
|
Fairy = 3,
|
Equip = 4,
|
Item = 5,
|
MountDogz = 6,
|
}
|
|
public enum NeedMatType
|
{
|
Nothing,
|
MakeItem,
|
fixedItem,
|
unfixedItem,
|
addItem,
|
}
|
|
public enum DisplayItemArray
|
{
|
MakeIds,
|
UnfixedIds,
|
FixedIds,
|
FixedCounts,
|
UnfixedDisplay,
|
FixedDisplay,
|
}
|
|