using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
|
public class ChallengeDemonKingModel : Model
|
{
|
public const int PERSONALBOSS_MAPID = 31240; //数据地图ID
|
public const int PERSONAL_REDPOINTID = 76003;
|
int m_showNpcID; //当前展示的BossID
|
public int showNpcID
|
{
|
get
|
{
|
return m_showNpcID;
|
}
|
set
|
{
|
if (value == m_showNpcID)
|
return;
|
m_showNpcID = value;
|
UpdateShow?.Invoke();
|
DebugEx.Log($"挑战妖王当前展示的NPCID {value}");
|
}
|
}
|
public Dictionary<int, int> realmNpcIDDict;
|
public Dictionary<int, int> lineIdDict;
|
public List<string> npcIDList;
|
public event Action UpdateShow;
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
public override void Init()
|
{
|
realmNpcIDDict = PersonalBossConfig.GetNPCIDDictForRealm();
|
lineIdDict = PersonalBossConfig.GetNPCIDDictForLineId();
|
npcIDList = PersonalBossConfig.GetKeys();
|
showNpcID = int.Parse(npcIDList[JumpIndex()]);
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
//获取Cell的状态
|
//0 已通关-不可扫荡 1 已通关-可扫荡-免费 2 未通关-可挑战(待首通) 3 未通关-不可挑战(境界够前一关没打) 4 未通关-不可解锁(境界不够) 5 已通关-可扫荡-可付费 6 已通关-不可扫荡
|
public int GetCellState(int npcid)
|
{
|
int lineId = PersonalBossConfig.Get(npcid).lineId;
|
int realmLv = NPCConfig.Get(npcid).Realm;
|
//已通关
|
if (IsFBPass(lineId))
|
{
|
if (IsSweep(npcid))
|
{
|
if (IsFreeTime(npcid))
|
{
|
return 1;
|
}
|
else
|
{
|
//次数不够
|
if (dungeonModel.GetTotalTimes(ChallengeDemonKingModel.PERSONALBOSS_MAPID) - dungeonModel.GetEnterTimes(ChallengeDemonKingModel.PERSONALBOSS_MAPID) < 1)
|
{
|
return 6;
|
}
|
else
|
{
|
return 5;
|
}
|
}
|
}
|
else
|
{
|
return 0;
|
}
|
}
|
//未通关
|
else
|
{
|
if (PlayerDatas.Instance.baseData.realmLevel >= realmLv)
|
{
|
int lastNPCID = GetLastNPCID(npcid);
|
if (lastNPCID == 0)
|
{
|
return 2;
|
}
|
else
|
{
|
int lastLineId = PersonalBossConfig.Get(lastNPCID).lineId;
|
return IsFBPass(lastLineId) ? 2 : 3;
|
}
|
}
|
else
|
{
|
return 4;
|
}
|
}
|
}
|
|
//是否通关过这个副本
|
bool IsFBPass(int lineId)
|
{
|
DungeonRecord dungeonRecord;
|
if (dungeonModel.TryGetRecord(PERSONALBOSS_MAPID, out dungeonRecord))
|
{
|
if (dungeonRecord.lineGrades.ContainsKey(lineId) && dungeonRecord.lineGrades[lineId] != 0)
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
//是否可以扫荡
|
bool IsSweep(int npcid)
|
{
|
//不存在下一个已通关的关卡就可以扫荡
|
int nextNpcId = GetNextNPCID(npcid);
|
if (nextNpcId == 0)
|
return true;
|
int nextLineId = PersonalBossConfig.Get(nextNpcId).lineId;
|
return !IsFBPass(nextLineId);
|
}
|
|
//获得上一关的lineid 返回0说明没有上一关
|
int GetLastNPCID(int npcid)
|
{
|
int index = npcIDList.IndexOf(npcid.ToString());
|
int lastIndex = index - 1;
|
return lastIndex >= 0 ? int.Parse(npcIDList[lastIndex]) : 0;
|
}
|
|
//获得下一关的lineid 返回0说明没有下一关
|
int GetNextNPCID(int npcid)
|
{
|
int index = npcIDList.IndexOf(npcid.ToString());
|
int nextIndex = index + 1;
|
return nextIndex <= npcIDList.Count - 1 ? int.Parse(npcIDList[nextIndex]) : 0;
|
}
|
|
//跳转到可扫荡boss的索引
|
public int JumpIndex()
|
{
|
int jumpindex = 0;
|
for (int i = 0; i < npcIDList.Count; i++)
|
{
|
int npcId = int.Parse(npcIDList[i]);
|
int state = GetCellState(npcId);
|
if (state == 1 || state == 5 || state == 6)
|
{
|
jumpindex = i;
|
}
|
}
|
return jumpindex;
|
}
|
|
//这次扫荡是否免费的
|
public bool IsFreeTime(int npcid)
|
{
|
var config = PersonalBossConfig.Get(npcid);
|
DungeonRecord dungeonRecord;
|
if (dungeonModel.TryGetRecord(PERSONALBOSS_MAPID, out dungeonRecord))
|
{
|
if (dungeonRecord.lineGrades.ContainsKey(config.lineId) && dungeonRecord.enterTimes > 0)
|
{
|
return false;
|
}
|
}
|
return true;
|
|
}
|
}
|
|