using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
using LitJson;
|
using UnityEngine;
|
namespace vnxbqy.UI
|
{
|
public class RealmModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize
|
{
|
Dictionary<int, Dictionary<int, int[]>> m_RealmPreviewEquips = new Dictionary<int, Dictionary<int, int[]>>(); //境界预览装备用于解锁
|
Dictionary<int, Dictionary<int, int[]>> m_RecommandEquips = new Dictionary<int, Dictionary<int, int[]>>(); //推荐装备用于任务完成
|
List<List<int>> m_RealmStages = new List<List<int>>();
|
public int realmMaxLevel { get; private set; }
|
public bool isBossPass { get; private set; }
|
public int realmExpTime { get; private set; }
|
public long startExp { get; private set; }
|
|
public uint buffAddRate { get; private set; }
|
public uint buffSeconds { get; private set; }
|
|
public int realmUpgrateNoEnoughReason = 0; //境界提升不足提示 1。换装备,2 升星
|
|
|
public DateTime expStartTime { get; private set; }
|
|
UIEffect realmEffect;
|
int realmEffectCount = 0;
|
|
public event Action OnTowerPassEvent;
|
public int passedFloor;
|
//可挑战层
|
public int currentFloor {
|
get {
|
return passedFloor + 1;
|
}
|
}
|
|
public int selectFloorID; //新的大境界未解锁,或者最后一层时,显示可选的最高层
|
|
//特殊奖励楼层
|
Dictionary<int, int> rewardShowFloors = new Dictionary<int, int>();
|
|
public const int REALM_DUNGEON_ID = 31110;
|
public const int Tower_MapId = 31310;
|
|
public readonly Redpoint levelUpRedpoint = new Redpoint(114, 11401);
|
public readonly Redpoint challengeRedpoint = new Redpoint(114, 11402);
|
public readonly Redpoint missionRedpoint = new Redpoint(114, 11403);
|
public readonly Redpoint towerRedpoint = new Redpoint(114, 11406);
|
|
int m_SelectRealm = 0;
|
public int selectRealm
|
{
|
get { return m_SelectRealm; }
|
set
|
{
|
if (m_SelectRealm != value)
|
{
|
m_SelectRealm = value;
|
if (selectRealmRefresh != null)
|
{
|
selectRealmRefresh();
|
}
|
}
|
}
|
}
|
|
int cacheMapId = 0;
|
|
bool redpointDirty = false;
|
|
bool serverInited = false;
|
|
public List<int> displayRealms = new List<int>();
|
|
public int displayRealmLevel
|
{
|
get
|
{
|
if (displayRealms.Count > 0)
|
{
|
return displayRealms[0];
|
}
|
return PlayerDatas.Instance.baseData.realmLevel;
|
}
|
}
|
|
public event Action selectRealmRefresh;
|
public event Action realmExpRefresh;
|
|
public event Action<int> OnFlashOverEvent;
|
public void OnFlashOver(int state)
|
{
|
if (OnFlashOverEvent != null)
|
OnFlashOverEvent(state);
|
}
|
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
SkyTowerModel skyTowerModel { get { return ModelCenter.Instance.GetModel<SkyTowerModel>(); } }
|
DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
WorldBossModel worldBossModel { get { return ModelCenter.Instance.GetModel<WorldBossModel>(); } }
|
TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
|
BossHomeModel bossHomeModel { get { return ModelCenter.Instance.GetModel<BossHomeModel>(); } }
|
|
public override void Init()
|
{
|
StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
|
PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
|
GlobalTimeEvent.Instance.secondEvent += PerSecond;
|
packModel.refreshItemCountEvent += RefreshItemCountEvent;
|
FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
skyTowerModel.OnChallengeState += OnChallengeState;
|
ParseConfig();
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
isBossPass = false;
|
expStartTime = DateTime.Now;
|
startExp = 0;
|
serverInited = false;
|
buffSeconds = 0;
|
buffAddRate = 0;
|
realmEffectCount = 0;
|
taskAwardState = 0;
|
taskValues.Clear();
|
SysNotifyMgr.Instance.OnSystemNotifyEvent -= OnSystemNotifyEvent;
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
redpointDirty = true;
|
serverInited = true;
|
|
SysNotifyMgr.Instance.OnSystemNotifyEvent -= OnSystemNotifyEvent;
|
SysNotifyMgr.Instance.OnSystemNotifyEvent += OnSystemNotifyEvent;
|
|
}
|
|
public override void UnInit()
|
{
|
StageLoad.Instance.onStageLoadFinish -= OnStageLoadFinish;
|
PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
packModel.refreshItemCountEvent -= RefreshItemCountEvent;
|
GlobalTimeEvent.Instance.secondEvent -= PerSecond;
|
FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
skyTowerModel.OnChallengeState -= OnChallengeState;
|
}
|
|
private void OnFuncStateChangeEvent(int id)
|
{
|
if (id == (int)FuncOpenEnum.Realm)
|
{
|
redpointDirty = true;
|
}
|
}
|
|
void OnChallengeState()
|
{
|
redpointDirty = true;
|
}
|
|
private void PerSecond()
|
{
|
if (redpointDirty)
|
{
|
RefreshRedpoint();
|
redpointDirty = false;
|
}
|
//if (serverInited)
|
//{
|
// RefreshRealmPoolRedpoint();
|
//}
|
|
TryPlayRealmEffect();
|
}
|
|
void ParseConfig()
|
{
|
List<int> stages = new List<int>();
|
realmMaxLevel = RealmConfig.GetKeys().Count - 1;
|
for (int i = 1; i <= realmMaxLevel; i++)
|
{
|
var config = RealmConfig.Get(i);
|
if (config.Lv == config.LvLarge)
|
{
|
stages = new List<int>();
|
m_RealmStages.Add(stages);
|
}
|
stages.Add(config.Lv);
|
|
}
|
|
var configs = RealmTowerConfig.GetKeys();
|
foreach (var item in configs)
|
{
|
var key = int.Parse(item);
|
var config = RealmTowerConfig.Get(key);
|
if (config.ExShow != 0)
|
{
|
rewardShowFloors[key] = config.ExShow;
|
}
|
}
|
|
|
var funcConfig = FuncConfigConfig.Get("RealmExpTime");
|
realmExpTime = int.Parse(funcConfig.Numerical1);
|
|
funcConfig = FuncConfigConfig.Get("RealmMission");
|
realMissionGuides = ConfigParse.ParseIntArrayDict(funcConfig.Numerical1);
|
dailyQuestInfoForLvGuide = JsonMapper.ToObject<int[][]>(funcConfig.Numerical2);
|
mainTaskIDsNotGuide = JsonMapper.ToObject<int[]>(funcConfig.Numerical3);
|
defaultGuideID = int.Parse(funcConfig.Numerical4);
|
firstRealmBreakUpGuideID = int.Parse(funcConfig.Numerical5);
|
|
funcConfig = FuncConfigConfig.Get("RealmTower");
|
realmTowerOpenRealm = int.Parse(funcConfig.Numerical1);
|
realmTowerGuideID = int.Parse(funcConfig.Numerical2);
|
}
|
|
|
public bool TryGetRealmStages(int index, out List<int> stages)
|
{
|
stages = null;
|
if (index < m_RealmStages.Count)
|
{
|
stages = m_RealmStages[index];
|
return true;
|
}
|
return false;
|
}
|
|
//level 装备阶
|
public bool TryGetRealmPreviewEquips(int level, int job, out int[] equips)
|
{
|
equips = null;
|
if (m_RealmPreviewEquips.ContainsKey(level) && m_RealmPreviewEquips[level].ContainsKey(job))
|
{
|
return m_RealmPreviewEquips[level].TryGetValue(job, out equips);
|
}
|
if (!m_RealmPreviewEquips.ContainsKey(level))
|
{
|
m_RealmPreviewEquips[level] = new Dictionary<int, int[]>();
|
}
|
if (!m_RealmPreviewEquips[level].ContainsKey(job))
|
{
|
m_RealmPreviewEquips[level].Add(job, new int[3]);
|
}
|
|
for (int i = 0; i < EquipModel.equipShowPlaces.Length; i++)
|
{
|
int place = EquipModel.equipShowPlaces[i];
|
var config = ItemConfig.GetEquipConfig(level, place, 5, job);
|
if (config != null)
|
{
|
m_RealmPreviewEquips[level][job][i] = config.ID;
|
}
|
}
|
|
equips = m_RealmPreviewEquips[level][job];
|
return true;
|
}
|
|
public bool TryGetRecommandEquips(int level, int job, int itemColor, out int[] equips)
|
{
|
equips = null;
|
if (m_RecommandEquips.ContainsKey(level))
|
{
|
return m_RecommandEquips[level].TryGetValue(job, out equips);
|
}
|
|
if (!m_RecommandEquips.ContainsKey(level))
|
{
|
m_RecommandEquips[level] = new Dictionary<int, int[]>();
|
}
|
if (!m_RecommandEquips[level].ContainsKey(job))
|
{
|
m_RecommandEquips[level].Add(job, new int[8]);
|
}
|
|
for (int i = 0; i < EquipModel.equip8Places.Length; i++)
|
{
|
int place = EquipModel.equip8Places[i];
|
var config = ItemConfig.GetEquipConfig(level, place, itemColor, job);
|
if (config != null)
|
{
|
m_RecommandEquips[level][job][i] = config.ID;
|
}
|
}
|
|
equips = m_RecommandEquips[level][job];
|
|
return true;
|
}
|
|
//三个任务同时处于完成或者待领取状态,至少有一个可领取
|
public bool CheckAllMissionCanFinish()
|
{
|
bool hasAward = false;
|
var missions = RealmLVUPTaskConfig.GetMissionIDs(PlayerDatas.Instance.baseData.realmLevel);
|
for (int i = 0; i < missions.Count; i++)
|
{
|
int missionID = missions[i];
|
int state = GetMissionState(PlayerDatas.Instance.baseData.realmLevel, missionID);
|
if (state == 1)
|
{
|
hasAward = true;
|
|
}
|
else if (state == 0)
|
{
|
return false;
|
}
|
}
|
|
return hasAward;
|
}
|
|
//境界任务完成后才可以渡劫,否则点击渡劫按任务顺序做引导
|
// error: 小于100的错误码是任务类型用于引导等;101 任务奖励可领取未领取;102 等级不足;103 经验不足
|
public bool TryLevelUp(out int error, out bool hasBoss, out bool hasAward, out int id)
|
{
|
id = 0;
|
error = 100; //小于100的错误码是任务引导
|
var missions = RealmLVUPTaskConfig.GetMissionIDs(PlayerDatas.Instance.baseData.realmLevel);
|
hasAward = false; //是否有奖励可领取
|
hasBoss = false; //是否有BOSS任务
|
for (int i = 0; i < missions.Count; i++)
|
{
|
int missionID = missions[i];
|
int state = GetMissionState(PlayerDatas.Instance.baseData.realmLevel, missionID);
|
if (state == 0)
|
{
|
var tmpID = RealmLVUPTaskConfig.GetID(PlayerDatas.Instance.baseData.realmLevel, missionID);
|
var type = RealmLVUPTaskConfig.Get(tmpID).TaskType;
|
if (error == 100)
|
{
|
error = type;
|
id = tmpID;
|
}
|
if (type == 6)
|
{
|
hasBoss = true;
|
}
|
|
}
|
else if (state == 1)
|
{
|
hasAward = true;
|
}
|
}
|
if (error < 100)
|
{
|
return false;
|
}
|
|
if (hasAward)
|
{
|
error = 101;
|
return false;
|
}
|
|
|
var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
|
if (realmLevel >= realmMaxLevel)
|
{
|
return false;
|
}
|
var config = RealmConfig.Get(realmLevel);
|
|
if (PlayerDatas.Instance.baseData.LV < config.LVMax)
|
{
|
error = 102;
|
return false;
|
}
|
|
if (PlayerDatas.Instance.baseData.LV == config.LVMax)
|
{
|
//需要满经验
|
ulong totalExp = (ulong)PlayerDatas.Instance.baseData.TotalExp + (ulong)PlayerDatas.Instance.baseData.ExpPoint * Constants.ExpPointValue;
|
ulong maxExp = (ulong)PlayerLVConfig.GetExpByPlayerLv(PlayerDatas.Instance.baseData.LV);
|
|
if (totalExp < maxExp)
|
{
|
error = 103;
|
return false;
|
}
|
}
|
return true;
|
}
|
|
private void TryPlayRealmEffect()
|
{
|
if (realmEffect != null)
|
{
|
if (realmEffect.IsPlaying)
|
{
|
return;
|
}
|
else
|
{
|
realmEffectCount--;
|
realmEffect = null;
|
}
|
}
|
if (realmEffectCount > 0)
|
{
|
if (WindowCenter.Instance.IsOpen<MainInterfaceWin>()
|
&& !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin())
|
{
|
realmEffect = EffectMgr.Instance.PlayUIEffect(7047, 1800, WindowCenter.Instance.uiRoot.baseCanvas, false);
|
}
|
}
|
}
|
|
public bool IsUnlockEquipRealm(int realmLevel, out int level)
|
{
|
level = 0;
|
var config = RealmConfig.Get(realmLevel);
|
if (config.EquipLV > 0)
|
{
|
level = config.EquipLV;
|
return true;
|
}
|
return false;
|
}
|
|
public bool IsBuffActive(DateTime time)
|
{
|
return buffSeconds > 0
|
&& expStartTime.AddTicks(TimeSpan.TicksPerSecond * buffSeconds) > time;
|
}
|
|
public bool SatisfyEquipCondition(RealmLVUPTaskConfig config, out List<int> notSatisfyPlaces)
|
{
|
notSatisfyPlaces = null;
|
RealmLevelUpEquipCondition equipCondition
|
= new RealmLevelUpEquipCondition()
|
{
|
level = config.NeedValueList[0],
|
starLevel = config.NeedValueList[1],
|
isSuit = config.NeedValueList[2] == 1,
|
itemColor = config.NeedValueList[3],
|
};
|
notSatisfyPlaces = new List<int>();
|
for (int i = 1; i <= 8; i++)
|
{
|
var equipGuid = equipModel.GetEquip(new Int2(equipCondition.level, i));
|
var itemModel = packModel.GetItemByGuid(equipGuid);
|
if (itemModel != null)
|
{
|
if (equipCondition.isSuit)
|
{
|
if (itemModel.config.SuiteiD == 0)
|
{
|
notSatisfyPlaces.Add(i);
|
continue;
|
}
|
}
|
else
|
{
|
if (itemModel.config.ItemColor < equipCondition.itemColor)
|
{
|
notSatisfyPlaces.Add(i);
|
continue;
|
}
|
}
|
|
var starLevel = equipStarModel.GetEquipStarLevel(new Int2(equipCondition.level, i));
|
|
if (starLevel < equipCondition.starLevel)
|
{
|
notSatisfyPlaces.Add(i);
|
}
|
}
|
else
|
{
|
notSatisfyPlaces.Add(i);
|
}
|
}
|
return notSatisfyPlaces.Count == 0;
|
}
|
|
|
// 装备条件是否满足 1 缺少装备 2 星级不足
|
public bool SatisfyEquipCondition(RealmLVUPTaskConfig config, out int error)
|
{
|
error = 0;
|
RealmLevelUpEquipCondition equipCondition = new RealmLevelUpEquipCondition()
|
{
|
level = config.NeedValueList[0],
|
starLevel = config.NeedValueList[1],
|
isSuit = config.NeedValueList[2] == 1,
|
itemColor = config.NeedValueList[3],
|
};
|
|
int needCount = 8;
|
if (config.NeedValueList.Length == 5)
|
needCount = config.NeedValueList[4];
|
|
int equipOKCount = 0;
|
int starOKCount = 0;
|
for (int i = 1; i <= 8; i++)
|
{
|
var equipGuid = equipModel.GetEquip(new Int2(equipCondition.level, i));
|
var itemModel = packModel.GetItemByGuid(equipGuid);
|
if (itemModel != null)
|
{
|
bool equipOK = false;
|
if (equipCondition.isSuit)
|
{
|
if (itemModel.config.SuiteiD != 0)
|
{
|
equipOKCount++;
|
equipOK = true;
|
}
|
}
|
else
|
{
|
if (itemModel.config.ItemColor >= equipCondition.itemColor)
|
{
|
equipOKCount++;
|
equipOK = true;
|
}
|
}
|
if (equipOK)
|
{
|
var starLevel = equipStarModel.GetEquipStarLevel(new Int2(equipCondition.level, i));
|
if (starLevel >= equipCondition.starLevel)
|
{
|
starOKCount++;
|
}
|
}
|
}
|
}
|
if (equipOKCount < needCount)
|
{
|
error = 1;
|
return false;
|
}
|
|
if (starOKCount < needCount)
|
{
|
error = 2;
|
return false;
|
}
|
|
return true;
|
}
|
|
|
//大境界索引(m_RealmStages)
|
public int GetRealmStage(int realmLevel)
|
{
|
if (realmLevel == 0)
|
{
|
return 0;
|
}
|
for (int i = 0; i < m_RealmStages.Count; i++)
|
{
|
var stages = m_RealmStages[i];
|
var index = stages.IndexOf(realmLevel);
|
if (index != -1)
|
{
|
if (stages.Count == 1)
|
{
|
//最后一大境界
|
return i - 1;
|
}
|
return i;
|
}
|
}
|
|
//最后一大境界
|
return m_RealmStages.Count - 1;
|
}
|
|
public int GetRealmStageEffect(int realmLevel)
|
{
|
var config = RealmConfig.Get(realmLevel);
|
if (config != null)
|
{
|
switch (config.Quality)
|
{
|
case 1: return 7028;
|
case 2: return 7029;
|
case 3: return 7030;
|
case 4: return 7031;
|
case 5: return 7032;
|
case 6: return 7033;
|
}
|
}
|
return 7028;
|
}
|
|
public int GetRealmCoverEffect(int realmLevel)
|
{
|
var config = RealmConfig.Get(realmLevel);
|
if (config != null)
|
{
|
switch (config.Quality)
|
{
|
case 1: return 7039;
|
case 2: return 7040;
|
case 3: return 7041;
|
case 4: return 7042;
|
case 5: return 7043;
|
case 6: return 7044;
|
}
|
}
|
return 7039;
|
}
|
|
public int GetRealmLineEffect(int realmLevel)
|
{
|
var config = RealmConfig.Get(realmLevel);
|
if (config != null)
|
{
|
switch (config.Quality)
|
{
|
case 1: return 7034;
|
case 2: return 7059;
|
case 3: return 7060;
|
case 4: return 7061;
|
case 5: return 7062;
|
case 6: return 7063;
|
}
|
}
|
return 7034;
|
}
|
|
public bool GetBossEffectShow(int realmLevel)
|
{
|
var playerId = PlayerDatas.Instance.baseData.PlayerID;
|
return LocalSave.GetBool(StringUtility.Contact("RealmBossEffect_", realmLevel, "_", playerId));
|
}
|
|
public void SetBossEffectShow(int realmLevel)
|
{
|
var playerId = PlayerDatas.Instance.baseData.PlayerID;
|
LocalSave.SetBool(StringUtility.Contact("RealmBossEffect_", realmLevel, "_", playerId), true);
|
}
|
|
public bool SatisfyChallengeBoss()
|
{
|
//有BOSS任务并且 未通关
|
if (RealmLVUPTaskConfig.GetBossID(PlayerDatas.Instance.baseData.realmLevel) == 0)
|
return false;
|
|
var missionIDs = RealmLVUPTaskConfig.GetMissionIDs(PlayerDatas.Instance.baseData.realmLevel);
|
foreach (var missionID in missionIDs)
|
{
|
var id = RealmLVUPTaskConfig.GetID(PlayerDatas.Instance.baseData.realmLevel, missionID);
|
if (RealmLVUPTaskConfig.Get(id).TaskType == 6)
|
{
|
//未挑战成功
|
if (GetMissionProcess(missionID) == 0)
|
{
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
|
public void TryPushRealmPoolMessage()
|
{
|
return;
|
|
}
|
|
|
public void ReceivePackage(HA311_tagMCSyncRealmInfo package)
|
{
|
taskAwardState = (int)package.TaskAwardState;
|
for (int i = 0; i < package.TaskValueCount; i++)
|
{
|
taskValues[package.TaskValueList[i].TaskID] = (int)package.TaskValueList[i].TaskValue;
|
}
|
|
RealmMissionRefreshEvent?.Invoke();
|
redpointDirty = true;
|
}
|
|
public void ReceivePackage(HA327_tagMCRealmExpInfo package)
|
{
|
expStartTime = TimeUtility.GetTime(package.BeginTime);
|
startExp = package.CurExpPoint * (long)Constants.ExpPointValue + package.CurExp;
|
buffAddRate = package.BuffAddRate;
|
buffSeconds = package.BuffTime;
|
if (realmExpRefresh != null)
|
{
|
realmExpRefresh();
|
}
|
|
}
|
|
private void OnStageLoadFinish()
|
{
|
if (!(StageLoad.Instance.currentStage is DungeonStage))
|
{
|
cacheMapId = 0;
|
}
|
else
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
if (cacheMapId == REALM_DUNGEON_ID
|
&& mapId != REALM_DUNGEON_ID)
|
{
|
SnxxzGame.Instance.StartCoroutine(Co_TryOpenRealmWin());
|
}
|
cacheMapId = mapId;
|
}
|
}
|
|
private void OnSystemNotifyEvent(string key)
|
{
|
if (key == "BigRealmUpSuccess")
|
{
|
if (WindowCenter.Instance.IsOpen<MainInterfaceWin>()
|
&& !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin())
|
{
|
if (realmEffectCount < 2)
|
{
|
realmEffectCount++;
|
TryPlayRealmEffect();
|
}
|
}
|
}
|
}
|
|
private void PlayerDataRefreshEvent(PlayerDataType dataType)
|
{
|
if (dataType == PlayerDataType.RealmLevel
|
|| dataType == PlayerDataType.LV
|
|| dataType == PlayerDataType.TotalExp)
|
{
|
redpointDirty = true;
|
if (WindowCenter.Instance.IsOpen<MainInterfaceWin>())
|
{
|
StartRealmFistBreakUPGuide();
|
}
|
}
|
|
if (dataType == PlayerDataType.RealmLevel)
|
{
|
//显示不超过当前的大境界塔层
|
var config = RealmTowerConfig.Get(currentFloor);
|
if (config != null)
|
{
|
int largeRealm = Math.Max(1, RealmConfig.Get(RealmTowerConfig.Get(currentFloor).NeedRealmLV).LvLarge);
|
int largeRealmNow = Math.Max(1, RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel).LvLarge);
|
if (largeRealm > largeRealmNow)
|
{
|
selectFloorID = passedFloor;
|
}
|
else
|
{
|
selectFloorID = currentFloor;
|
}
|
}
|
else
|
{
|
selectFloorID = passedFloor;
|
}
|
|
taskValues.Clear();
|
}
|
|
if (dataType == PlayerDataType.FightPower)
|
{
|
redpointDirty = true;
|
}
|
}
|
|
private void RefreshItemCountEvent(PackType packType, int arg2, int itemId)
|
{
|
if (packType == PackType.Item)
|
{
|
if (BreakRealmPill == itemId)
|
{
|
redpointDirty = true;
|
}
|
}
|
if (packType == PackType.Equip)
|
{
|
redpointDirty = true;
|
}
|
}
|
|
IEnumerator Co_TryOpenRealmWin()
|
{
|
yield return WaitingForSecondConst.WaitMS1000;
|
TryOpenRealmWin();
|
}
|
|
private void TryOpenRealmWin()
|
{
|
if (NewBieCenter.Instance.inGuiding)
|
{
|
return;
|
}
|
var treasureModel = ModelCenter.Instance.GetModel<TreasureModel>();
|
if (treasureModel.newGotShowing)
|
{
|
return;
|
}
|
if (WindowCenter.Instance.ExistAnyFullScreenOrMaskWin())
|
{
|
return;
|
}
|
WindowCenter.Instance.Open<RealmTransitionWin>();
|
}
|
|
|
void RefreshRedpoint()
|
{
|
levelUpRedpoint.state = RedPointState.None;
|
towerRedpoint.state = RedPointState.None;
|
challengeRedpoint.state = RedPointState.None;
|
missionRedpoint.state = RedPointState.None;
|
|
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Realm))
|
return;
|
|
var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
|
if (realmLevel < realmMaxLevel)
|
{
|
int error;
|
bool hasBoss;
|
bool hasAward;
|
int id;
|
if (TryLevelUp(out error, out hasBoss, out hasAward, out id))
|
{
|
levelUpRedpoint.state = RedPointState.Simple;
|
}
|
if (hasAward)
|
{
|
missionRedpoint.state = RedPointState.Simple;
|
}
|
if (hasBoss)
|
{
|
if (NPCExConfig.Get(RealmLVUPTaskConfig.GetBossID(realmLevel)).SuppressFightPower <= (long)PlayerDatas.Instance.baseData.FightPoint)
|
{
|
challengeRedpoint.state = RedPointState.Simple;
|
}
|
}
|
}
|
|
if (GetErrorOfChallenge() == 0)
|
{
|
towerRedpoint.state = RedPointState.Simple;
|
}
|
|
}
|
|
|
//第一次渡劫引导
|
public void StartRealmFistBreakUPGuide()
|
{
|
//满经验任务已完成领取可以渡劫,或者满经验任务完成但未领取奖励,都可以引导
|
var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
|
if (realmLevel != 1)
|
return;
|
|
var config = RealmConfig.Get(realmLevel);
|
if (PlayerDatas.Instance.baseData.LV < config.LVMax)
|
{
|
return;
|
}
|
|
if (PlayerDatas.Instance.baseData.LV == config.LVMax)
|
{
|
//需要满经验
|
ulong totalExp = (ulong)PlayerDatas.Instance.baseData.TotalExp + (ulong)PlayerDatas.Instance.baseData.ExpPoint * Constants.ExpPointValue;
|
ulong maxExp = (ulong)PlayerLVConfig.GetExpByPlayerLv(PlayerDatas.Instance.baseData.LV);
|
|
if (totalExp < maxExp)
|
{
|
return;
|
}
|
}
|
|
var missions = RealmLVUPTaskConfig.GetMissionIDs(realmLevel);
|
for (int i = 0; i < missions.Count; i++)
|
{
|
int missionID = missions[i];
|
int state = GetMissionState(PlayerDatas.Instance.baseData.realmLevel, missionID);
|
if (state < 1)
|
{
|
return;
|
|
}
|
}
|
|
if (!NewBieCenter.Instance.inGuiding)
|
NewBieCenter.Instance.StartNewBieGuideEx(firstRealmBreakUpGuideID);
|
}
|
|
|
#region 境界塔
|
|
//下一个最近的特殊奖励层
|
public int GetNextRewardShowFloor()
|
{
|
var floors = rewardShowFloors.Keys.ToList();
|
floors.Sort();
|
for (var i = 0; i < floors.Count; i++)
|
{
|
if (floors[i] >= currentFloor)
|
{
|
return floors[i];
|
}
|
}
|
|
return 0;
|
}
|
|
public void RequestChallenge()
|
{
|
var error = GetErrorOfChallenge();
|
if (error == 0 || error == 3)
|
{
|
dungeonModel.RequestChallangeDungeon(Tower_MapId, 0);
|
}
|
else
|
{
|
switch (error)
|
{
|
case 1:
|
SysNotifyMgr.Instance.ShowTip("BossRealmHint2", RealmTowerConfig.Get(selectFloorID).NeedRealmLV);
|
break;
|
default:
|
break;
|
}
|
}
|
}
|
|
//0 可挑战 1 境界不足 2 已通关 3 战力不足(红点用)
|
private int GetErrorOfChallenge()
|
{
|
if (PlayerDatas.Instance.baseData.realmLevel < realmTowerOpenRealm)
|
{
|
return 1;
|
}
|
|
if (selectFloorID == 0)
|
return 1;
|
|
var config = RealmTowerConfig.Get(selectFloorID);
|
if (config.NeedRealmLV > PlayerDatas.Instance.baseData.realmLevel)
|
{
|
return 1;
|
}
|
|
if (NPCExConfig.Get(config.BossID).SuppressFightPower > (long)PlayerDatas.Instance.baseData.FightPoint)
|
return 3;
|
|
|
if (selectFloorID <= passedFloor)
|
{
|
//已通关
|
return 2;
|
}
|
|
return 0;
|
}
|
|
public void UpdateRealmTowerInfo(HB217_tagMCRealmTowerInfo netPack)
|
{
|
passedFloor = (int)netPack.Floor;
|
|
//显示不超过当前的大境界塔层
|
var config = RealmTowerConfig.Get(currentFloor);
|
if (config != null)
|
{
|
int largeRealm = Math.Max(1, RealmConfig.Get(RealmTowerConfig.Get(currentFloor).NeedRealmLV).LvLarge);
|
int largeRealmNow = Math.Max(1, RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel).LvLarge);
|
if (largeRealm > largeRealmNow)
|
{
|
selectFloorID = passedFloor;
|
}
|
else
|
{
|
selectFloorID = currentFloor;
|
}
|
}
|
else
|
{
|
selectFloorID = passedFloor;
|
}
|
redpointDirty = true;
|
OnTowerPassEvent?.Invoke();
|
}
|
|
public void RequestRefreshMonster()
|
{
|
var sendInfo = new CA508_tagCMDoFBAction();
|
sendInfo.ActionType = 0;
|
sendInfo.ActionInfo = (uint)currentFloor;
|
GameNetSystem.Instance.SendInfo(sendInfo);
|
}
|
#endregion
|
|
#region 境界任务
|
//当前境界的任务状态
|
int taskAwardState;
|
Dictionary<int, int> taskValues = new Dictionary<int, int>();
|
public const int BreakRealmPill = 4501; //破境丹ID
|
public RealmLVUPTaskConfig equipNeedConfig;
|
public Dictionary<int, int[]> realMissionGuides = new Dictionary<int, int[]>();
|
public event Action RealmMissionRefreshEvent;
|
int firstRealmBreakUpGuideID = 0; //第一次渡劫由程序引导 满经验时
|
int[] mainTaskIDsNotGuide; //主线任务不引导的任务ID, 避免任务循环引导
|
int[][] dailyQuestInfoForLvGuide; //等级不足时引导的日常信息
|
int defaultGuideID; //默认引导ID
|
|
public int realmTowerOpenRealm; //境界塔开启的境界等级
|
public int realmTowerGuideID; //境界塔引导ID
|
|
//public uint TaskAwardState; //进阶任务领奖状态;按任务ID二进制位存储是否已领取
|
// 返回服务端的记录任务奖励状态 0未领取 1已领取
|
public int GetMissionAwardState(int id)
|
{
|
return (taskAwardState & (int)Math.Pow(2, id)) != 0 ? 1 : 0;
|
}
|
|
//任务类型 任务说明 所需值1 所需值2 所需值3 所需值4
|
//1 等级达到x级 x级
|
//2 通关x地图x层 地图ID 层
|
//3 杀怪x只 x只
|
//4 需要境界丹 x个
|
//5 装备条件 阶级 星数 是否套装 颜色
|
//6 挑战心魔 NPCID
|
|
//客户端显示的任务状态 0 代表进行中 1 代表可领取 2 代表已领取
|
public int GetMissionState(int realm, int missionID)
|
{
|
var id = RealmLVUPTaskConfig.GetID(realm, missionID);
|
var config = RealmLVUPTaskConfig.Get(id);
|
var type = config.TaskType;
|
if (type == 5)
|
{
|
//需求装备条件的初始化
|
equipNeedConfig = config;
|
}
|
if (GetMissionAwardState(missionID) == 1)
|
{
|
return 2;
|
}
|
|
switch (type)
|
{
|
case 1:
|
return PlayerDatas.Instance.baseData.LV >= config.NeedValueList[0] ? 1 : 0;
|
case 2:
|
if (config.NeedValueList[0] == SkyTowerModel.DATA_MAPID)
|
{
|
return ModelCenter.Instance.GetModel<SkyTowerModel>().highestPassFloor >= config.NeedValueList[1] ? 1 : 0;
|
}
|
return 0;
|
case 3:
|
return taskValues.ContainsKey(missionID) && taskValues[missionID] >= config.NeedValueList[0] ? 1 : 0;
|
case 4:
|
return packModel.GetItemCountByID(PackType.Item, BreakRealmPill) >= config.NeedValueList[0] ? 1 : 0;
|
case 5:
|
int error;
|
if (SatisfyEquipCondition(config, out error))
|
{
|
return 1;
|
}
|
return 0;
|
case 6:
|
return taskValues.ContainsKey(missionID) && taskValues[missionID] >= 1 ? 1 : 0;
|
case 7:
|
var taskId = taskModel.GetLatestMainTaskId();
|
return TaskListConfig.GetMissionIndex(taskId) > TaskListConfig.GetMissionIndex(config.NeedValueList[0]) ? 1 : 0;
|
default:
|
return 0;
|
}
|
|
}
|
|
public int GetMissionProcess(int id)
|
{
|
if (taskValues.ContainsKey(id))
|
{
|
return taskValues[id];
|
}
|
return 0;
|
}
|
|
//type: 1等级 2爬塔 3杀怪 4.境界丹 5.装备条件 6.心魔
|
|
public void RealMissionGuide(int type, int id = 0)
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var mapConfig = MapConfig.Get(mapId);
|
if (mapConfig.MapFBType != (int)MapType.OpenCountry)
|
{
|
SysNotifyMgr.Instance.ShowTip("InFBCanotDo");
|
return;
|
}
|
//if (type != 5 && type != 6)
|
// WindowCenter.Instance.Close<RealmWin>();
|
bool isCloseRealmWin = type != 5 && type != 6 ? true : false;
|
if (type == 5)
|
{
|
WindowCenter.Instance.Open<RealmRecommandEquipWin>(false, id);
|
}
|
else if (realMissionGuides.ContainsKey(type))
|
{
|
|
int guideIndex = 0;
|
if (type == 1)
|
{
|
//引导优先级按日常任务状态规则0表示开启且有次数,-1代表未开启;配正整数6万下数字表示小于等于已完成正常次数引导,
|
//大于6万购买次数用60000+数字,如60000代表有购买次数不管几次,60001代表购买1次
|
//其他情况特殊约定【【活跃修炼,超过等于活跃点200引导】
|
for (int i = 0; i < dailyQuestInfoForLvGuide.Length; i++)
|
{
|
int dailyquestID = dailyQuestInfoForLvGuide[i][0];
|
|
if (dailyquestID == 0)
|
{
|
var latestTask = taskModel.GetLatestMainTaskId();
|
|
if (latestTask != 0 && TaskListConfig.Has(latestTask) && TaskListConfig.Get(latestTask).RealmPriority == 1
|
&&(taskModel.GetTaskStatus(latestTask) != TaskModel.TaskStatus.CardLevel && taskModel.GetTaskStatus(latestTask) != TaskModel.TaskStatus.TreasureCardLevel))
|
{
|
//特殊约定0为主线任务
|
guideIndex = i;
|
break;
|
}
|
continue;
|
}
|
|
var dailyQuestState = dailyQuestModel.GetQuestState(dailyquestID);
|
if (dailyQuestState == DailyQuestModel.DailyQuestState.OutTime ||
|
dailyQuestState == DailyQuestModel.DailyQuestState.Completed)
|
continue;
|
|
int count = dailyQuestInfoForLvGuide[i][1];
|
|
if (dailyQuestState == DailyQuestModel.DailyQuestState.Locked && count == -1)
|
{
|
guideIndex = i;
|
break;
|
}
|
else if (dailyQuestState == DailyQuestModel.DailyQuestState.Normal && count < 60000)
|
{
|
if (dailyquestID == (int)DailyQuestType.ActivityPlace)
|
{
|
if (dailyQuestModel.usableActivePoint >= count)
|
{
|
guideIndex = i;
|
break;
|
}
|
}
|
else if (count == 0)
|
{
|
guideIndex = i;
|
break;
|
}
|
else if (count > 0 && dailyQuestModel.GetDailyQuestCompletedTimes(dailyquestID) <= count)
|
{
|
guideIndex = i;
|
break;
|
}
|
}
|
else if (dailyQuestState == DailyQuestModel.DailyQuestState.CanBuyTimes && count >= 60000)
|
{
|
if (count == 60000)
|
{
|
guideIndex = i;
|
break;
|
}
|
else if (dailyQuestModel.GetDailyQueAlreadyBuyTimes(dailyquestID) < count - 60000)
|
{
|
guideIndex = i;
|
break;
|
}
|
}
|
}
|
if (guideIndex >= realMissionGuides[type].Length)
|
{
|
guideIndex = realMissionGuides[type].Length - 1;
|
Debug.LogError("RealmMission 配置长度不匹配,具体查看功能配置表说明");
|
}
|
}
|
else if (type == 2)
|
{
|
if (!FuncOpen.Instance.IsFuncOpen(164, true))
|
{
|
return;
|
}
|
}
|
else if (type == 3)
|
{
|
if (FuncOpen.Instance.IsFuncOpen(108))
|
{
|
guideIndex = 1;
|
}
|
}
|
else if (type == 4)
|
{
|
if (!FuncOpen.Instance.IsFuncOpen(21))
|
{
|
guideIndex = 0;
|
}
|
else if (worldBossModel.GetWorldBossRemainCount() > 0)
|
{
|
guideIndex = 1;
|
}
|
else if (bossHomeModel.remindTimes > 0)
|
{
|
guideIndex = 2;
|
}
|
else if (GetErrorOfChallenge() == 0)
|
{
|
guideIndex = 3;
|
isCloseRealmWin = false;
|
}
|
else
|
{
|
guideIndex = 4;
|
}
|
}
|
|
//主线引导ID 为34
|
int guideID = realMissionGuides[type][guideIndex];
|
if (guideID == 34)
|
{
|
if (WindowCenter.Instance.IsOpen<DemonJarDamageRankWin>())
|
{
|
return;
|
}
|
var latestTask = taskModel.GetLatestMainTaskId();
|
var taskState = taskModel.GetQuestState(latestTask);
|
if (mainTaskIDsNotGuide.Contains(latestTask) && taskState == 1)
|
{
|
guideID = defaultGuideID;
|
}
|
}
|
NewBieCenter.Instance.StartNewBieGuideEx(guideID);
|
}
|
if (isCloseRealmWin)
|
WindowCenter.Instance.Close<RealmWin>();
|
}
|
|
|
public void RequestAllAwards()
|
{
|
var missisons = RealmLVUPTaskConfig.GetMissionIDs(PlayerDatas.Instance.baseData.realmLevel);
|
for (int i = 0; i < missisons.Count; i++)
|
{
|
var state = GetMissionState(PlayerDatas.Instance.baseData.realmLevel, missisons[i]);
|
if (state == 1)
|
{
|
CA504_tagCMPlayerGetReward pak = new CA504_tagCMPlayerGetReward();
|
pak.RewardType = 68;
|
pak.DataEx = (uint)missisons[i];
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
}
|
}
|
|
#endregion
|
}
|
|
public struct RealmLevelUpEquipCondition
|
{
|
public int level;
|
public int starLevel;
|
public bool isSuit;
|
public int itemColor;
|
}
|
|
}
|