using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using LitJson;
|
|
public class TreasurePavilionModel : ILModel<TreasurePavilionModel>
|
{
|
//古宝ID:[星级,等级]
|
Dictionary<int, List<int>> gubaoDict = new Dictionary<int, List<int>>();
|
List<int> gubaoShowList = new List<int>(); //排序显示 可激活-已激活-品质
|
|
public Dictionary<int, int> gubaoAwardDict = new Dictionary<int, int>();
|
public Dictionary<int, int> gubaoEffectDict = new Dictionary<int, int>(); //古宝特效
|
public Dictionary<int, string> gubaoDiIconDict = new Dictionary<int, string>();
|
public int[] xbIDArr;
|
public Dictionary<int, int> luckyDrawFuncIDDict = new Dictionary<int, int>();
|
public event Action UpdateGubaoEvent;
|
public Dictionary<int, Dictionary<int, int[]>> probabilityDisplayDict = new Dictionary<int, Dictionary<int, int[]>>();
|
public int selectGubao; //从藏宝阁选中
|
public int waitActiveGubao; //激活等待显示的古宝
|
public int upgradeGubao; //当前升级升星的古宝
|
public int upgradeFuncOrder = 0;//0升星1升级
|
string scoreFormula;
|
public bool isEffectPlaying = false;//古宝抽奖动画正在播放
|
public List<int> gubaoTypeList = new List<int>();
|
public Dictionary<int, int> gubaoItemCountDict = new Dictionary<int, int>(); //古宝碎片背包物品改为数值记录
|
public event Action UpdateGubaoItemCountEvent;
|
|
public bool isSkipOneTip = false; //本次登录是否跳过一次购买二次确认窗口
|
public bool isSkipManyTip = false; //本次登录是否跳过多次购买二次确认窗口
|
public bool isWinOpen = false;
|
int getA3CBCount; //古宝收到了几次包
|
int m_SelectIndex; //古宝总类型
|
public event Action OnSelectUpdate;
|
public int selectIndex
|
{
|
get { return m_SelectIndex; }
|
set
|
{
|
if (m_SelectIndex != value)
|
{
|
m_SelectIndex = value;
|
OnSelectUpdate?.Invoke();
|
}
|
}
|
}
|
|
int m_SelectTagIndex = 0; //古宝Tag类型 0 全部 1 共鸣 2 可升星
|
public int selectTagIndex
|
{
|
get { return m_SelectTagIndex; }
|
set
|
{
|
if (m_SelectTagIndex != value)
|
{
|
m_SelectTagIndex = value;
|
OnSelectUpdate?.Invoke();
|
}
|
}
|
}
|
|
int m_SelectResonanceID = 0;
|
public int selectResonanceID
|
{
|
get { return m_SelectResonanceID; }
|
set
|
{
|
if (m_SelectResonanceID != value)
|
{
|
m_SelectResonanceID = value;
|
}
|
}
|
}
|
|
bool m_showLuckyDraw = false;
|
public bool isShowLuckyDraw
|
{
|
get { return m_showLuckyDraw; }
|
set
|
{
|
if (m_showLuckyDraw != value)
|
{
|
m_showLuckyDraw = value;
|
OnSelectUpdate?.Invoke();
|
}
|
}
|
}
|
int m_XBIndex = 0;
|
public int xbIndex
|
{
|
get { return m_XBIndex; }
|
set
|
{
|
if (m_XBIndex != value)
|
{
|
m_XBIndex = value;
|
OnSelectUpdate?.Invoke();
|
}
|
}
|
}
|
|
PackModel packModel { get { return ModelCenter.Instance.GetModelEx<PackModel>(); } }
|
|
Dictionary<int, Redpoint> activeRedPointDict = new Dictionary<int, Redpoint>();
|
Dictionary<int, Redpoint> starRedPointDict = new Dictionary<int, Redpoint>();
|
Dictionary<int, Redpoint> lvRedPointDict = new Dictionary<int, Redpoint>();
|
Dictionary<int, Redpoint> awardRedPointDict = new Dictionary<int, Redpoint>();
|
Redpoint tmpRP = new Redpoint(MainRedDot.RedPoint_key, MainRedPoint.cbgRedpoint);
|
Redpoint treasureLuckyDrawRedpoint = new Redpoint(MainRedPoint.cbgRedpoint, MainRedDot.TreasureLuckyDrawRedpoint); //古宝抽奖入口红点
|
List<Redpoint> treasureLuckyDrawTabRedpointList = new List<Redpoint>(); //古宝抽奖Tab红点
|
Redpoint treasureLuckDrawFreeRedpoint = new Redpoint(MainRedDot.TreasureLuckyDrawRedpoint, MainRedDot.TreasureLuckyDrawRedpoint * 10 + 9);//免费抽奖红点
|
TreasurePavilionUpgradeChooseModel treasurePavilionUpgradeChooseModel { get { return ModelCenter.Instance.GetModelEx<TreasurePavilionUpgradeChooseModel>(); } }
|
protected override void Init()
|
{
|
GameEvent.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
|
packModel.refreshItemCountEvent += RefreshItemCount;
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFunctionStateChange;
|
ParseConfig();
|
|
for (int i = 0; i < gubaoTypeList.Count; i++)
|
{
|
new Redpoint(MainRedPoint.cbgRedpoint, MainRedPoint.cbgRedpoint * 10 + gubaoTypeList[i]);
|
}
|
for (int i = 0; i < 4; i++)
|
{
|
treasureLuckyDrawTabRedpointList.Add(new Redpoint(MainRedDot.TreasureLuckyDrawRedpoint, MainRedDot.TreasureLuckyDrawRedpoint * 10 + i));
|
}
|
var gubaoKeys = ILGubaoConfig.GetKeys();
|
for (int i = 0; i < gubaoKeys.Count; i++)
|
{
|
var gubaoID = int.Parse(gubaoKeys[i]);
|
var gubaoRPID = MainRedPoint.cbgRedpoint * 10000 + gubaoID;
|
var config = ILGubaoConfig.Get(gubaoID);
|
new Redpoint(MainRedPoint.cbgRedpoint * 10 + config.GubaoType, gubaoRPID);
|
activeRedPointDict[gubaoID] = new Redpoint(gubaoRPID, gubaoRPID * 10);
|
starRedPointDict[gubaoID] = new Redpoint(gubaoRPID, gubaoRPID * 10 + 1);
|
lvRedPointDict[gubaoID] = new Redpoint(gubaoRPID, gubaoRPID * 10 + 2);
|
var starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, 1));
|
if (starConfig.StarEffIDList[0] != 0 && ILGubaoEffAttrConfig.Get(starConfig.StarEffIDList[0]).EffItemAwardList.Length > 2)
|
{
|
awardRedPointDict[gubaoID] = new Redpoint(gubaoRPID, gubaoRPID * 10 + 3);
|
}
|
//if (!unLockItems.Contains(config.UnlockItemID))
|
//{
|
// unLockItems.Add(config.UnlockItemID);
|
//}
|
}
|
}
|
|
protected override void UnInit()
|
{
|
GameEvent.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
|
packModel.refreshItemCountEvent -= RefreshItemCount;
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFunctionStateChange;
|
}
|
private void OnFunctionStateChange(int id)
|
{
|
if (id == 234)
|
{
|
UpdateLuckyDrawRedpoint();
|
}
|
}
|
void ParseConfig()
|
{
|
gubaoTypeList = ILGubaoConfig.gubaoTypeDict.Keys.ToList();
|
//gubaoShowList.Clear();
|
//var tmpList = ILGubaoConfig.GetKeys();
|
//for (int i = 0; i < tmpList.Count; i++)
|
//{
|
// gubaoShowList.Add(int.Parse(tmpList[i]));
|
//}
|
var config = FuncConfigConfig.Get("gubao");
|
var json = JsonMapper.ToObject(config.Numerical1);
|
var keys = json.Keys.ToList();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
gubaoEffectDict[int.Parse(keys[i])] = int.Parse(json[keys[i]].ToString());
|
}
|
|
json = JsonMapper.ToObject(config.Numerical2);
|
keys = json.Keys.ToList();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
gubaoDiIconDict[int.Parse(keys[i])] = json[keys[i]].ToString();
|
}
|
|
scoreFormula = config.Numerical3;
|
|
config = FuncConfigConfig.Get("TreasureLuckyDraw");
|
xbIDArr = JsonMapper.ToObject<int[]>(config.Numerical1);
|
json = JsonMapper.ToObject(config.Numerical2);
|
keys = json.Keys.ToList();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
luckyDrawFuncIDDict[int.Parse(keys[i])] = int.Parse(json[keys[i]].ToString());
|
}
|
|
for (int i = 0; i < xbIDArr.Length; i++)
|
{
|
int xbID = xbIDArr[i];
|
int type = XBGetItemConfig.Get(xbID).TreasureType;
|
Dictionary<int, int[]> result = new Dictionary<int, int[]>();
|
string str = TreasureSetConfig.Get(type).ProbabilityDisplay;
|
var jsonData = JsonMapper.ToObject(str);
|
var keyList = jsonData.Keys.ToList();
|
for (int j = 0; j < keyList.Count; j++)
|
{
|
string key = keyList[j];
|
int[] value = JsonMapper.ToObject<int[]>(jsonData[key].ToJson());
|
result[int.Parse(key)] = value;
|
}
|
probabilityDisplayDict[type] = result;
|
}
|
|
|
}
|
|
|
void OnBeforePlayerDataInitialize()
|
{
|
gubaoDict.Clear();
|
waitActiveGubao = 0;
|
gubaoAwardDict.Clear();
|
gubaoItemCountDict.Clear();
|
getA3CBCount = 0;
|
}
|
|
|
void RefreshItemCount(PackType packType, int index, int itemID)
|
{
|
if (packType == PackType.Item)
|
{
|
if (CanRefreshRepoint(itemID))
|
{
|
UpdateRedpoint();
|
}
|
}
|
}
|
|
public void UpdateLuckyDrawRedpoint()
|
{
|
var keyList = luckyDrawFuncIDDict.Keys.ToList();
|
for (int i = 0; i < treasureLuckyDrawTabRedpointList.Count; i++)
|
{
|
treasureLuckyDrawTabRedpointList[i].state = RedPointState.None;
|
}
|
treasureLuckDrawFreeRedpoint.state = RedPointState.None;
|
for (int i = 0; i < 4; i++)
|
{
|
if (i < xbIDArr.Length)
|
{
|
if (!luckyDrawFuncIDDict.ContainsKey(xbIDArr[i]))
|
return;
|
if (!FuncOpen.Instance.IsFuncOpen(luckyDrawFuncIDDict[xbIDArr[i]]))
|
return;
|
int type = XBGetItemConfig.Get(xbIDArr[i]).TreasureType;
|
var funcSet = ModelCenter.Instance.GetModel<HappyXBModel>().GetXBFuncSet(type);
|
bool isHaveFree = ModelCenter.Instance.GetModel<HappyXBModel>().IsHaveFreeXB(type);
|
if (isHaveFree)
|
{
|
treasureLuckyDrawTabRedpointList[i].state = RedPointState.Simple;
|
if (xbIndex == i)
|
{
|
treasureLuckDrawFreeRedpoint.state = RedPointState.Simple;
|
}
|
}
|
}
|
}
|
}
|
|
// 428 -4281(类型) - 4280000 - 42800001
|
// 主界面红点-古宝(ID)红点- 0激活1升星2升级红点
|
// 物品数量
|
public void UpdateRedpoint()
|
{
|
treasurePavilionUpgradeChooseModel.UpdateGubaoPieceInfo();
|
var keys = activeRedPointDict.Keys.ToList();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
var gubaoID = keys[i];
|
activeRedPointDict[gubaoID].state = RedPointState.None;
|
starRedPointDict[gubaoID].state = RedPointState.None;
|
lvRedPointDict[gubaoID].state = RedPointState.None;
|
|
var config = ILGubaoConfig.Get(gubaoID);
|
|
if (!gubaoDict.ContainsKey(gubaoID))
|
{
|
var hasCnt = GetGubaoItemCount(gubaoID);// packModel.GetItemCountByID(PackType.Item, config.UnlockItemID);
|
if (hasCnt >= config.UnlockItemCnt)
|
{
|
activeRedPointDict[gubaoID].state = RedPointState.Simple;
|
}
|
|
}
|
else
|
{
|
var gubaoInfo = TryGetGubaoInfo(gubaoID);
|
//升级红点
|
var needItems = ILGubaoLVConfig.GetGubaoQualityLVItems(config.GubaoType, config.GubaoQuality, gubaoInfo[1]);
|
bool enough = true;
|
for (int j = 0; j < needItems.Count; j++)
|
{
|
var hasCnt = packModel.GetItemCountByID(PackType.Item, needItems[j].x);
|
if (hasCnt < needItems[j].y)
|
{
|
enough = false;
|
break;
|
}
|
}
|
if (enough && needItems.Count > 0)
|
lvRedPointDict[gubaoID].state = RedPointState.Simple;
|
|
//升星红点
|
var maxStar = ILGubaoStarConfig.GetMaxStar(gubaoID);
|
if (maxStar == 1)
|
{
|
continue;
|
}
|
var qualityItems = ILGubaoStarConfig.GetGubaQualityPieceInfoList(gubaoID, gubaoInfo[0]);
|
needItems = ILGubaoStarConfig.GetGubaoStarItems(gubaoID, gubaoInfo[0]);
|
enough = true;
|
for (int j = 0; j < needItems.Count; j++)
|
{
|
var itemConfig = ItemConfig.Get(needItems[j].x);
|
int hasCnt;
|
if (itemConfig.Effect1 == 270)
|
hasCnt = GetGubaoItemCount(itemConfig.EffectValueA1);
|
else
|
hasCnt = packModel.GetItemCountByID(PackType.Item, needItems[j].x);
|
if (hasCnt < needItems[j].y)
|
{
|
enough = false;
|
break;
|
}
|
}
|
|
// 检查古宝碎片
|
if (enough)
|
{
|
for (int j = 0; j < qualityItems.Count; j++)
|
{
|
int quality = qualityItems[j].x;
|
int cnt = qualityItems[j].y;
|
int hasCnt = treasurePavilionUpgradeChooseModel.GetHaveGuBaoPieceCountByQuality(quality);
|
if (hasCnt < cnt)
|
{
|
enough = false;
|
break;
|
}
|
}
|
}
|
|
if (enough && (needItems.Count > 0 || qualityItems.Count > 0))
|
starRedPointDict[gubaoID].state = RedPointState.Simple;
|
|
}
|
}
|
}
|
|
void UpdateRedpointAward()
|
{
|
var keys = awardRedPointDict.Keys.ToList();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
var gubaoID = keys[i];
|
awardRedPointDict[gubaoID].state = RedPointState.None;
|
|
//领取红点
|
if (gubaoAwardDict.ContainsKey(gubaoID) && gubaoAwardDict[gubaoID] > 0)
|
{
|
var starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, gubaoDict[gubaoID][0]));
|
if (gubaoAwardDict[gubaoID] / ILGubaoEffAttrConfig.Get(starConfig.StarEffIDList[0]).EffCond > 0)
|
{
|
awardRedPointDict[gubaoID].state = RedPointState.Simple;
|
}
|
}
|
}
|
}
|
|
|
|
bool CanRefreshRepoint(int itemID)
|
{
|
//if (unLockItems.Contains(itemID))
|
// return true;
|
|
if (ILGubaoLVConfig.needItemIDs.Contains(itemID))
|
return true;
|
|
if (ILGubaoStarConfig.needItemIDs.Contains(itemID))
|
return true;
|
return false;
|
}
|
|
public void UpdateGubaoNetPack(IL_HA3C7_tagMCGubaoInfo netPack)
|
{
|
for (int i = 0; i < netPack.Count; i++)
|
{
|
gubaoDict[netPack.GubaoInfoList[i].GubaoID] = new List<int>() {
|
netPack.GubaoInfoList[i].GubaoStar,
|
netPack.GubaoInfoList[i].GubaoLV
|
};
|
}
|
|
UpdateGubaoEvent?.Invoke();
|
if (waitActiveGubao != 0 && gubaoDict.ContainsKey(waitActiveGubao))
|
{
|
WindowCenter.Instance.OpenIL<TreasurePavilionActiveWin>();
|
}
|
UpdateRedpoint();
|
}
|
|
public void SortGubaoList()
|
{
|
gubaoShowList = ILGubaoConfig.gubaoTypeDict[gubaoTypeList[selectIndex]];
|
gubaoShowList.Sort(CmpGubao);
|
}
|
|
public List<int> GetGubaoList()
|
{
|
return gubaoShowList;
|
}
|
|
|
|
public List<int> TryGetGubaoInfo(int gubaoID)
|
{
|
if (!gubaoDict.ContainsKey(gubaoID))
|
return new List<int>();
|
|
return gubaoDict[gubaoID];
|
}
|
|
|
//排序显示 可激活-已激活-品质
|
int CmpGubao(int gubaoA, int gubaoB)
|
{
|
var isActiveA = gubaoDict.ContainsKey(gubaoA);
|
var isActiveB = gubaoDict.ContainsKey(gubaoB);
|
|
var configA = ILGubaoConfig.Get(gubaoA);
|
var configB = ILGubaoConfig.Get(gubaoB);
|
var canActiveA = false;
|
var canActiveB = false;
|
if (!isActiveA)
|
{
|
canActiveA = GetGubaoItemCount(gubaoA) >= configA.UnlockItemCnt;
|
if (canActiveA) isActiveA = true;
|
}
|
|
if (!isActiveB)
|
{
|
canActiveB = GetGubaoItemCount(gubaoB) >= configB.UnlockItemCnt;
|
if (canActiveB) isActiveB = true;
|
}
|
|
if (canActiveA != canActiveB)
|
{
|
return canActiveB.CompareTo(canActiveA);
|
}
|
|
if (isActiveA != isActiveB)
|
{
|
return isActiveB.CompareTo(isActiveA);
|
}
|
|
int gubaoQualityA = configA.GubaoQuality;
|
int gubaoQualityB = configB.GubaoQuality;
|
if (gubaoQualityA != gubaoQualityB)
|
{
|
return gubaoQualityB.CompareTo(gubaoQualityA);
|
}
|
|
return gubaoA.CompareTo(gubaoB);
|
}
|
|
public int GetGubaoScore(int gubaoID)
|
{
|
Equation.Instance.Clear();
|
//baseScore+lvFightPower*0.2+starScore
|
var config = ILGubaoConfig.Get(gubaoID);
|
Equation.Instance.AddKeyValue("baseScore", config.BaseScore);
|
|
var gubaoInfo = TryGetGubaoInfo(gubaoID);
|
var lvFightPower = 0;
|
|
ILGubaoStarConfig starConfig = null;
|
if (gubaoDict.ContainsKey(gubaoID))
|
{
|
starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, gubaoDict[gubaoID][0]));
|
}
|
|
if (gubaoInfo.Count > 0)
|
{
|
var lvConfig = ILGubaoLVConfig.Get(ILGubaoLVConfig.GetGubaoQualityLVIndex(config.GubaoType, config.GubaoQuality, gubaoInfo[1]));
|
Dictionary<int, int> attrDict = new Dictionary<int, int>();
|
for (int i = 0; i < lvConfig.LVAttrTypeList.Length; i++)
|
{
|
attrDict[lvConfig.LVAttrTypeList[i]] = lvConfig.LVAttrValueList[i];
|
}
|
|
if (starConfig.StarAttrIDList.Length != 0)
|
{
|
for (int i = 0; i < starConfig.StarAttrIDList.Length; i++)
|
{
|
if (!attrDict.ContainsKey(starConfig.StarAttrIDList[i]))
|
{
|
attrDict[starConfig.StarAttrIDList[i]] = 0;
|
}
|
attrDict[starConfig.StarAttrIDList[i]] += starConfig.StarAttrValueList[i];
|
}
|
}
|
|
lvFightPower = UIHelper.GetFightPower(attrDict);
|
}
|
Equation.Instance.AddKeyValue("lvFightPower", lvFightPower);
|
var starScore = 0;
|
if (starConfig != null)
|
{
|
for (int i = 0; i < starConfig.StarEffIDList.Length; i++)
|
{
|
if (!ILGubaoEffAttrConfig.Has(starConfig.StarEffIDList[i]))
|
{
|
starScore += 0;
|
}
|
else
|
{
|
starScore += ILGubaoEffAttrConfig.Get(starConfig.StarEffIDList[i]).StarScore;
|
}
|
}
|
}
|
Equation.Instance.AddKeyValue("starScore", starScore);
|
return Equation.Instance.Eval<int>(scoreFormula);
|
}
|
|
public void ActiveGubao(int gubaoID)
|
{
|
var pak = new IL_CB216_tagCMGubaoActivate();
|
pak.GubaoID = (ushort)gubaoID;
|
GameNetSystem.Instance.SendInfo(pak);
|
waitActiveGubao = gubaoID;
|
}
|
|
public void UpgradeGubaoStar(int gubaoID, IL_CB217_tagCMGubaoStarUp.tagCMGubaoPieceUse[] info = null)
|
{
|
var pak = new IL_CB217_tagCMGubaoStarUp();
|
pak.GubaoID = (ushort)gubaoID;
|
pak.CommPieceUseList = info;
|
pak.PieceSelectCount = info == null ? (byte)0 : (byte)info.Length;
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
|
public void UpgradeGubaoLV(int gubaoID)
|
{
|
var pak = new IL_CB218_tagCMGubaoLVUp();
|
pak.GubaoID = (ushort)gubaoID;
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
|
public event Action UpdateGubaoAwardEvent;
|
public void UpdateGubaoAward(IL_HA3CA_tagMCGubaoItemEffInfo netPack)
|
{
|
for (int i = 0; i < netPack.ItemEffInfoList.Length; i++)
|
{
|
gubaoAwardDict[netPack.ItemEffInfoList[i].GubaoID] = (int)netPack.ItemEffInfoList[i].EffValue;
|
}
|
|
UpdateRedpointAward();
|
UpdateGubaoAwardEvent?.Invoke();
|
}
|
|
|
public void UpdateGubaoItemCount(IL_HA3CB_tagMCGubaoPieceInfo netPack)
|
{
|
|
ShowRewardWin(netPack);
|
for (int i = 0; i < netPack.PieceInfoList.Length; i++)
|
{
|
gubaoItemCountDict[netPack.PieceInfoList[i].GubaoID] = (int)netPack.PieceInfoList[i].PieceCount;
|
}
|
UpdateGubaoItemCountEvent?.Invoke();
|
UpdateRedpoint();
|
}
|
|
private List<Item> accumulatedItems = new List<Item>();
|
private Clock rewardClock;
|
|
public void ShowRewardWin(IL_HA3CB_tagMCGubaoPieceInfo vNetData)
|
{
|
getA3CBCount += 1;
|
if (WindowCenter.Instance.IsOpen<BoxGetItemWin>())
|
return;
|
if (getA3CBCount <= 1) // 同步古宝数据,避免触发奖励弹窗
|
return;
|
if (isShowLuckyDraw && isWinOpen) //避免和古宝抽奖奖励弹窗冲突
|
return;
|
|
|
for (int i = 0; i < vNetData.PieceInfoList.Length; i++)
|
{
|
int gubaoID = vNetData.PieceInfoList[i].GubaoID;
|
int pieceCount = (int)vNetData.PieceInfoList[i].PieceCount;
|
int hasCnt = 0;
|
if (gubaoItemCountDict.ContainsKey(gubaoID))
|
{
|
hasCnt = gubaoItemCountDict[gubaoID];
|
}
|
if (hasCnt > pieceCount)
|
return;
|
int itemId = ILGubaoConfig.Get(gubaoID).UnlockItemID;
|
ItemLogicUtility.Instance.RefreshPickItem(PackType.Item, itemId.ToString());
|
|
}
|
}
|
|
public int GetGubaoItemCount(int gubaoID)
|
{
|
if (!gubaoItemCountDict.ContainsKey(gubaoID))
|
return 0;
|
|
return gubaoItemCountDict[gubaoID];
|
}
|
|
//当前类型的古宝一个共鸣套装也没有
|
public bool IsTypeNoReverberation()
|
{
|
var dict = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict();
|
var list = GetGubaoList();
|
for (int i = 0; i < list.Count; i++)
|
{
|
int gubaoID = list[i];
|
if (dict.ContainsKey(gubaoID))
|
{
|
return false;
|
}
|
}
|
return true;
|
}
|
|
|
|
//返回当前所在标签类型的可升星的古宝列表
|
public bool TryGetUpgradeStarList(out List<int> upgradeStarList)
|
{
|
upgradeStarList = new List<int>();
|
var list = GetGubaoList();
|
for (int i = 0; i < list.Count; i++)
|
{
|
int gubaoID = list[i];
|
//古宝表里没有
|
if (!ILGubaoConfig.Has(gubaoID)) continue;
|
var config = ILGubaoConfig.Get(gubaoID);
|
//古宝未激活
|
if (!gubaoDict.ContainsKey(gubaoID)) continue;
|
var gubaoInfo = TryGetGubaoInfo(gubaoID);
|
var maxStar = ILGubaoStarConfig.GetMaxStar(gubaoID);
|
//古宝最大等级只有1级
|
if (maxStar == 1) continue;
|
var qualityItems = ILGubaoStarConfig.GetGubaQualityPieceInfoList(gubaoID, gubaoInfo[0]);
|
var needItems = ILGubaoStarConfig.GetGubaoStarItems(gubaoID, gubaoInfo[0]);
|
var enough = true;
|
for (int j = 0; j < needItems.Count; j++)
|
{
|
var itemConfig = ItemConfig.Get(needItems[j].x);
|
int hasCnt;
|
if (itemConfig.Effect1 == 270)
|
hasCnt = GetGubaoItemCount(itemConfig.EffectValueA1);
|
else
|
hasCnt = packModel.GetItemCountByID(PackType.Item, needItems[j].x);
|
if (hasCnt < needItems[j].y)
|
{
|
enough = false;
|
break;
|
}
|
}
|
// 检查古宝碎片
|
if (enough)
|
{
|
for (int j = 0; j < qualityItems.Count; j++)
|
{
|
int quality = qualityItems[j].x;
|
int cnt = qualityItems[j].y;
|
int hasCnt = treasurePavilionUpgradeChooseModel.GetHaveGuBaoPieceCountByQuality(quality);
|
if (hasCnt < cnt)
|
{
|
enough = false;
|
break;
|
}
|
}
|
}
|
|
if (enough && (needItems.Count > 0 || qualityItems.Count > 0))
|
upgradeStarList.Add(gubaoID);
|
}
|
return upgradeStarList.Count > 0;
|
}
|
|
//获取当前类型的所有共鸣ID
|
public List<int> GetReverberationList()
|
{
|
List<int> tempList = new List<int>();
|
var dict = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict();
|
var list = GetGubaoList();
|
for (int i = 0; i < list.Count; i++)
|
{
|
int gubaoID = list[i];
|
if (dict.ContainsKey(gubaoID))
|
{
|
int resonanceID = dict[gubaoID];
|
if (!tempList.Contains(resonanceID))
|
{
|
tempList.Add(resonanceID);
|
}
|
}
|
}
|
tempList.Sort();
|
return tempList;
|
}
|
|
//显示内容(直接显示总的)
|
public string GetInfo(int nowID)
|
{
|
if (!GubaoResonanceAttrConfig.Has(nowID))
|
return string.Empty;
|
var config = GubaoResonanceAttrConfig.Get(nowID);
|
int resonanceStar = config.ResonanceStar;
|
int[] attrIDArr = config.ResonanceAttrIDList;
|
int[] attrValueArr = config.ResonanceAttrValueList;
|
List<string> result = new List<string>();
|
if (resonanceStar == 1)
|
{
|
result.Add(Language.Get("TreasurePavilion02"));
|
}
|
else
|
{
|
result.Add(Language.Get("TreasurePavilion03", resonanceStar));
|
}
|
|
for (int i = 0; i < attrIDArr.Length; i++)
|
{
|
result.Add(GetShowAttribute(attrIDArr[i], attrValueArr[i]));
|
}
|
|
string str = StringUtility.Contact(result.ToArray());
|
result.Clear();
|
result = null;
|
return str;
|
}
|
|
//获得当前共鸣星级上一共鸣星级的共鸣属性ID 没有返回0
|
public int GetLastResonanceStarID(int resonanceID, int resonanceStar)
|
{
|
var dict = GubaoResonanceAttrConfig.GetDict();
|
var starDict = dict[resonanceID];
|
var keyList = starDict.Keys.ToList();
|
int minResonanceStar = resonanceStar;
|
|
//传入星级是1 已经是最小星级的
|
if (resonanceStar == 1)
|
return 0;
|
keyList.Sort();
|
int index = keyList.IndexOf(resonanceStar);
|
if (index - 1 < 0)
|
return 0;
|
return starDict[keyList[index - 1]];
|
}
|
|
//获得当前共鸣星级上一共鸣星级的属性值 没有返回0
|
public long GetLastAttributeValue(int lastID, int nowAttrID)
|
{
|
if (lastID == 0)
|
return 0;
|
var config = GubaoResonanceAttrConfig.Get(lastID);
|
int[] lastAttrIDArr = config.ResonanceAttrIDList;
|
int[] lastAttrValueArr = config.ResonanceAttrValueList;
|
if (!IsLastHaveAttributeID(lastID, nowAttrID))
|
return 0;
|
int index = GetLastHaveAttributeIDIndex(lastID, nowAttrID);
|
return lastAttrValueArr[index];
|
}
|
|
//上一档是否存在这个属性
|
public bool IsLastHaveAttributeID(int lastID, int AttrID)
|
{
|
if (lastID == 0)
|
return false;
|
var config = GubaoResonanceAttrConfig.Get(lastID);
|
int[] lastAttrIDArr = config.ResonanceAttrIDList;
|
for (int i = 0; i < lastAttrIDArr.Length; i++)
|
{
|
if (lastAttrIDArr[i] == AttrID)
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public int GetLastHaveAttributeIDIndex(int lastID, int AttrID)
|
{
|
var config = GubaoResonanceAttrConfig.Get(lastID);
|
int[] lastAttrIDArr = config.ResonanceAttrIDList;
|
for (int i = 0; i < lastAttrIDArr.Length; i++)
|
{
|
if (lastAttrIDArr[i] == AttrID)
|
{
|
return i;
|
}
|
}
|
return 0;
|
}
|
|
//传入属性id 自动根据属性类型决定后面加不加%
|
public string GetShowAttribute(int id, long value)
|
{
|
if (id == 0 || !PlayerPropertyConfig.GetKeys().Contains(id.ToString()))
|
return "";
|
return StringUtility.Contact(" ", PlayerPropertyConfig.Get(id).Name, " +", PlayerPropertyConfig.GetValueDescription(id, value) + " ");
|
}
|
|
//获得这组古宝的最小星数
|
public int GetNowStar(int id)
|
{
|
int resonanceID = GubaoResonanceAttrConfig.Get(id).ResonanceID;
|
var gubaoIDList = GubaoResonanceConfig.Get(resonanceID).GubaoIDList;
|
List<int> starCountList = new List<int>();
|
for (int i = 0; i < gubaoIDList.Length; i++)
|
{
|
int gubaoID = gubaoIDList[i];
|
var list = TryGetGubaoInfo(gubaoID);
|
if (list.Count == 0)
|
return 0;
|
starCountList.Add(list[0]);
|
}
|
starCountList.Sort();
|
return starCountList[0];
|
}
|
|
//获取共鸣中有几件古宝激活了
|
public int GetResonanceGuBaoActiveCount(int resonanceID)
|
{
|
int count = 0;
|
var gubaoIDList = GubaoResonanceConfig.Get(resonanceID).GubaoIDList;
|
for (int i = 0; i < gubaoIDList.Length; i++)
|
{
|
int gubaoID = gubaoIDList[i];
|
var list = TryGetGubaoInfo(gubaoID);
|
var hasCnt = GetGubaoItemCount(gubaoID);
|
var config = ILGubaoConfig.Get(gubaoID);
|
//满足激活条件的古宝 视为已激活
|
if (list.Count == 0)
|
{
|
if (hasCnt >= config.UnlockItemCnt)
|
{
|
count += 1;
|
}
|
else
|
{
|
continue;
|
}
|
}
|
else
|
{
|
count += 1;
|
}
|
}
|
return count;
|
}
|
|
|
//获得这组古宝的最小星数
|
public int GetNowStarByResonanceID(int resonanceID)
|
{
|
var gubaoIDList = GubaoResonanceConfig.Get(resonanceID).GubaoIDList;
|
List<int> starCountList = new List<int>();
|
for (int i = 0; i < gubaoIDList.Length; i++)
|
{
|
int gubaoID = gubaoIDList[i];
|
var list = TryGetGubaoInfo(gubaoID);
|
if (list.Count == 0)
|
return 0;
|
starCountList.Add(list[0]);
|
}
|
starCountList.Sort();
|
return starCountList[0];
|
}
|
|
//获取共鸣中有几条属性激活了
|
public int GetResonanceGuBaoAttrActiveCount(int resonanceID)
|
{
|
int minStar = GetNowStarByResonanceID(resonanceID);
|
int count = 0;
|
var starList = GubaoResonanceAttrConfig.GetResonanceStarDict()[resonanceID];
|
for (int j = 0; j < starList.Count; j++)
|
{
|
int star = starList[j];
|
if (star <= minStar)
|
{
|
count += 1;
|
}
|
}
|
return count;
|
}
|
|
//对套装进行排序
|
//套装激活属性数量未满 > 没有任何激活的古宝套装 > 套装所有属性激活
|
public int CmpResonance(int resonanceA, int resonanceB)
|
{
|
// 套装中古宝数量
|
int gubaoCountA = GubaoResonanceConfig.Get(resonanceA).GubaoIDList.Length;
|
int gubaoCountB = GubaoResonanceConfig.Get(resonanceB).GubaoIDList.Length;
|
// 套装中激活的古宝数量
|
int activeCountA = GetResonanceGuBaoActiveCount(resonanceA);
|
int activeCountB = GetResonanceGuBaoActiveCount(resonanceB);
|
// 套装可激活属性数量
|
int AttrCountA = GubaoResonanceAttrConfig.GetResonanceStarDict()[resonanceA].Count;
|
int AttrCountB = GubaoResonanceAttrConfig.GetResonanceStarDict()[resonanceB].Count;
|
// 套装激活属性数量
|
int activeAttrCountA = GetResonanceGuBaoAttrActiveCount(resonanceA);
|
int activeAttrCountB = GetResonanceGuBaoAttrActiveCount(resonanceB);
|
|
// 判断是否有任一古宝激活但套装未满(包括未激活任何套装效果的情况)
|
bool isPartiallyActiveA = activeCountA > 0 && activeCountA < gubaoCountA;
|
bool isPartiallyActiveB = activeCountB > 0 && activeCountB < gubaoCountB;
|
|
// 判断套装属性是否全部激活
|
bool allActiveA = activeAttrCountA == AttrCountA && activeAttrCountA > 0;
|
bool allActiveB = activeAttrCountB == AttrCountB && activeAttrCountB > 0;
|
|
// 处理套装所有属性激活的情况,将其排在最后
|
if (allActiveA != allActiveB)
|
{
|
return allActiveA ? 1 : -1; // 全部激活的套装排在后面
|
}
|
|
// 如果都是全部激活或都不是全部激活,继续比较其他条件
|
|
// 比较激活属性数量
|
if (activeAttrCountA != activeAttrCountB)
|
{
|
return activeAttrCountB.CompareTo(activeAttrCountA);
|
}
|
|
// 如果激活属性数量相同,处理有任一古宝激活但套装未满的情况
|
if (isPartiallyActiveA != isPartiallyActiveB)
|
{
|
return isPartiallyActiveA ? -1 : 1; // 部分激活的套装优先
|
}
|
|
if (isPartiallyActiveA && isPartiallyActiveB)
|
{
|
// 两个套装都是部分激活,比较激活的古宝数量
|
return activeCountB.CompareTo(activeCountA);
|
}
|
|
// 处理没有任何激活的古宝套装的情况
|
if (activeCountA == 0 && activeCountB == 0)
|
{
|
// 两个套装都没有激活的古宝,比较总古宝数量
|
return gubaoCountB.CompareTo(gubaoCountA);
|
}
|
|
// 如果都是全部激活的情况,比较总古宝数量
|
if (allActiveA && allActiveB)
|
{
|
return gubaoCountB.CompareTo(gubaoCountA);
|
}
|
|
// 如果代码执行到这里,说明存在未考虑到的情况,返回0表示相等
|
return 0;
|
|
}
|
|
public int GetJumpIndex()
|
{
|
if (selectResonanceID == 0)
|
{
|
return 0;
|
}
|
else
|
{
|
List<int> reverberationList = GetReverberationList();
|
reverberationList.Sort(CmpResonance);
|
int index = reverberationList.IndexOf(selectResonanceID);
|
if (index < 0)
|
{
|
return 0;
|
}
|
return index;
|
}
|
}
|
|
//获取品质对应的可展示的物品ID
|
public List<int> GetItemIDByQuality(int quality, int treasureType)
|
{
|
List<int> result = new List<int>();
|
var probabilityDict = probabilityDisplayDict[treasureType];
|
int[] libs = probabilityDict[quality];
|
for (int i = 0; i < libs.Length; i++)
|
{
|
int libID = libs[i];
|
var list = TreasureItemLibConfig.GetItemIDList(libID);
|
for (int j = 0; j < list.Count; j++)
|
{
|
if (!result.Contains(list[j]))
|
{
|
result.Add(list[j]);
|
}
|
}
|
}
|
return result;
|
}
|
|
public Dictionary<int, int> GetRateDict(int treasureID)
|
{
|
Dictionary<int, int> result = new Dictionary<int, int>();
|
Dictionary<int, int> gridLibInfo = new Dictionary<int, int>();
|
var jsonData = JsonMapper.ToObject(XBGetItemConfig.Get(treasureID).GridLibInfo);
|
var keyList = jsonData.Keys.ToList();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
gridLibInfo[int.Parse(keyList[i])] = int.Parse(jsonData[keyList[i]].ToString());
|
}
|
|
int[][] GridItemRateList = XBGetItemConfig.Get(treasureID).GridItemRateList1;
|
Dictionary<int, int> rateDict = ConfigParse.GetRateDict(GridItemRateList);
|
|
var InfoKey = gridLibInfo.Keys.ToList();
|
for (int i = 0; i < InfoKey.Count; i++)
|
{
|
int grid = InfoKey[i];
|
int lib = gridLibInfo[grid];
|
result[lib] = rateDict[grid];
|
}
|
|
return result;
|
}
|
|
public List<string> GetGubaoEffects(int gubaoID, bool includeShentong = true, int star = 0)
|
{
|
List<string> starInfo = new List<string>();
|
if (includeShentong)
|
{
|
int shentongID = ShentongModel.Instance.GetShentongIDByGubaoID(gubaoID);
|
if (shentongID != 0)
|
{
|
//激活神通Shentong8
|
starInfo.Add(Language.Get("Shentong8", ILShentongConfig.Get(shentongID).Name));
|
}
|
}
|
|
int showStar;
|
if (star != 0)
|
{
|
showStar = star;
|
}
|
else
|
{
|
var gubaoInfo = TryGetGubaoInfo(gubaoID);
|
showStar = gubaoInfo.Count == 0 ? 1 : gubaoInfo[0];
|
}
|
|
var starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, showStar));
|
if (starConfig.StarEffIDList[0] != 0)
|
{
|
starInfo.Add(ILGubaoEffAttrConfig.Get(starConfig.StarEffIDList[0]).Name);
|
}
|
for (int i = 0; i < starConfig.StarAttrIDList.Length; i++)
|
{
|
starInfo.Add(PlayerPropertyConfig.GetFullDescription(starConfig.StarAttrIDList[i], starConfig.StarAttrValueList[i]));
|
}
|
|
return starInfo;
|
}
|
}
|