Initial version - 1.2.0.60

EN: 1.2.0.60
CN: 1.2.0.61
JP: 1.2.0.63
KR: 1.2.0.67
This commit is contained in:
SL1900
2025-12-03 01:00:00 +09:00
commit 5e0d58cfad
3595 changed files with 9373562 additions and 0 deletions
@@ -0,0 +1,58 @@
local AchievementChecker = {}
local MonsterRelevant = require("Game.Adventure.AchievementCheck.MonsterRelevant")
local SkillsRelevant = require("Game.Adventure.AchievementCheck.SkillsRelevant")
local PlayerRelevant = require("Game.Adventure.AchievementCheck.PlayerRelevant")
AchievementChecker.BattleAchievementCheckFunction = {
[GameEnum.questCompleteCondClient.KillMonsterWithoutHitBySkill] = SkillsRelevant.KillMonsterWithoutHitBySkill,
[GameEnum.questCompleteCondClient.KillMonsterWithoutKillSpecifiedMonster] = MonsterRelevant.CheckKillMonsterWithoutKillSpecifiedMonster,
[GameEnum.questCompleteCondClient.KillMonsterWithOneAttack] = MonsterRelevant.CheckKillMonsterWithOneAttack,
[GameEnum.questCompleteCondClient.CritCount] = PlayerRelevant.CritCount,
[GameEnum.questCompleteCondClient.CastSkillTypeCount] = PlayerRelevant.CastSkillTypeCount,
[GameEnum.questCompleteCondClient.CastSkillCount] = PlayerRelevant.CastSkillCount,
[GameEnum.questCompleteCondClient.ExtremDodgeCount] = PlayerRelevant.ExtremDodgeCount,
[GameEnum.questCompleteCondClient.KillMonsterClass] = MonsterRelevant.KillMonsterClass,
[GameEnum.questCompleteCondClient.TriggerTagElement] = PlayerRelevant.TriggerTagElement,
[GameEnum.questCompleteCondClient.OneHitDamage] = PlayerRelevant.OneHitDamage,
[GameEnum.questCompleteCondClient.ClearLevelWithHPBelow] = PlayerRelevant.ClearLevelWithHPBelow,
[GameEnum.questCompleteCondClient.KillMonsterWithTag] = MonsterRelevant.KillMonsterWithTag,
[GameEnum.questCompleteCondClient.KillMonsterWithSkin] = MonsterRelevant.KillMonsterWithSkin
}
function AchievementChecker:CheckBattleAchievement(tbAchievementId, tbRet, bBattleSuccess)
local battleData = NovaAPI.GetAchievementData()
if battleData == nil then
printError("成就战斗数据null")
return
end
for _, nAchievementId in ipairs(tbAchievementId) do
local mapAchievementData = ConfigTable.GetData("Achievement", nAchievementId)
if mapAchievementData == nil then
printError("成就数据不存在:" .. nAchievementId)
return
end
if mapAchievementData.CompleteCondClient > 999 then
local bHasValue, nCount = battleData.specialBattleData:TryGetValue(mapAchievementData.CompleteCondClient)
print("Check Special Battle Achievement:" .. nAchievementId .. " Type:" .. mapAchievementData.CompleteCondClient)
if bHasValue and 0 < nCount then
print("Add Special Battle Achievement:" .. nAchievementId .. " Type:" .. mapAchievementData.CompleteCondClient .. " Count:" .. nCount)
table.insert(tbRet, {
Data = {nCount, nAchievementId},
Id = GameEnum.eventTypes.eClient
})
end
else
if self.BattleAchievementCheckFunction[mapAchievementData.CompleteCondClient] == nil then
printError("成就检测方法未绑定:" .. mapAchievementData.CompleteCondClient)
return
end
local nCount = self.BattleAchievementCheckFunction[mapAchievementData.CompleteCondClient](mapAchievementData, battleData, bBattleSuccess)
if 0 < nCount then
print(string.format("成就%d完成", nAchievementId))
table.insert(tbRet, {
Data = {nCount, nAchievementId},
Id = GameEnum.eventTypes.eClient
})
end
end
end
end
return AchievementChecker
@@ -0,0 +1,95 @@
local MonsterRelevant = {}
function MonsterRelevant.CheckKillMonsterWithoutKillSpecifiedMonster(mapAchievementData, AchievementDataDic)
for _, nMonsterId in ipairs(mapAchievementData.ClientCompleteParams1) do
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
if mapKillDic:ContainsKey(nMonsterId) then
return 0
end
end
end
for _, nMonsterId in ipairs(mapAchievementData.ClientCompleteParams2) do
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
if mapKillDic:ContainsKey(nMonsterId) then
return 1
end
end
end
return 0
end
function MonsterRelevant.CheckKillMonsterWithOneAttack(mapAchievementData, AchievementDataDic)
local nTarget = mapAchievementData.ClientCompleteParams1[1]
local nTargetChar = mapAchievementData.ClientCompleteParams2[1]
for nCharId, nCount in pairs(AchievementDataDic.OnceSkillKillCountDic) do
if (#nTargetChar == 0 or 0 < table.indexof(nTargetChar, nCharId)) and nCount > nTarget then
return 1
end
end
return 0
end
function MonsterRelevant.KillMonsterClass(mapAchievementData, AchievementDataDic)
local nCount = 0
local tbTarget = mapAchievementData.ClientCompleteParams1
local tbTargetChar = mapAchievementData.ClientCompleteParams2
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
if #tbTargetChar == 0 or 0 < table.indexof(tbTargetChar, nCharId) then
for nMonsterId, nKillCount in pairs(mapKillDic) do
local mapMonsterCfg = ConfigTable.GetData("Monster", nMonsterId)
if mapMonsterCfg ~= nil and 0 < table.indexof(tbTarget, mapMonsterCfg.EpicLv) then
nCount = nCount + nKillCount
end
end
end
end
return nCount
end
function MonsterRelevant.KillMonsterWithTag(mapAchievementData, AchievementDataDic)
local nCount = 0
local nTargetChar = mapAchievementData.ClientCompleteParams1
local tbTarget = mapAchievementData.ClientCompleteParams3
if tbTarget == nil then
return 0
end
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
if #nTargetChar == 0 or 0 < table.indexof(nTargetChar, nCharId) then
for nMonsterId, nKillCount in pairs(mapKillDic) do
local mapMonsterCfg = ConfigTable.GetData("Monster", nMonsterId)
if mapMonsterCfg ~= nil then
if 0 < table.indexof(mapMonsterCfg.Tag1, tbTarget) then
nCount = nCount + nKillCount
elseif 0 < table.indexof(mapMonsterCfg.Tag2, tbTarget) then
nCount = nCount + nKillCount
elseif 0 < table.indexof(mapMonsterCfg.Tag3, tbTarget) then
nCount = nCount + nKillCount
elseif 0 < table.indexof(mapMonsterCfg.Tag4, tbTarget) then
nCount = nCount + nKillCount
elseif 0 < table.indexof(mapMonsterCfg.Tag5, tbTarget) then
nCount = nCount + nKillCount
end
end
end
end
end
return nCount
end
function MonsterRelevant.KillMonsterWithSkin(mapAchievementData, AchievementDataDic)
local nCount = 0
local tbTargetSkin = mapAchievementData.ClientCompleteParams1
if tbTargetSkin == nil then
return 0
end
for _, mapKillDic in pairs(AchievementDataDic.killDataDic) do
if 0 < #tbTargetSkin then
for nMonsterId, nKillCount in pairs(mapKillDic) do
local mapMonsterCfg = ConfigTable.GetData("Monster", nMonsterId)
if mapMonsterCfg ~= nil then
local nFAId = mapMonsterCfg.FAId
if 0 < table.indexof(tbTargetSkin, nFAId) then
nCount = nCount + nKillCount
end
end
end
end
end
return nCount
end
return MonsterRelevant
@@ -0,0 +1,70 @@
local PlayerRelevant = {}
function PlayerRelevant.CritCount(mapAchievementData, AchievementDataDic)
local ret = 0
for nCharId, nCritCount in ipairs(AchievementDataDic.CritCountData) do
if #mapAchievementData.ClientCompleteParams1 == 0 or 0 < table.indexof(mapAchievementData.ClientCompleteParams1, nCharId) then
ret = ret + nCritCount
end
end
return ret
end
function PlayerRelevant.CastSkillTypeCount(mapAchievementData, AchievementDataDic)
local nCount = 0
local tbTarget = mapAchievementData.ClientCompleteParams1
for nSkillId, nCastCount in pairs(AchievementDataDic.CastSkillData) do
local mapSkill = ConfigTable.GetData("Skill", nSkillId)
if mapSkill ~= nil and 0 < table.indexof(tbTarget, mapSkill.Type) then
nCount = nCount + nCastCount
end
end
return nCount
end
function PlayerRelevant.CastSkillCount(mapAchievementData, AchievementDataDic)
local nCount = 0
local tbTarget = mapAchievementData.ClientCompleteParams1
for nSkillId, nCastCount in pairs(AchievementDataDic.CastSkillData) do
local mapSkill = ConfigTable.GetData("Skill", nSkillId)
if mapSkill ~= nil and 0 < table.indexof(tbTarget, mapSkill.Id) then
nCount = nCount + nCastCount
end
end
return nCount
end
function PlayerRelevant.ExtremDodgeCount(mapAchievementData, AchievementDataDic)
local ret = 0
for nCharId, nPrefectDodgeCount in ipairs(AchievementDataDic.PrefectDodgeData) do
if #mapAchievementData.ClientCompleteParams1 == 0 or 0 < table.indexof(mapAchievementData.ClientCompleteParams1, nCharId) then
ret = ret + nPrefectDodgeCount
end
end
return ret
end
function PlayerRelevant.TriggerTagElement(mapAchievementData, AchievementDataDic)
local nCount = 0
local tbTarget = mapAchievementData.ClientCompleteParams1
for nMark, nTriggerCount in pairs(AchievementDataDic.MarkTriggerData) do
if 0 < table.indexof(tbTarget, nMark) then
nCount = nCount + nTriggerCount
end
end
return nCount
end
function PlayerRelevant.OneHitDamage(mapAchievementData, AchievementDataDic)
local nTarget = mapAchievementData.ClientCompleteParams1[1]
if nTarget <= AchievementDataDic.MaxDamageValue then
return 1
end
return 0
end
function PlayerRelevant.ClearLevelWithHPBelow(mapAchievementData, AchievementDataDic, bSuccess)
if not bSuccess then
return 0
end
local nTarget = mapAchievementData.ClientCompleteParams1[1]
local nCurPrec = AchievementDataDic.MainActorHpPrec * 100
if nTarget >= nCurPrec then
return 1
end
return 0
end
return PlayerRelevant
@@ -0,0 +1,31 @@
local SkillsRelevant = {}
function SkillsRelevant.KillMonsterWithoutHitBySkill(mapAchievementData, AchievementDataDic)
if mapAchievementData.ClientCompleteParams2 == nil then
return 0
end
if mapAchievementData.ClientCompleteParams1 == nil then
return 0
end
if AchievementDataDic.DamageDataDic == nil then
return 0
end
if AchievementDataDic.killDataDic == nil then
return 0
end
for _, nHitDamageId in ipairs(mapAchievementData.ClientCompleteParams2) do
for nCharId, mapDamageDic in pairs(AchievementDataDic.DamageDataDic) do
if mapDamageDic:ContainsKey(nHitDamageId) then
return 0
end
end
end
for _, nMonsterId in ipairs(mapAchievementData.ClientCompleteParams1) do
for nCharId, mapKillDic in pairs(AchievementDataDic.killDataDic) do
if mapKillDic:ContainsKey(nMonsterId) then
return 1
end
end
end
return 0
end
return SkillsRelevant
@@ -0,0 +1,207 @@
local ActivityLevelsInstanceLevel = class("ActivityLevelsInstanceLevel")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local AdventureModuleHelper = CS.AdventureModuleHelper
local TimerManager = require("GameCore.Timer.TimerManager")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvent_Pause",
ActivityInstance_Result = "LevelResultChange",
ActivityLevelSettle_Failed = "OnEvent_ActivityLevelSettleFailed"
}
function ActivityLevelsInstanceLevel:Init(parent, nActivityId, nLevelId, nBuildId)
self.parent = parent
self.nLevelId = nLevelId
self.nActivityId = nActivityId
self.isSettlement = false
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.tbCharId = {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
self.mapActorInfo = {}
for idx, nTid in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
self.mapActorInfo[nTid] = stActorInfo
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.EquipmentInstance
CS.AdventureModuleHelper.EnterActivityLevelsInstance(nLevelId, self.tbCharId)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
end
function ActivityLevelsInstanceLevel:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
EventManager.Hit("OpenActivityLevelsInstanceRoomInfo", self.nLevelId)
end
function ActivityLevelsInstanceLevel:OnEvent_LevelResult(tbStar, bAbandon)
end
function ActivityLevelsInstanceLevel:OnEvent_AbandonBattle()
self:LevelResultChange(false, 0)
end
function ActivityLevelsInstanceLevel:OnEvent_AdventureModuleEnter()
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.ActivityLevels)
EventManager.Hit(EventId.OpenPanel, PanelId.ActivityLevelsBattlePanel, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function ActivityLevelsInstanceLevel:LevelResultChange(isWin, totalTime)
EventManager.Hit("ActivityLevelsInstanceBattleEnd")
self:SettleLevelsInstance(isWin, totalTime)
end
function ActivityLevelsInstanceLevel:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function ActivityLevelsInstanceLevel:SettleLevelsInstance(isWin, totalTime)
if self.isSettlement then
return
end
self.isSettlement = true
local starCount = 0
self:RefreshCharDamageData()
if isWin then
local mapCfg = ConfigTable.GetData("ActivityLevelsLevel", self.nLevelId)
if totalTime <= mapCfg.ThreeStarCondition[1] then
starCount = 3
elseif totalTime <= mapCfg.TwoStarCondition[1] then
starCount = 2
else
starCount = 1
end
end
local callback = function(taFixed, tbFirstReward, nExp, mapChangeInfo)
NovaAPI.InputEnable()
EventManager.Hit("ActivityLevelsInstanceLevelEnd")
self.passStar = starCount
if isWin then
self:PlaySuccessPerform(taFixed, tbFirstReward, nExp, starCount, mapChangeInfo)
else
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.ActivityLevelsInstanceResultPanel, false, 0, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
end
self:UnBindEvent()
self.parent:LevelEnd()
end
NovaAPI.InputDisable()
self.parent:SendActivityLevelSettleReq(self.nActivityId, starCount, callback)
end
function ActivityLevelsInstanceLevel:OnEvent_ActivityLevelSettleFailed()
NovaAPI.InputEnable()
EventManager.Hit("ActivityLevelsInstanceLevelEnd")
self.passStar = 0
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.ActivityLevelsInstanceResultPanel, false, 0, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, nil, self.tbCharDamage)
local nCurTime = CS.ClientManager.Instance.serverTimeStamp
local nEndTime = self.parent.nEndTime
if nCurTime > nEndTime then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Activity_End_Notice"))
end
self:UnBindEvent()
self.parent:LevelEnd()
end
function ActivityLevelsInstanceLevel:PlaySuccessPerform(FixedRewardItems, FirstRewardItems, nExp, starCount, mapChangeInfo)
local func_SettlementFinish = function(bSuccess)
end
local tbChar = self.tbCharId
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nType = ConfigTable.GetData("ActivityLevelsFloor", ConfigTable.GetData("ActivityLevelsLevel", self.nLevelId).FloorId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.ActivityLevelsInstanceResultPanel, true, starCount, FixedRewardItems or {}, FirstRewardItems or {}, {}, nExp or 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
self.bSettle = false
self.parent:LevelEnd()
self:UnBindEvent()
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
CS.AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function ActivityLevelsInstanceLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function ActivityLevelsInstanceLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function ActivityLevelsInstanceLevel:SetCharFixedAttribute()
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function ActivityLevelsInstanceLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function ActivityLevelsInstanceLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function ActivityLevelsInstanceLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function ActivityLevelsInstanceLevel:OnEvent_Pause()
EventManager.Hit("OpenActivityLevelsInstancePause", self.nActivityId, self.nLevelId, self.tbCharId)
end
return ActivityLevelsInstanceLevel
+78
View File
@@ -0,0 +1,78 @@
function UTILS.AddEffect(nCharId, nEffectId, nLevel, nUseCount)
if nUseCount == nil then
nUseCount = 0
end
local mapEftCfgData = ConfigTable.GetData_Effect(nEffectId)
if mapEftCfgData == nil then
printError("Effect Id missing" .. nEffectId)
return nil
end
local nEffectValueId = nEffectId
if mapEftCfgData.levelTypeData == GameEnum.levelTypeData.Exclusive then
nEffectValueId = nEffectValueId + nLevel * 10
elseif mapEftCfgData.levelTypeData == GameEnum.levelTypeData.OutfitPromote then
elseif mapEftCfgData.levelTypeData == GameEnum.levelTypeData.OutfifBreak then
end
local mapEftValueData = ConfigTable.GetData("EffectValue", nEffectValueId)
if mapEftValueData == nil then
printError("EffectValue Id missing" .. nEffectValueId)
return nil
end
local nTakeEffectLimit = mapEftValueData.TakeEffectLimit
local nEftRemainTimes = nTakeEffectLimit
if nTakeEffectLimit ~= 0 then
nEftRemainTimes = nTakeEffectLimit - nUseCount
if nEftRemainTimes <= 0 then
printLog("效果次数已用完:" .. nEffectId)
return nil
end
end
local nEffectUid = 0
return nEffectUid
end
function UTILS.AddBuildEffect(mapCharEffect, mapOutfitEffect)
local retCharEffect = {}
local retOutfitEffect = {}
for nCharId, mapEffect in pairs(mapCharEffect) do
if mapEffect[AllEnum.EffectType.Affinity] ~= nil then
for _, nEffectId in ipairs(mapEffect[AllEnum.EffectType.Affinity]) do
if retCharEffect[AllEnum.EffectType.Affinity] == nil then
retCharEffect[AllEnum.EffectType.Affinity] = {}
end
if retCharEffect[AllEnum.EffectType.Affinity][nEffectId] ~= nil then
printError("重复的EffectID" .. nEffectId)
else
local nEftUid = UTILS.AddEffect(nCharId, nEffectId, 0, 0)
retCharEffect[AllEnum.EffectType.Affinity][nEffectId] = nEftUid
end
end
end
if mapEffect[AllEnum.EffectType.Talent] ~= nil then
for _, nEffectId in ipairs(mapEffect[AllEnum.EffectType.Talent]) do
if retCharEffect[AllEnum.EffectType.Talent] == nil then
retCharEffect[AllEnum.EffectType.Talent] = {}
end
if retCharEffect[AllEnum.EffectType.Talent][nEffectId] ~= nil then
printError("重复的EffectID" .. nEffectId)
else
local nEftUid = UTILS.AddEffect(nCharId, nEffectId, 0, 0)
retCharEffect[AllEnum.EffectType.Talent][nEffectId] = nEftUid
end
end
end
if mapOutfitEffect ~= nil then
for nOutfitTid, tbOutfitEffectId in pairs(mapCharEffect) do
if retOutfitEffect[nOutfitTid] == nil then
retOutfitEffect[nOutfitTid] = {}
end
for _, nEffectId in ipairs(tbOutfitEffectId) do
if retOutfitEffect[nOutfitTid][nEffectId] == nil then
retOutfitEffect[nOutfitTid][nEffectId] = {}
end
local nEftUid = UTILS.AddEffect(nCharId, nEffectId, 0, 0)
table.insert(retOutfitEffect[nOutfitTid][nEffectId], nEftUid)
end
end
end
end
end
@@ -0,0 +1,194 @@
local DailyInstanceLevel = class("DailyInstanceLevel")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local AdventureModuleHelper = CS.AdventureModuleHelper
local TimerManager = require("GameCore.Timer.TimerManager")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
DailyInstanceGameEnd = "OnEvent_LevelResult",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvnet_Pause"
}
function DailyInstanceLevel:Init(parent, nLevelId, nBuildId)
self.parent = parent
self.nLevelId = nLevelId
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.tbCharId = {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
self.mapActorInfo = {}
for idx, nTid in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
self.mapActorInfo[nTid] = stActorInfo
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.DailyInstance
CS.AdventureModuleHelper.EnterDailyInstanceMap(nLevelId, self.tbCharId)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
end
function DailyInstanceLevel:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function DailyInstanceLevel:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
EventManager.Hit("OpenDailyInstanceRoomInfo", ConfigTable.GetData("DailyInstance", self.nLevelId).FloorId, self.nLevelId)
end
function DailyInstanceLevel:OnEvent_LevelResult(tbStar, bAbandon)
EventManager.Hit("DailyInstanceBattleEnd")
if self.parent:GetSettlementState() then
printError("日常副本结算流程重复进入,本次退出")
return
end
self:RefreshCharDamageData()
self.parent:SetSettlementState(true)
local mapDILevelCfgData = ConfigTable.GetData("DailyInstance", self.nLevelId)
local nStar = 0
local nStarCount = 0
nStar = tbStar[0] and nStar | 1 or nStar
nStar = tbStar[1] and nStar | 2 or nStar
nStar = tbStar[2] and nStar | 4 or nStar
for i = 0, 2 do
if tbStar[i] then
nStarCount = nStarCount + 1
end
end
local callback = function(tbSelectReward, tbFirstReward, nExp, mapChangeInfo)
local waitCallback = function()
NovaAPI.InputEnable()
if 0 < nStar then
self:PlaySuccessPerform(tbFirstReward, tbSelectReward, nExp, tbStar, mapChangeInfo)
else
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.DailyInstanceResultPanel, false, tbStar, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
self.parent:LevelEnd()
end
end
EventManager.Hit("DailyInstanceLevelEnd", mapDILevelCfgData.FloorId)
if bAbandon then
waitCallback()
else
TimerManager.Add(1, 2, self, waitCallback, true, true, true, nil)
end
end
NovaAPI.InputDisable()
self.parent:MsgSettleDailyInstance(self.nLevelId, self.mapBuildData.nBuildId, nStar, callback)
end
function DailyInstanceLevel:OnEvent_AbandonBattle()
self:OnEvent_LevelResult({
false,
false,
false
}, true)
end
function DailyInstanceLevel:OnEvent_AdventureModuleEnter()
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.DailyInstance)
EventManager.Hit(EventId.OpenPanel, PanelId.DailyInstanceBattlePanel, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function DailyInstanceLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function DailyInstanceLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function DailyInstanceLevel:PlaySuccessPerform(FirstRewardItems, tbSelectReward, nExp, tbStar, mapChangeInfo)
local func_SettlementFinish = function(bSuccess)
end
local tbChar = self.tbCharId
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nType = ConfigTable.GetData("DailyInstanceFloor", ConfigTable.GetData("DailyInstance", self.nLevelId).FloorId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.DailyInstanceResultPanel, true, tbStar, tbSelectReward or {}, FirstRewardItems or {}, {}, nExp or 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
self.bSettle = false
self.parent:LevelEnd()
self:UnBindEvent()
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
CS.AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function DailyInstanceLevel:SetCharFixedAttribute()
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function DailyInstanceLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function DailyInstanceLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function DailyInstanceLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function DailyInstanceLevel:OnEvnet_Pause()
EventManager.Hit("OpenDailyInstancePause", self.nLevelId, self.tbCharId)
end
return DailyInstanceLevel
@@ -0,0 +1,194 @@
local EquipmentInstanceLevel = class("EquipmentInstanceLevel")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local AdventureModuleHelper = CS.AdventureModuleHelper
local TimerManager = require("GameCore.Timer.TimerManager")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
EquipmentInstanceGameEnd = "OnEvent_LevelResult",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvnet_Pause"
}
function EquipmentInstanceLevel:Init(parent, nLevelId, nBuildId)
self.parent = parent
self.nLevelId = nLevelId
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.tbCharId = {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
self.mapActorInfo = {}
for idx, nTid in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
self.mapActorInfo[nTid] = stActorInfo
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.EquipmentInstance
CS.AdventureModuleHelper.EnterEquipmentInstanceMap(nLevelId, self.tbCharId)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
end
function EquipmentInstanceLevel:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function EquipmentInstanceLevel:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
EventManager.Hit("OpenEquipmentInstanceRoomInfo", ConfigTable.GetData("CharGemInstance", self.nLevelId).FloorId, self.nLevelId)
end
function EquipmentInstanceLevel:OnEvent_LevelResult(tbStar, bAbandon)
EventManager.Hit("EquipmentInstanceBattleEnd")
if self.parent:GetSettlementState() then
printError("装备副本结算流程重复进入,本次退出")
return
end
self:RefreshCharDamageData()
self.parent:SetSettlementState(true)
local mapDILevelCfgData = ConfigTable.GetData("CharGemInstance", self.nLevelId)
local nStar = 0
local nStarCount = 0
nStar = tbStar[0] and 1 or nStar
nStar = tbStar[1] and 2 or nStar
nStar = tbStar[2] and 3 or nStar
for i = 0, 2 do
if tbStar[i] then
nStarCount = nStarCount + 1
end
end
local callback = function(tbStarReward, tbFirstReward, tbSurpriseItems, nExp, mapChangeInfo)
local waitCallback = function()
NovaAPI.InputEnable()
if 0 < nStar then
self:PlaySuccessPerform(tbFirstReward, tbStarReward, tbSurpriseItems, nExp, tbStar, mapChangeInfo)
else
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInstanceResult, false, tbStar, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, {}, self.tbCharDamage or {})
self.parent:LevelEnd()
end
end
EventManager.Hit("EquipmentInstanceLevelEnd", mapDILevelCfgData.FloorId)
if bAbandon then
waitCallback()
else
TimerManager.Add(1, 2, self, waitCallback, true, true, true, nil)
end
end
NovaAPI.InputDisable()
self.parent:MsgSettleEquipmentInstance(self.nLevelId, self.mapBuildData.nBuildId, nStar, callback)
end
function EquipmentInstanceLevel:OnEvent_AbandonBattle()
self:OnEvent_LevelResult({
false,
false,
false
}, true)
end
function EquipmentInstanceLevel:OnEvent_AdventureModuleEnter()
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.EquipmentInstance)
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInstanceBattlePanel, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function EquipmentInstanceLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function EquipmentInstanceLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function EquipmentInstanceLevel:PlaySuccessPerform(FirstRewardItems, tbStarReward, tbSurpriseItems, nExp, tbStar, mapChangeInfo)
local func_SettlementFinish = function(bSuccess)
end
local tbChar = self.tbCharId
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nType = ConfigTable.GetData("CharGemInstanceFloor", ConfigTable.GetData("CharGemInstance", self.nLevelId).FloorId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInstanceResult, true, tbStar, tbStarReward or {}, FirstRewardItems or {}, {}, nExp or 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, tbSurpriseItems or {}, self.tbCharDamage or {})
self.bSettle = false
self.parent:LevelEnd()
self:UnBindEvent()
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
CS.AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function EquipmentInstanceLevel:SetCharFixedAttribute()
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function EquipmentInstanceLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function EquipmentInstanceLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function EquipmentInstanceLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function EquipmentInstanceLevel:OnEvnet_Pause()
EventManager.Hit("OpenEquipmentInstancePause", self.nLevelId, self.tbCharId)
end
return EquipmentInstanceLevel
@@ -0,0 +1,143 @@
local InfinityTowerLevel = class("InfinityTowerLevel")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
InfinityTowerEnd = "OnEvent_InfinityTowerEnd",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvnet_Pause",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
Infinity_Tower_RunTime = "OnEvent_InfinityTowerRunTime",
ADVENTURE_LEVEL_UNLOAD_COMPLETE = "OnEvent_UnloadComplete"
}
function InfinityTowerLevel:Init(parent, floorId, nBuildId, againOrNextLv, isContinue)
self.parent = parent
self.floorId = floorId
self.lvRunTime = 0
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.tbCharId = {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
self.mapActorInfo = {}
for idx, nTid in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
self.mapActorInfo[nTid] = stActorInfo
end
self.parent:CacheBuildCharTid(self.tbCharId)
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.InfinityTower
CS.AdventureModuleHelper.EnterInfinityTowerFloor(self.floorId, self.tbCharId, isContinue)
if againOrNextLv == 0 then
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
else
self:OnEvent_AdventureModuleEnter()
end
EventManager.Hit("Infinity_Refresh_Msg")
end
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
end
function InfinityTowerLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function InfinityTowerLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function InfinityTowerLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function InfinityTowerLevel:OnEvent_InfinityTowerEnd(state)
if state == 1 then
self.parent:ITSettleReq(2, self.lvRunTime, self.tbCharId)
elseif state == 2 then
self.parent:ITSettleReq(1, self.lvRunTime, self.tbCharId)
elseif state == 3 then
self.parent:ITSettleReq(3, self.lvRunTime, self.tbCharId)
end
EventManager.Hit("Infinity_Hide_Time")
EventManager.Hit("ResetBossHUD")
end
function InfinityTowerLevel:OnEvent_AdventureModuleEnter()
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.InfinityTower)
EventManager.Hit(EventId.OpenPanel, PanelId.InfinityTowerBattlePanel, self.tbCharId)
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
EventManager.Hit(EventId.OpenPanel, PanelId.Hud)
end
cs_coroutine.start(wait)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function InfinityTowerLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function InfinityTowerLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function InfinityTowerLevel:OnEvent_LoadLevelRefresh()
EventManager.Hit("MainBattleMenuBtnPauseActive", true)
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
local tabAddAffixBuff = PlayerData.InfinityTower:GetFloorAffixBuff(self.tbCharId, self.floorId)
safe_call_cs_func(CS.AdventureModuleHelper.InfinityTowerFloorEffects, tabAddAffixBuff)
end
function InfinityTowerLevel:OnEvent_UnloadComplete()
self.parent:EnterInfinityTowerAgainNext()
end
function InfinityTowerLevel:OnEvnet_Pause()
EventManager.Hit("show_Infinity_Pause", self.lvRunTime, self.tbCharId)
end
function InfinityTowerLevel:OnEvent_AbandonBattle()
self:OnEvent_InfinityTowerEnd(3)
end
function InfinityTowerLevel:OnEvent_InfinityTowerRunTime(rTime)
self.lvRunTime = rTime
end
return InfinityTowerLevel
@@ -0,0 +1,688 @@
local JointDrillLevelData = class("JointDrillLevelData")
local FP = CS.TrueSync.FP
local PB = require("pb")
local AdventureModuleHelper = CS.AdventureModuleHelper
local TimerManager = require("GameCore.Timer.TimerManager")
local LocalData = require("GameCore.Data.LocalData")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvent_Pause",
JointDrill_StartTiming = "OnEvent_BattleStart",
JointDrill_MonsterSpawn = "OnEvent_MonsterSpawn",
JointDrill_BattleLvsToggle = "OnEvent_BattleLvsToggle",
ADVENTURE_LEVEL_UNLOAD_COMPLETE = "OnEvent_UnloadComplete",
JointDrill_Gameplay_Time = "OnEvent_JointDrill_Gameplay_Time",
JointDrill_DamageValue = "OnEvent_DamageValue",
JointDrill_CharDamageValue = "OnEvent_CharDamageValue",
GiveUpJointDrill = "OnEvent_GiveUpBattle",
RestartJointDrill = "OnEvent_RestartJointDrill",
RetreatJointDrill = "OnEvent_RetreatJointDrill",
JointDrill_Result = "OnEvent_JointDrill_Result",
InputEnable = "OnEvent_InputEnable",
JointDrill_StopTime = "OnEvent_JointDrill_StopTime",
JointDrillChallengeFinishError = "OnEvent_JointDrillChallengeFinishError",
Upload_Dodge_Event = "OnEvent_UploadDodgeEvent"
}
function JointDrillLevelData:Init(parent, nLevelId, nBuildId, nCurLevel, bChangeLevel)
self.parent = parent
self.nLevelId = nLevelId
self.nCurLevel = nCurLevel
self.nBuildId = nBuildId
self.bChangeLevel = bChangeLevel
self.mapLevel = nil
self.tbFloor = {}
self.mapFloor = nil
self.nGameTime = self.parent:GetGameTime()
self.bInResult = false
if not bChangeLevel or self.bRestart then
self.nDamageValue = 0
self.tbCharDamage = {}
self.mapActorInfo = nil
end
self.mapTempData = {}
if self.parent.record ~= nil and self.parent.record ~= "" then
self.mapTempData = self.parent:DecodeTempDataJson()
if not bChangeLevel or self.bRestart then
self.mapInitTempData = clone(self.mapTempData)
end
end
if self.mapInitTempData == nil then
self.mapInitTempData = {}
end
local mapJointDrillLevelData = ConfigTable.GetData("JointDrillLevel", nLevelId)
if mapJointDrillLevelData == nil then
return
end
self.mapLevel = mapJointDrillLevelData
local nFloorGroup = mapJointDrillLevelData.FloorId
self.tbFloor = CacheTable.GetData("_JointDrillFloor", nFloorGroup)
self.mapFloor = self.tbFloor[nCurLevel]
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.parent:AddJointDrillTeam(self.mapBuildData, self.nGameTime, self.nDamageValue)
self.tbCharId = {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
end
self.tbDiscId = {}
for _, nDiscId in pairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
if #self.tbCharDamage == 0 then
for _, v in ipairs(self.tbCharId) do
table.insert(self.tbCharDamage, {nCharId = v, nDamage = 0})
end
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.JointDrill
local mapParams = {
tostring(self.nCurLevel),
tostring(self.bChangeLevel),
tostring(self.nGameTime)
}
self.bRestart = false
if not bChangeLevel then
AdventureModuleHelper.EnterDynamic(self.nLevelId, self.tbCharId, GameEnum.dynamicLevelType.JointDrill, mapParams)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
else
self:StartJointDrill()
AdventureModuleHelper.EnterDynamic(self.nLevelId, self.tbCharId, GameEnum.dynamicLevelType.JointDrill, mapParams)
end
local sKey = LocalData.GetPlayerLocalData("JointDrillRecordKey") or ""
safe_call_cs_func(CS.AdventureModuleHelper.SetDamageRecordId, sKey)
end
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
end
function JointDrillLevelData:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function JointDrillLevelData:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function JointDrillLevelData:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function JointDrillLevelData:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function JointDrillLevelData:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function JointDrillLevelData:GetSyncGameTime(nTime)
return math.floor(tonumber(string.format("%.3f", nTime)) * 1000)
end
function JointDrillLevelData:CacheTempData(bCharacter, bBoss, bChangeTeam, bChangeLevel, bLockBossHp)
if not bCharacter and not bBoss then
return
end
self.mapTempData = {}
self.mapTempData.mapCharacterTempData = {}
self.mapTempData.mapBossTempData = {}
if bCharacter then
local id = AdventureModuleHelper.GetCurrentActivePlayer()
self.mapTempData.mapCharacterTempData.hpInfo = {}
self.mapTempData.mapCharacterTempData.skillInfo = {}
self.mapTempData.mapCharacterTempData.effectInfo = {}
self.mapTempData.mapCharacterTempData.buffInfo = {}
self.mapTempData.mapCharacterTempData.stateInfo = {}
self.mapTempData.mapCharacterTempData.ammoInfo = {}
self.mapTempData.mapCharacterTempData.sommonInfo = AdventureModuleHelper.GetSummonMonsterInfos()
self.mapActorInfo = self:GetActorHp()
self.mapTempData.mapCharacterTempData.hpInfo = self:GetActorHp()
local playerids = AdventureModuleHelper.GetCurrentGroupPlayers()
local Count = playerids.Count - 1
for i = 0, Count do
local charTid = AdventureModuleHelper.GetCharacterId(playerids[i])
local clsSkillId = AdventureModuleHelper.GetPlayerSkillCd(playerids[i])
local nStatus = AdventureModuleHelper.GetPlayerActorStatus(playerids[i])
local nStatusTime = AdventureModuleHelper.GetPlayerActorSpecialStatusTime(playerids[i])
local tbAmmo = AdventureModuleHelper.GetPlayerActorAmmoCount(playerids[i])
local nAmmoType = AdventureModuleHelper.GetPlayerActorAmmoType(playerids[i])
local jsonString = AdventureModuleHelper.GetPlayerActorLocalDataJson(playerids[i])
print(string.format("Status:%d,Time:%d", nStatus, nStatusTime))
if clsSkillId ~= nil then
local tbSkillInfos = clsSkillId.skillInfos
local nSkillCount = tbSkillInfos.Count - 1
for j = 0, nSkillCount do
local clsSkillInfo = tbSkillInfos[j]
local mapSkill = ConfigTable.GetData_Skill(clsSkillInfo.skillId)
if mapSkill == nil then
return
end
if not mapSkill.IsCleanSkillCD then
table.insert(self.mapTempData.mapCharacterTempData.skillInfo, {
nCharId = charTid,
nSkillId = clsSkillInfo.skillId,
nCd = FP.ToInt(clsSkillInfo.currentUseInterval),
nSectionAmount = clsSkillInfo.currentSectionAmount,
nSectionResumeTime = FP.ToInt(clsSkillInfo.currentResumeTime),
nUseTimeHint = FP.ToInt(clsSkillInfo.currentUseTimeHint),
nEnergy = FP.ToInt(clsSkillInfo.currentEnergy)
})
end
end
end
self.mapTempData.mapCharacterTempData.effectInfo[charTid] = {
mapEffect = {}
}
local tbClsEfts = AdventureModuleHelper.GetEffectList(playerids[i])
if tbClsEfts ~= nil then
local nEftCount = tbClsEfts.Count - 1
for k = 0, nEftCount do
local eftInfo = tbClsEfts[k]
local mapEft = ConfigTable.GetData_Effect(eftInfo.effectConfig.Id)
if mapEft == nil then
return
end
local nCd = eftInfo.CD.RawValue
if mapEft.Remove then
self.mapTempData.mapCharacterTempData.effectInfo[charTid].mapEffect[eftInfo.effectConfig.Id] = {nCount = 0, nCd = nCd}
end
end
end
if self.mapEffectTriggerCount ~= nil then
for nEftId, nCount in pairs(self.mapEffectTriggerCount) do
if self.mapTempData.mapCharacterTempData.effectInfo[charTid].mapEffect[nEftId] == nil then
self.mapTempData.mapCharacterTempData.effectInfo[charTid].mapEffect[nEftId] = {nCount = nCount, nCd = 0}
else
self.mapTempData.mapCharacterTempData.effectInfo[charTid].mapEffect[nEftId].nCount = nCount
end
end
end
local tbBuffInfo = AdventureModuleHelper.GetEntityBuffList(playerids[i])
self.mapTempData.mapCharacterTempData.buffInfo[charTid] = {}
if tbBuffInfo ~= nil then
local nBuffCount = tbBuffInfo.Count - 1
for l = 0, nBuffCount do
local eftInfo = tbBuffInfo[l]
local mapBuff = ConfigTable.GetData_Buff(eftInfo.buffConfig.Id)
if mapBuff == nil then
return
end
if mapBuff.NotRemove then
table.insert(self.mapTempData.mapCharacterTempData.buffInfo[charTid], {
Id = eftInfo.buffConfig.Id,
CD = eftInfo:GetBuffLeftTime().RawValue,
nNum = eftInfo:GetBuffNum()
})
end
end
end
self.mapTempData.mapCharacterTempData.stateInfo[charTid] = {
nState = nStatus,
nStateTime = nStatusTime,
jsonStr = jsonString
}
if tbAmmo ~= nil then
self.mapTempData.mapCharacterTempData.ammoInfo[charTid] = {}
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nCurAmmo = nAmmoType
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmo1 = tbAmmo[0]
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmo2 = tbAmmo[1]
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmo3 = tbAmmo[2]
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmoMax1 = tbAmmo[3]
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmoMax2 = tbAmmo[4]
self.mapTempData.mapCharacterTempData.ammoInfo[charTid].nAmmoMax3 = tbAmmo[5]
end
if charTid == self.tbCharId[1] then
self.mapTempData.mapCharacterTempData.shieldList = AdventureModuleHelper.GetEntityShieldList(playerids[i])
end
end
end
if bBoss then
local bSaveEnergyValue = false
local bSaveResilience = false
if bChangeLevel then
bSaveEnergyValue = self.mapFloor.SaveEnergyValue
bSaveResilience = self.mapFloor.SaveResilience
elseif bChangeTeam then
bSaveEnergyValue = self.mapFloor.TeamSaveEnergyValue
bSaveResilience = self.mapFloor.TeamSaveResilience
end
EventManager.HitEntityEvent("RefreshBossEnergyValueHUD", self.nBossId, bSaveEnergyValue)
self.mapTempData.mapBossTempData = AdventureModuleHelper.GetJointDrillBossData(self.nBossId, bChangeTeam, bSaveEnergyValue, bSaveResilience)
if bLockBossHp then
if 0 >= self.mapTempData.mapBossTempData.nHp then
self.mapTempData.mapBossTempData.nHp = 1
end
if 0 >= self.mapTempData.mapBossTempData.nHpMax then
self.mapTempData.mapBossTempData.nHpMax = 1
end
end
end
local data, nDataLength = self.parent:EncodeTempDataJson(self.mapTempData)
print("temp数据长度?" .. #data)
local msgInt = "proto.I32"
local msgLength = {
Value = #data
}
local dataLength = assert(PB.encode(msgInt, msgLength))
local dataNew = dataLength .. data
print("temp数据total长度?" .. #dataNew)
return data, nDataLength
end
function JointDrillLevelData:SetActorHP()
local tbActorInfo = {}
if self.mapActorInfo == nil then
return
end
for nTid, nHp in pairs(self.mapActorInfo) do
local stCharInfo = CS.Lua2CSharpInfo_ActorAttribute()
stCharInfo.actorID = nTid
stCharInfo.curHP = nHp
table.insert(tbActorInfo, stCharInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorAttributes, tbActorInfo)
end
function JointDrillLevelData:ResetBuff()
local ret = {}
if self.mapTempData.mapCharacterTempData ~= nil and self.mapTempData.mapCharacterTempData.buffInfo ~= nil then
for nCharId, mapBuff in pairs(self.mapTempData.mapCharacterTempData.buffInfo) do
for _, mapBuffInfo in ipairs(mapBuff) do
local stBuffInfo = CS.Lua2CSharpInfo_ResetBuffInfo()
stBuffInfo.Id = mapBuffInfo.Id
stBuffInfo.Cd = mapBuffInfo.CD
stBuffInfo.buffNum = mapBuffInfo.nNum
if ret[nCharId] == nil then
ret[nCharId] = {}
end
table.insert(ret[nCharId], stBuffInfo)
end
end
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetBuff, ret)
end
function JointDrillLevelData:ResetSkill()
local ret = {}
if self.mapTempData.mapCharacterTempData ~= nil and self.mapTempData.mapCharacterTempData.skillInfo ~= nil then
for _, skillInfo in ipairs(self.mapTempData.mapCharacterTempData.skillInfo) do
local stSkillInfo = CS.Lua2CSharpInfo_ResetSkillInfo()
stSkillInfo.skillId = skillInfo.nSkillId
stSkillInfo.currentSectionAmount = skillInfo.nSectionAmount
stSkillInfo.cd = FP.FromFloat(skillInfo.nCd).RawValue
stSkillInfo.currentResumeTime = FP.FromFloat(skillInfo.nSectionResumeTime).RawValue
stSkillInfo.currentUseTimeHint = FP.FromFloat(skillInfo.nUseTimeHint).RawValue
stSkillInfo.energy = FP.FromFloat(skillInfo.nEnergy).RawValue
if ret[skillInfo.nCharId] == nil then
ret[skillInfo.nCharId] = {}
end
table.insert(ret[skillInfo.nCharId], stSkillInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorSkillInfo, ret)
end
function JointDrillLevelData:ResetAmmo()
if self.mapTempData.mapCharacterTempData ~= nil and self.mapTempData.mapCharacterTempData.ammoInfo ~= nil then
local ret = {}
for nCharId, mapAmmo in pairs(self.mapTempData.mapCharacterTempData.ammoInfo) do
local stInfo = CS.Lua2CSharpInfo_ActorAmmoInfo()
local tbAmmoCount = {
mapAmmo.nAmmo1,
mapAmmo.nAmmo2,
mapAmmo.nAmmo3
}
stInfo.actorID = nCharId
stInfo.ammoCount = tbAmmoCount
stInfo.ammoType = mapAmmo.nCurAmmo
table.insert(ret, stInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAmmoInfos, ret)
end
end
function JointDrillLevelData:ResetSommon()
if self.mapTempData.mapCharacterTempData ~= nil and self.mapTempData.mapCharacterTempData.sommonInfo ~= nil then
safe_call_cs_func(CS.AdventureModuleHelper.SetSummonMonsters, self.mapTempData.mapCharacterTempData.sommonInfo)
end
end
function JointDrillLevelData:ResetCharacter()
end
function JointDrillLevelData:GetActorHp()
local logStr = ""
local tbActorEntity = AdventureModuleHelper.GetCurrentGroupPlayers()
local mapCurCharInfo = {}
local count = tbActorEntity.Count - 1
for i = 0, count do
local nCharId = AdventureModuleHelper.GetCharacterId(tbActorEntity[i])
local hp = AdventureModuleHelper.GetEntityHp(tbActorEntity[i])
mapCurCharInfo[nCharId] = hp
logStr = logStr .. string.format("EntityID:%d\t角色Id?%d\t角色血量:%d\n", tbActorEntity[i], nCharId, hp)
end
print(logStr)
return mapCurCharInfo
end
function JointDrillLevelData:JointDrillSuccess(netMsg)
local tbSkin = {}
for _, nCharId in ipairs(self.tbCharId) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
local nScoreOld = 0
local mapSelfRank = self.parent:GetSelfRankData()
if mapSelfRank ~= nil then
nScoreOld = mapSelfRank.Score
end
local func_SettlementFinish = function()
end
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nType = self.mapFloor.Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
print("sceneName:" .. sName)
AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
local nResultType = AllEnum.JointDrillResultType.Success
local nScore = netMsg.FightScore + netMsg.HpScore + netMsg.DifficultyScore
local mapScore = {
FightScore = netMsg.FightScore,
HpScore = netMsg.HpScore,
DifficultyScore = netMsg.DifficultyScore,
nTotalScore = self.parent.nTotalScore,
nScore = nScore,
nScoreOld = nScoreOld
}
local bSimulate = self.parent:GetBattleSimulate()
local nBattleCount = self.parent:GetJointDrillBattleCount()
EventManager.Hit(EventId.OpenPanel, PanelId.JointDrillResult, nResultType, self.nCurLevel, 0, self.nLevelId, {}, mapScore, netMsg.Items or {}, netMsg.Change or {}, netMsg.Old, netMsg.New, bSimulate, nBattleCount, self.tbCharDamage)
self.parent:ChallengeEnd()
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function JointDrillLevelData:CheckJointDrillGameOver()
local nChallengeCount = self.parent:GetJointDrillBattleCount()
local nAllChallengeCount = self.parent:GetMaxChallengeCount(self.nLevelId)
if nChallengeCount >= nAllChallengeCount then
local callback = function(netMsg)
self:JointDrillFail(AllEnum.JointDrillResultType.ChallengeEnd, netMsg)
end
self.parent:JointDrillGameOver(callback)
else
local bBossFloor = self.mapFloor.FloorType == GameEnum.JointDrillFloorType.Boss
local data, nDataLength = self:CacheTempData(false, bBossFloor, true, false, true)
local mapBossInfo = self.mapTempData.mapBossTempData
local callback = function(netMsg)
self:JointDrillFail(AllEnum.JointDrillResultType.BattleEnd, netMsg)
end
self.parent:JointDrillGiveUp(self.nCurLevel, self.nGameTime, self.nDamageValue, mapBossInfo.nHp, data, self.mapBuildData, callback)
end
end
function JointDrillLevelData:JointDrillFail(nResultType, netMsg)
local bossInfo = {}
local tempBossData = self.mapTempData.mapBossTempData
if nResultType == AllEnum.JointDrillResultType.Retreat then
tempBossData = self.mapInitTempData.mapBossTempData
end
if tempBossData ~= nil then
bossInfo.nHp = tempBossData.nHp
bossInfo.nHpMax = tempBossData.nHpMax
end
local bSimulate = self.parent:GetBattleSimulate()
local nBattleCount = self.parent:GetJointDrillBattleCount()
local mapScore = {}
local mapReward = {}
local mapChange = {}
local nOld, nNew = 0, 0
local nScoreOld = 0
local mapSelfRank = self.parent:GetSelfRankData()
if mapSelfRank ~= nil then
nScoreOld = mapSelfRank.Score
end
if netMsg ~= nil then
local nScore = netMsg.FightScore + netMsg.HpScore + netMsg.DifficultyScore
mapScore = {
FightScore = netMsg.FightScore,
HpScore = netMsg.HpScore,
DifficultyScore = netMsg.DifficultyScore,
nTotalScore = self.parent.nTotalScore,
nScore = nScore,
nScoreOld = nScoreOld
}
nOld = netMsg.Old
nNew = netMsg.New
mapReward = netMsg.Items or {}
mapChange = netMsg.Change or {}
end
EventManager.Hit(EventId.OpenPanel, PanelId.JointDrillResult, nResultType, self.nCurLevel, self.nGameTime, self.nLevelId, bossInfo, mapScore, mapReward, mapChange, nOld, nNew, bSimulate, nBattleCount, self.tbCharDamage)
self.parent:LevelEnd(nResultType)
end
function JointDrillLevelData:SyncGameTime(nTime)
nTime = nTime or 0
self.nGameTime = math.min(self:GetSyncGameTime(nTime), self.mapLevel.BattleTime * 1000)
self.parent:SetGameTime(self.nGameTime)
EventManager.Hit("RefreshJointDrillGameTime", self.nGameTime)
end
function JointDrillLevelData:ResetGameTimer()
if self.gameTimer ~= nil then
self.gameTimer:Cancel()
self.gameTimer = nil
end
self.bTimerStart = false
end
function JointDrillLevelData:StartJointDrill()
EventManager.Hit(EventId.OpenPanel, PanelId.JointDrillBattlePanel, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function JointDrillLevelData:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
self:ResetBuff()
self:SetActorHP()
self:ResetSkill()
self.parent:AddRecordFloorList()
if not self.bChangeLevel and not self.bRestart then
PlayerData.Build:SetBuildReportInfo(self.mapBuildData.nBuildId)
end
end
function JointDrillLevelData:OnEvent_AdventureModuleEnter()
self:StartJointDrill()
end
function JointDrillLevelData:OnEvent_BattleStart(nTime)
self.bTimerStart = true
self:SyncGameTime(nTime)
end
function JointDrillLevelData:OnEvent_MonsterSpawn(nBossId)
self.nBossId = nBossId
local bBoss = self.mapFloor.FloorType == GameEnum.JointDrillFloorType.Boss
if bBoss and self.mapTempData ~= nil and self.mapTempData.mapBossTempData ~= nil then
AdventureModuleHelper.SetJointDrillBossData(nBossId, self.mapTempData.mapBossTempData)
end
if self.bChangeLevel then
return
end
local data, nDataLength = self:CacheTempData(true, bBoss)
local nHp, nHpMax = 0, 0
if self.mapTempData ~= nil and self.mapTempData.mapBossTempData ~= nil then
nHp = self.mapTempData.mapBossTempData.nHp
nHpMax = self.mapTempData.mapBossTempData.nHpMax
end
self.parent:JointDrillSync(self.nCurLevel, self.nGameTime, self.nDamageValue, nHp, nHpMax, data)
self.mapInitTempData = clone(self.mapTempData)
end
function JointDrillLevelData:OnEvent_BattleLvsToggle(nBattleLv, nTotalTime, nDamageValue)
if nBattleLv < self.nCurLevel then
return
end
nTotalTime = math.min(self.mapLevel.BattleTime * 1000, self:GetSyncGameTime(nTotalTime))
self.nCurLevel = nBattleLv + 1
self.nDamageValue = self.nDamageValue + nDamageValue
self.mapFloor = self.tbFloor[self.nCurLevel]
local bBoss = self.mapFloor.FloorType == GameEnum.JointDrillFloorType.Boss
self:CacheTempData(true, bBoss, false, true, true)
self.parent:AddJointDrillTeam(self.mapBuildData, nTotalTime, self.nDamageValue)
PanelManager.InputDisable()
self.parent:StopRecord()
local syncCallback = function()
PanelManager.InputEnable()
AdventureModuleHelper.LevelStateChanged(false)
EventManager.Hit("ResetBossHUD")
end
local data, nDataLength = self.parent:EncodeTempDataJson(self.mapTempData)
local nHp, nHpMax = 1, 1
local tempBossData = self.mapTempData.mapBossTempData
if tempBossData ~= nil then
nHp = math.max(tempBossData.nHp, 1)
nHpMax = math.max(tempBossData.nHpMax, 1)
end
self.parent:JointDrillSync(self.nCurLevel, nTotalTime, self.nDamageValue, nHp, nHpMax, data, syncCallback)
end
function JointDrillLevelData:OnEvent_UnloadComplete()
if self.bInResult == true then
return
end
if self.bRestart then
self.parent:RestartBattle()
else
self.parent:ChangeLevel(self.nCurLevel)
end
self:ResetCharacter()
end
function JointDrillLevelData:OnEvent_JointDrill_Gameplay_Time(nTime)
self:SyncGameTime(nTime)
end
function JointDrillLevelData:OnEvent_Pause()
EventManager.Hit("OpenJointDrillPause", self.nLevelId, self.tbCharId, self.nGameTime)
end
function JointDrillLevelData:OnEvent_DamageValue(nDamageValue)
self.nDamageValue = self.nDamageValue + nDamageValue
end
function JointDrillLevelData:OnEvent_GiveUpBattle()
self.parent:AddJointDrillTeam(self.mapBuildData, self.nGameTime, self.nDamageValue)
self:CheckJointDrillGameOver()
end
function JointDrillLevelData:OnEvent_RestartJointDrill()
self.bRestart = true
self.parent:SetGameTime(0)
local sRecord = self.parent:EncodeTempDataJson(self.mapInitTempData)
self.parent:ResetRecord(sRecord)
self.parent:SetRecorderExcludeIds(true)
AdventureModuleHelper.LevelStateChanged(false)
EventManager.Hit("ResetBossHUD")
end
function JointDrillLevelData:OnEvent_RetreatJointDrill()
local callback = function()
local sRecord = self.parent:EncodeTempDataJson(self.mapInitTempData)
self.parent:ResetRecord(sRecord)
self:JointDrillFail(AllEnum.JointDrillResultType.Retreat)
end
self.parent:JointDrillRetreat(self.mapBuildData, callback)
end
function JointDrillLevelData:OnEvent_JointDrill_Result(nLevelState, nTotalTime, nDamageValue)
if self.bInResult then
return
end
nTotalTime = math.min(self.mapLevel.BattleTime * 1000, self:GetSyncGameTime(nTotalTime))
self.bInResult = true
self.nDamageValue = self.nDamageValue + nDamageValue
if nLevelState == GameEnum.levelState.Failed then
self.parent:AddJointDrillTeam(self.mapBuildData, self.nGameTime, self.nDamageValue)
self:CheckJointDrillGameOver()
elseif nLevelState == GameEnum.levelState.Success then
local callback = function(netMsg)
self:JointDrillSuccess(netMsg)
end
self.parent:JointDrillSettle(self.mapBuildData, self.nGameTime, self.nDamageValue, callback)
end
end
function JointDrillLevelData:JointDrillTimeOut()
if self.bInResult then
return
end
self.bInResult = true
NovaAPI.DispatchEventWithData("JointDrill_Level_TimeOut")
local callback = function(netMsg)
self:JointDrillFail(AllEnum.JointDrillResultType.ChallengeEnd, netMsg)
end
self.parent:AddJointDrillTeam(self.mapBuildData, self.nGameTime, self.nDamageValue)
self.parent:JointDrillGameOver(callback)
end
function JointDrillLevelData:OnEvent_CharDamageValue(charDamageValue)
for nCharId, nValue in pairs(charDamageValue) do
for _, v in ipairs(self.tbCharDamage) do
if v.nCharId == nCharId then
v.nDamage = v.nDamage + nValue
break
end
end
end
end
function JointDrillLevelData:OnEvent_InputEnable(bEnable)
end
function JointDrillLevelData:OnEvent_JointDrill_StopTime()
end
function JointDrillLevelData:OnEvent_JointDrillChallengeFinishError()
self:JointDrillFail(AllEnum.JointDrillResultType.ChallengeEnd)
EventManager.Hit(EventId.ClosePanel, PanelId.JointDrillBuildList)
self.parent:ChallengeEnd()
end
function JointDrillLevelData:OnEvent_UploadDodgeEvent(padMode)
local tab = {}
table.insert(tab, {
"role_id",
tostring(PlayerData.Base._nPlayerId)
})
table.insert(tab, {"pad_mode", padMode})
table.insert(tab, {"level_type", "JointDrill"})
table.insert(tab, {
"build_id",
tostring(self.nBuildId)
})
table.insert(tab, {
"level_id",
tostring(self.nLevelId)
})
table.insert(tab, {
"up_time",
tostring(CS.ClientManager.Instance.serverTimeStamp)
})
NovaAPI.UserEventUpload("use_dodge_key", tab)
end
return JointDrillLevelData
@@ -0,0 +1,78 @@
local MainlineAvgLevel = class("MainlineAvgLevel")
local mapEventConfig = {
LevelStateChanged = "OnEvent_SendMsgFinishBattle"
}
function MainlineAvgLevel:Init(parent, nMainlineId)
self._nSelectId = nMainlineId
self.parent = parent
self.bSettle = false
self:BindEvent()
local mapMainline = ConfigTable.GetData_Mainline(nMainlineId)
if mapMainline == nil then
self.parent:LevelEnd()
return
end
if mapMainline.AvgId == nil or mapMainline.AvgId == "" then
self.parent:LevelEnd()
return
end
self.parent = parent
local mapData = {
nType = AllEnum.StoryAvgType.PureAvg,
sAvgId = mapMainline.AvgId,
nNodeId = nMainlineId,
callback = nil
}
EventManager.Hit(EventId.OpenPanel, PanelId.PureAvgStory, mapData)
end
function MainlineAvgLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function MainlineAvgLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function MainlineAvgLevel:OnEvent_SendMsgFinishBattle()
if self.bSettle == true then
print("已在结算流程中!")
return
end
self.bSettle = true
print("OnEvent_SendMsgFinishBattle")
local nStar = 7
local func_cbFinishSucc = function(_, mapMainData)
self.parent:UpdateMainlineStar(self._nSelectId, nStar)
EventManager.Hit(EventId.CloesCurPanel)
local close = function()
PlayerData.Base:OnBackToMainMenuModule()
end
if mapMainData.FirstRewardItems and #mapMainData.FirstRewardItems > 0 then
UTILS.OpenReceiveByDisplayItem(mapMainData.FirstRewardItems, mapMainData.Change, close)
else
close()
end
self:UnBindEvent()
self.parent:LevelEnd()
end
local mapSendMsg = {}
mapSendMsg.Ok = true
mapSendMsg.MinChests = {}
mapSendMsg.MaxChests = {}
HttpNetHandler.SendMsg(NetMsgId.Id.mainline_settle_req, mapSendMsg, nil, func_cbFinishSucc)
end
return MainlineAvgLevel
@@ -0,0 +1,503 @@
local MainlineBattleLevel = class("MainlineBattleLevel")
local RapidJson = require("rapidjson")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local mapEventConfig = {
LevelStateChanged = "OnEvent_SendMsgFinishBattle",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
InteractiveBoxGet = "OnEvent_OpenChest",
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
Mainline_Time_CountUp = "OnEvent_Time",
BattlePause = "OnEvnet_Pause",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter"
}
function MainlineBattleLevel:Init(parent, nSelectId, nTeamIdx, tbChestS, tbChestL)
self.bSettle = false
self.parent = parent
self.nMainLineTime = 0
self:BindEvent()
self._nSelectId = nSelectId
self.curFloorIdx = 1
self.nLargeTotalCount = 0
self.nSmallTotalCount = 0
self.curSmallCount = 0
self.curLargeCount = 0
self.bNewSmall = false
self.bNewLarge = false
self._tbBoxS = nil
self._tbBoxL = nil
self.mapCharacterTempData = {}
self._tbOpendChestS = {}
self._tbOpendChestL = {}
local mapMainline = ConfigTable.GetData_Mainline(nSelectId)
self:PrePorcessChestData(self._nSelectId)
self.nSmallTotalCount = #self._tbBoxS
self.nLargeTotalCount = #self._tbBoxL
self.bTrialLevel = mapMainline.TrialCharacter ~= nil and 0 < #mapMainline.TrialCharacter
if self.bTrialLevel then
self.nCurTeamIndex = 1
self.tbChar = {}
self.tbTrialId = {}
for _, nTrialId in pairs(mapMainline.TrialCharacter) do
if 0 < nTrialId then
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
table.insert(self.tbChar, mapTrialChar.nId)
table.insert(self.tbTrialId, nTrialId)
end
end
else
self.nCurTeamIndex = nTeamIdx
self.tbChar = PlayerData.Team:GetTeamCharId(nTeamIdx)
end
self.tbOpenedChestId = {}
for _, idx in ipairs(tbChestS) do
table.insert(self.tbOpenedChestId, self._tbBoxS[idx])
end
for _, idx in ipairs(tbChestL) do
table.insert(self.tbOpenedChestId, self._tbBoxL[idx])
end
if self.bTrialLevel then
for _, nTrialId in ipairs(self.tbTrialId) do
if 0 < nTrialId then
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
local stActorInfo = self.CalCharFixedEffectTrial(nTrialId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, mapTrialChar.nId, stActorInfo)
end
end
else
for idx, nCharId in ipairs(self.tbChar) do
local stActorInfo = self.CalCharFixedEffect(nCharId, idx == 1)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.Mainline
CS.AdventureModuleHelper.EnterMainlineMap(mapMainline.FloorId[1], self.tbChar, self.tbOpenedChestId)
self.curSmallCount = #tbChestS
self.curLargeCount = #tbChestL
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
function MainlineBattleLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function MainlineBattleLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function MainlineBattleLevel.CalCharFixedEffect(nCharId, bMainChar)
local tbstInfo = {}
local tbEffectId = {}
PlayerData.Char:CalcAffinityEffect(nCharId, tbstInfo, tbEffectId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
local nHeartStoneLevel = PlayerData.Char:CalCharacterAttrBattle(nCharId, tbstInfo, stActorInfo, bMainChar)
return tbstInfo, stActorInfo, nHeartStoneLevel
end
function MainlineBattleLevel.CalCharFixedEffectTrial(nTrialId)
local tbstInfo = {}
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
local nHeartStoneLevel = PlayerData.Char:CalCharacterTrialAttrBattle(nTrialId, tbstInfo, stActorInfo)
return stActorInfo, nHeartStoneLevel
end
function MainlineBattleLevel:PrePorcessChestData(nMainlineId)
if ConfigTable.GetData_Mainline(nMainlineId) == nil then
printError("no level data" .. nMainlineId)
end
local tbChestS = decodeJson(ConfigTable.GetData_Mainline(nMainlineId).MinChestReward)
local tbChestL = decodeJson(ConfigTable.GetData_Mainline(nMainlineId).MaxChestReward)
self._tbBoxS = tbChestS
self._tbBoxL = tbChestL
end
function MainlineBattleLevel:PlaySuccessPerform(GenerRewardItems, FirstRewardItems, ChestRewardItems, nExp, nStar, FadeTime, mapChangeInfo)
local func_SettlementFinish = function(bSuccess)
end
local tbChar = self.tbChar
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nFloorCount, nMapId
if PlayerData.Mainline.bUseOldMainline then
nFloorCount = #ConfigTable.GetData_Mainline(self._nSelectId).FloorId
nMapId = ConfigTable.GetData_Mainline(self._nSelectId).FloorId[nFloorCount]
else
nFloorCount = #ConfigTable.GetData_Story(self._nSelectId).FloorId
nMapId = ConfigTable.GetData_Story(self._nSelectId).FloorId[nFloorCount]
end
local nType = ConfigTable.GetData("MainlineFloor", nMapId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
local sLarge, sSmall = self:CalChestInfo()
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, true, nStar or 3, GenerRewardItems or {}, FirstRewardItems or {}, ChestRewardItems or {}, nExp or 0, false, sLarge, sSmall, self._nSelectId, self.tbChar, mapChangeInfo)
self.bSettle = false
self:UnBindEvent()
if PlayerData.Mainline.bUseOldMainline then
self.parent:LevelEnd()
end
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
CS.AdventureModuleHelper.LevelStateChanged(true, FadeTime or 0.5)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function MainlineBattleLevel:OnEvent_OpenChest(nId)
print("OpenBox:" .. nId)
local mapChest = ConfigTable.GetData("Chest", nId)
if mapChest == nil then
printError("宝箱id不存在" .. nId)
return
end
local nType = mapChest.Label
if nType == 1 then
local nIndex = table.indexof(self._tbBoxS, nId)
if self._tbBoxS == nil then
return
end
if nIndex < 1 then
return
end
mapChest = ConfigTable.GetData("Chest", nId)
table.insert(self._tbOpendChestS, nIndex)
self.curSmallCount = self.curSmallCount + 1
self.bNewSmall = true
else
local nIndex = table.indexof(self._tbBoxL, nId)
if self._tbBoxL == nil then
return
end
if nIndex < 1 then
return
end
mapChest = ConfigTable.GetData("Chest", nId)
table.insert(self._tbOpendChestL, nIndex)
self.curLargeCount = self.curLargeCount + 1
self.bNewLarge = true
end
local ShowTips = function(nTid, nCount)
if nTid == 0 or nCount == 0 then
return
end
EventManager.Hit(EventId.ShowRoguelikeDrop, nTid, nCount)
end
ShowTips(mapChest.Item1, mapChest.Number1)
ShowTips(mapChest.Item2, mapChest.Number2)
ShowTips(mapChest.Item3, mapChest.Number3)
ShowTips(mapChest.Item4, mapChest.Number4)
end
function MainlineBattleLevel:OnEvent_LoadLevelRefresh()
self:ResetCharacter()
end
function MainlineBattleLevel:CacheTempData()
local FP = CS.TrueSync.FP
self.mapCharacterTempData = {}
local AdventureModuleHelper = CS.AdventureModuleHelper
local id = AdventureModuleHelper.GetCurrentActivePlayer()
self.mapCharacterTempData.curCharId = CS.AdventureModuleHelper.GetCharacterId(id)
self.mapCharacterTempData.skillInfo = {}
self.mapCharacterTempData.effectInfo = {}
self.mapCharacterTempData.buffInfo = {}
self.mapCharacterTempData.hpInfo = {}
self.mapCharacterTempData.stateInfo = {}
local playerids = AdventureModuleHelper.GetCurrentGroupPlayers()
local Count = playerids.Count - 1
for i = 0, Count do
local charTid = AdventureModuleHelper.GetCharacterId(playerids[i])
local clsSkillId = AdventureModuleHelper.GetPlayerSkillCd(playerids[i])
local nStatus = AdventureModuleHelper.GetPlayerActorStatus(playerids[i])
local nStatusTime = AdventureModuleHelper.GetPlayerActorSpecialStatusTime(playerids[i])
self.mapCharacterTempData.hpInfo[charTid] = AdventureModuleHelper.GetEntityHp(playerids[i])
if clsSkillId ~= nil then
local tbSkillInfos = clsSkillId.skillInfos
local nSkillCount = tbSkillInfos.Count - 1
for j = 0, nSkillCount do
local clsSkillInfo = tbSkillInfos[j]
local mapSkill = ConfigTable.GetData_Skill(clsSkillInfo.skillId)
if mapSkill.Type == GameEnum.skillType.ULTIMATE then
table.insert(self.mapCharacterTempData.skillInfo, {
nCharId = charTid,
nSkillId = clsSkillInfo.skillId,
nCd = clsSkillInfo.currentUseInterval.RawValue,
nSectionAmount = clsSkillInfo.currentSectionAmount,
nSectionResumeTime = clsSkillInfo.currentResumeTime.RawValue,
nUseTimeHint = clsSkillInfo.currentUseTimeHint.RawValue,
nEnergy = clsSkillInfo.currentEnergy.RawValue
})
end
end
self.mapCharacterTempData.effectInfo[charTid] = {
mapEffect = {}
}
local tbClsEfts = AdventureModuleHelper.GetEffectList(playerids[i])
if tbClsEfts ~= nil then
local nEftCount = tbClsEfts.Count - 1
for k = 0, nEftCount do
local eftInfo = tbClsEfts[k]
local mapEft = ConfigTable.GetData_Effect(eftInfo.effectConfig.Id)
local nCd = eftInfo.CD.RawValue
if mapEft.Remove and 0 < nCd then
self.mapCharacterTempData.effectInfo[charTid].mapEffect[eftInfo.effectConfig.Id] = {nCount = 0, nCd = nCd}
end
end
end
local tbBuffInfo = AdventureModuleHelper.GetEntityBuffList(playerids[i])
self.mapCharacterTempData.buffInfo[charTid] = {
mapBuff = {}
}
if tbBuffInfo ~= nil then
local nBuffCount = tbBuffInfo.Count - 1
for l = 0, nBuffCount do
local eftInfo = tbBuffInfo[l]
local mapBuff = ConfigTable.GetData_Buff(eftInfo.buffConfig.Id)
if mapBuff.NotRemove then
table.insert(self.mapCharacterTempData.buffInfo[charTid].mapBuff, {
Id = eftInfo.buffConfig.Id,
CD = eftInfo:GetBuffLeftTime().RawValue,
nNum = eftInfo:GetBuffNum()
})
end
end
end
end
self.mapCharacterTempData.stateInfo[charTid] = {nState = nStatus, nStateTime = nStatusTime}
end
end
function MainlineBattleLevel:ResetCharacter()
if self.mapCharacterTempData.hpInfo ~= nil then
local tbActorInfo = {}
for nTid, nHp in pairs(self.mapCharacterTempData.hpInfo) do
local stCharInfo = CS.Lua2CSharpInfo_ActorAttribute()
stCharInfo.actorID = nTid
stCharInfo.curHP = nHp
table.insert(tbActorInfo, stCharInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorAttributes, tbActorInfo)
end
if self.mapCharacterTempData.skillInfo ~= nil then
local tbSkillInfos = {}
for _, skillInfo in ipairs(self.mapCharacterTempData.skillInfo) do
local stSkillInfo = CS.Lua2CSharpInfo_ResetSkillInfo()
stSkillInfo.skillId = skillInfo.nSkillId
stSkillInfo.currentSectionAmount = skillInfo.nSectionAmount
stSkillInfo.cd = skillInfo.nCd
stSkillInfo.currentResumeTime = skillInfo.nSectionResumeTime
stSkillInfo.currentUseTimeHint = skillInfo.nUseTimeHint
stSkillInfo.energy = skillInfo.nEnergy
if tbSkillInfos[skillInfo.nCharId] == nil then
tbSkillInfos[skillInfo.nCharId] = {}
end
table.insert(tbSkillInfos[skillInfo.nCharId], stSkillInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorSkillInfo, tbSkillInfos)
end
if self.mapCharacterTempData.buffInfo ~= nil then
local tbBuffinfo = {}
for nCharId, mapBuff in pairs(self.mapCharacterTempData.buffInfo) do
if mapBuff.mapBuff ~= nil then
for _, mapBuffInfo in pairs(mapBuff.mapBuff) do
local stBuffInfo = CS.Lua2CSharpInfo_ResetBuffInfo()
stBuffInfo.Id = mapBuffInfo.Id
stBuffInfo.Cd = mapBuffInfo.CD
stBuffInfo.buffNum = mapBuffInfo.nNum
if tbBuffinfo[nCharId] == nil then
tbBuffinfo[nCharId] = {}
end
table.insert(tbBuffinfo[nCharId], stBuffInfo)
end
end
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetBuff, tbBuffinfo)
end
end
function MainlineBattleLevel:OnEvent_SendMsgFinishBattle(LevelResult, _doorIdx, FadeTime)
if self.bSettle == true then
print("已在结算流程中!")
return
end
self.bSettle = true
print("OnEvent_SendMsgFinishBattle")
local fadeT = 0
if FadeTime ~= nil then
fadeT = FadeTime
end
if LevelResult == AllEnum.LevelResult.Failed then
self:OnEvent_AbandonBattle()
return
end
local mapMainline
if PlayerData.Mainline.bUseOldMainline then
mapMainline = ConfigTable.GetData_Mainline(self._nSelectId)
else
mapMainline = ConfigTable.GetData_Story(self._nSelectId)
end
if self.curFloorIdx < #mapMainline.FloorId then
self:ChangeFloor()
return
end
local nStar = 1
local nMainlineId = self._nSelectId
if PlayerData.Mainline.bUseOldMainline then
if #self._tbBoxS == self.curSmallCount then
nStar = nStar | 2
end
if #self._tbBoxL == self.curLargeCount then
nStar = nStar | 4
end
end
local func_cbFinishSucc = function(_, mapMainData)
local nLevelStar = 0
if PlayerData.Mainline.bUseOldMainline then
self.parent:UpdateMainlineStar(self._nSelectId, nStar)
nLevelStar = self.parent:GetMianlineLevelStar(nMainlineId)
end
local function func_AvgEnd()
EventManager.Remove("StoryDialog_DialogEnd", self, func_AvgEnd)
local sLarge, sSmall = self:CalChestInfo()
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, true, nLevelStar, mapMainData.GenerRewardItems or {}, mapMainData.FirstRewardItems or {}, mapMainData.ChestRewardItems or {}, mapMainData.Exp or 0, false, sLarge, sSmall, nMainlineId, self.tbChar, mapMainData.Change)
self:UnBindEvent()
self.parent:LevelEnd()
end
local sAvgId = PlayerData.Mainline:GetAfterBattleAvg()
if sAvgId then
EventManager.Add("StoryDialog_DialogEnd", self, func_AvgEnd)
EventManager.Hit("StoryDialog_DialogStart", sAvgId)
elseif PlayerData.Mainline.bUseOldMainline then
self:PlaySuccessPerform(mapMainData.GenerRewardItems, mapMainData.FirstRewardItems, mapMainData.ChestRewardItems, mapMainData.Exp, nLevelStar, fadeT, mapMainData.Change)
else
self:PlaySuccessPerform()
end
end
local Events = PlayerData.Achievement:GetBattleAchievement(GameEnum.levelType.Mainline, true)
local mapSendMsg = {}
mapSendMsg.Ok = true
mapSendMsg.MinChests = self._tbOpendChestS
mapSendMsg.MaxChests = self._tbOpendChestL
if 0 < #Events then
mapSendMsg.Events = {
List = {}
}
mapSendMsg.Events.List = Events
end
print("====== 当前通关主线关卡ID" .. self._nSelectId .. " ======")
if PlayerData.Mainline.bUseOldMainline then
HttpNetHandler.SendMsg(NetMsgId.Id.mainline_settle_req, mapSendMsg, nil, func_cbFinishSucc)
else
PlayerData.Avg:SendMsg_STORY_DONE(func_cbFinishSucc)
end
end
function MainlineBattleLevel:OnEvent_AbandonBattle()
if self._nSelectId > 0 then
local nStar = PlayerData.Mainline:GetMianlineLevelStar(self._nSelectId)
if 0 < nStar then
if #self._tbBoxS == self.curSmallCount then
nStar = 3
end
if #self._tbBoxL == self.curLargeCount then
nStar = nStar | 4
end
end
local func_cbExitSucc = function(_, mapMainData)
local nMainlineId = self._nSelectId
local sLarge, sSmall = self:CalChestInfo()
self.parent:UpdateMainlineStar(self._nSelectId, nStar)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, false, 0, mapMainData.GenerRewardItems or {}, mapMainData.FirstRewardItems or {}, mapMainData.ChestRewardItems or {}, mapMainData.Exp or 0, false, sLarge, sSmall, nMainlineId, self.tbChar, mapMainData.Change)
self:UnBindEvent()
self.parent:LevelEnd()
end
local mapSendMsg = {}
mapSendMsg.MinChests = self._tbOpendChestS
mapSendMsg.MaxChests = self._tbOpendChestL
HttpNetHandler.SendMsg(NetMsgId.Id.mainline_exit_req, mapSendMsg, nil, func_cbExitSucc)
end
end
function MainlineBattleLevel:CalChestInfo()
local sSmall, sLarge
if self.bNewSmall then
sSmall = string.format("<color=#4ee5d1>%d</color>/%d", self.curSmallCount, self.nSmallTotalCount)
else
sSmall = string.format("%d/%d", self.curSmallCount, self.nSmallTotalCount)
end
if self.bNewLarge then
sLarge = string.format("<color=#4ee5d1>%d</color>/%d", self.curLargeCount, self.nLargeTotalCount)
else
sLarge = string.format("%d/%d", self.curLargeCount, self.nLargeTotalCount)
end
if self.nSmallTotalCount == 0 then
sSmall = ""
end
if self.nLargeTotalCount == 0 then
sLarge = ""
end
return sLarge, sSmall
end
function MainlineBattleLevel:ChangeFloor()
self:CacheTempData()
local mapMainline = ConfigTable.GetData_Mainline(self._nSelectId)
self.curFloorIdx = self.curFloorIdx + 1
local function levelUnloadCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
if self.bTrialLevel then
for _, nTrialId in ipairs(self.tbTrialId) do
if 0 < nTrialId then
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
local stActorInfo, nHeartStoneLevel = self.CalCharFixedEffectTrial(nTrialId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, mapTrialChar.nId, stActorInfo)
end
end
else
for idx, nCharId in ipairs(self.tbChar) do
local stActorInfo, nHeartStoneLevel = self.CalCharFixedEffect(nCharId, idx == 1)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
self:SetCharStatus()
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
CS.AdventureModuleHelper.EnterMainlineMap(mapMainline.FloorId[self.curFloorIdx], self.tbChar, self.tbOpenedChestId)
CS.AdventureModuleHelper.LevelStateChanged(false)
self.bSettle = false
end
function MainlineBattleLevel:SetCharStatus()
local nStatus = 0
local nStatusTime = 0
local tbActorInfo = {}
for _, nTid in pairs(self.tbChar) do
local stCharInfo = CS.Lua2CSharpInfo_ActorStatus()
if self.mapCharacterTempData.stateInfo ~= nil and self.mapCharacterTempData.stateInfo[nTid] ~= nil then
nStatus = self.mapCharacterTempData.stateInfo[nTid].nState
nStatusTime = self.mapCharacterTempData.stateInfo[nTid].nStateTime
end
stCharInfo.actorID = nTid
stCharInfo.status = nStatus
stCharInfo.specialStatusTime = nStatusTime
table.insert(tbActorInfo, stCharInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.SetActorStatus, tbActorInfo)
end
function MainlineBattleLevel:OnEvent_Time(nTime)
self.nMainLineTime = nTime
end
function MainlineBattleLevel:OnEvnet_Pause()
EventManager.Hit(EventId.OpenPanel, PanelId.MainBattlePause, self.nMainLineTime or 0)
end
function MainlineBattleLevel:OnEvent_AdventureModuleEnter()
EventManager.Hit(EventId.OpenPanel, PanelId.Adventure, self.tbChar)
end
return MainlineBattleLevel
@@ -0,0 +1,470 @@
local MainlinePrologueLevel = class("MainlinePrologueLevel")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local LocalData = require("GameCore.Data.LocalData")
local RapidJson = require("rapidjson")
local mapFloor = {
[1] = "Game.Adventure.MainlineLevel.PrologueFloor.DesertFloor",
[2] = "Game.Adventure.MainlineLevel.PrologueFloor.BattleFloor"
}
local mapEventConfig = {
LevelStateChanged = "OnEvent_LevelStateChanged",
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
ExitModule = "OnEvent_ExitModule",
AfterEnterModule = "OnEvent_AfterEnterModule",
PrologueBattleReload = "OnEvent_PrologueBattleReload",
PrologueBattleArchive = "OnEvent_PrologueBattleArchive",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
EnterModule = "OnEvent_EnterModule"
}
local enterFloorForTest = 0
local PrologueSceneId = 1200103
local tbAfterDesertFloor = {1200104, 1200106}
local tbTrialCharacter = {
{
1200201,
1200203,
1200202
},
{
1200201,
1200203,
1200202
}
}
local tbSelectPerks = {
{
500501,
500801,
500101
}
}
local mapBoxReward = {
[1] = {
500501,
500801,
500101
}
}
local tbTheme = {
GameEnum.rglTheme.ChainLightning,
GameEnum.rglTheme.WindBlade,
GameEnum.rglTheme.FireRing
}
function MainlinePrologueLevel:Init(parent)
self.curFloor = nil
self.sAfterBattleAvg = "ST1001"
local lastAccount = LocalData.GetLocalData("LoginUIData", "LastUserName_All")
local sJson = LocalData.GetLocalData(lastAccount, "MainlinePrologueLevel")
if sJson ~= nil then
local tb = decodeJson(sJson)
self.isThreePlayer = tb.isThreePlayer
self.revivalPoint = Vector3(tb.revivalPoint[1], tb.revivalPoint[2], tb.revivalPoint[3])
self.btnNames = tb.btnNames
self.tbSelectPerks = tb.tbSelectPerks
self.curFloorIdx = tb.curFloorIdx
self.bDesertComplete = tb.bDesertComplete
self.nCurAvgCmdIdx = tb.nCurAvgCmdIdx
self.bBattleEnd = tb.bBattleEnd
self.curCharId = tb.curCharId
self.curNpcRewardIdx = tb.curNpcRewardIdx
self.nBoxId = tb.nBoxId
else
self.isThreePlayer = false
self.revivalPoint = Vector3.zero
self.btnNames = nil
self.tbSelectPerks = {}
self.curFloorIdx = 1
self.bDesertComplete = false
self.nCurAvgCmdIdx = 0
self.bBattleEnd = false
self.curCharId = 0
self.curNpcRewardIdx = 1
self.nBoxId = 0
end
EventManager.Hit("MainlinePrologueLevelNextModule", self)
self:BindEvent()
self.parent = parent
self.bSettle = false
self.tbTrialId = {}
self.tbChar = {}
if not self.bDesertComplete then
CS.AdventureModuleHelper.EnterProloguelMap(PrologueSceneId)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
elseif self.bBattleEnd then
self:OnEvent_LevelStateChanged()
else
if #tbTrialCharacter[self.curFloorIdx] > 0 then
PlayerData.Char:CreateTrialChar(tbTrialCharacter[self.curFloorIdx])
for _, nTrialId in pairs(tbTrialCharacter[self.curFloorIdx]) do
if 0 < nTrialId then
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
table.insert(self.tbChar, mapTrialChar.nId)
table.insert(self.tbTrialId, nTrialId)
end
end
end
for _, nTrialId in ipairs(self.tbTrialId) do
if 0 < nTrialId then
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
local tbstInfo, stActorInfo, nHeartStoneLevel = self.CalCharFixedEffectTrial(nTrialId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, mapTrialChar.nId, stActorInfo)
end
end
self:SetFloor(2)
CS.AdventureModuleHelper.EnterProloguelBattleMap(tbAfterDesertFloor[self.curFloorIdx], self.tbChar, {}, self.isThreePlayer, self.revivalPoint, self.btnNames)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
end
function MainlinePrologueLevel:SetLocalData()
local mapLocalData = {
isThreePlayer = self.isThreePlayer,
revivalPoint = {
self.revivalPoint.x,
self.revivalPoint.y,
self.revivalPoint.z
},
btnNames = self.btnNames,
tbSelectPerks = self.tbSelectPerks,
curFloorIdx = self.curFloorIdx,
bDesertComplete = self.bDesertComplete,
nCurAvgCmdIdx = self.nCurAvgCmdIdx,
bBattleEnd = self.bBattleEnd,
curCharId = self.curCharId,
curNpcRewardIdx = self.curNpcRewardIdx,
nBoxId = self.nBoxId
}
local sJson = RapidJson.encode(mapLocalData)
local lastAccount = LocalData.GetLocalData("LoginUIData", "LastUserName_All")
LocalData.SetLocalData(lastAccount, "MainlinePrologueLevel", sJson)
end
function MainlinePrologueLevel:SetFloor(nType)
if self.curFloor ~= nil then
self.curFloor:Exit()
end
self.curFloor = nil
local luaPath = mapFloor[nType]
if luaPath == nil then
printError("no exist type:" .. nType)
luaPath = mapFloor[1]
end
local luaFile = require(luaPath)
local luaClass = luaFile.new(self)
luaClass:Enter()
self.curFloor = luaClass
end
function MainlinePrologueLevel:UnsetFloor()
if self.curFloor ~= nil then
self.curFloor:Exit()
end
self.curFloor = nil
end
function MainlinePrologueLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function MainlinePrologueLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function MainlinePrologueLevel.CalCharFixedEffectTrial(nTrialId)
local tbstInfo = {}
local tbEffectId = {}
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
local nHeartStoneLevel = PlayerData.Char:CalCharacterTrialAttrBattle(nTrialId, tbstInfo, stActorInfo)
return tbstInfo, stActorInfo, nHeartStoneLevel
end
function MainlinePrologueLevel:SetTheme()
safe_call_cs_func(CS.AdventureModuleHelper.SetRglTheme, tbTheme)
end
function MainlinePrologueLevel:SetThemePerk()
local tbThemePerkInfo = {}
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
for _, nPerkId in ipairs(self.tbSelectPerks) do
stPerkInfo.perkId = nPerkId
stPerkInfo.nCount = 1
table.insert(tbThemePerkInfo, stPerkInfo)
end
if 0 < #tbThemePerkInfo then
safe_call_cs_func(CS.AdventureModuleHelper.ChangeThemePerkIds, tbThemePerkInfo)
end
end
function MainlinePrologueLevel:GetRewardNpc(nNpcId, nNpcUid)
local function SelectPerkCallBack(_, tbResult)
EventManager.Remove(EventId.SelectPerk, self, SelectPerkCallBack)
self.curNpcRewardIdx = self.curNpcRewardIdx + 1
table.insert(self.tbSelectPerks, tbResult[1])
local tbThemePerkInfo = {}
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = tbResult[1]
stPerkInfo.nCount = 1
table.insert(tbThemePerkInfo, stPerkInfo)
safe_call_cs_func(CS.AdventureModuleHelper.ChangeThemePerkIds, tbThemePerkInfo)
local mapNpc = ConfigTable.GetData("NPC", nNpcId)
if mapNpc.completeDestroy then
safe_call_cs_func(CS.InteractiveManager.Instance.setInteractiveNpcState, CS.InteractiveManager.Instance, nNpcUid)
end
NovaAPI.DispatchEventWithData("PROLOGUELEVEL_SELECTPERK")
end
if tbSelectPerks[self.curNpcRewardIdx] == nil then
printError(string.format("没有第%d个奖励", self.curNpcRewardIdx))
return
end
local tbPerks = {}
for _, nPerkId in ipairs(tbSelectPerks[self.curNpcRewardIdx]) do
table.insert(tbPerks, {
Id = nPerkId,
Level = 1,
nMaxLevel = 3
})
end
local mapBag = {
mapPerk = {},
mapItem = {},
mapSlotPerk = {
[1] = {
nPerkId = 0,
nQty = 0,
nMaxLevel = 0
},
[2] = {
nPerkId = 0,
nQty = 0,
nMaxLevel = 0
},
[3] = {
nPerkId = 0,
nQty = 0,
nMaxLevel = 0
},
[4] = {
nPerkId = 0,
nQty = 0,
nMaxLevel = 0
}
}
}
EventManager.Add(EventId.SelectPerk, self, SelectPerkCallBack)
EventManager.Hit(EventId.OpenPanel, PanelId.FRThemePerkSelect, {
{Perks = tbPerks, Theme = 0}
}, 0, mapBag, {}, true, true)
end
function MainlinePrologueLevel:GetRewardBox(nBoxId)
local function SelectPerkCallBack(_, tbResult)
EventManager.Remove(EventId.SelectPerk, self, SelectPerkCallBack)
self.curNpcRewardIdx = self.curNpcRewardIdx + 1
table.insert(self.tbSelectPerks, tbResult[1])
local tbThemePerkInfo = {}
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = tbResult[1]
stPerkInfo.nCount = 1
table.insert(tbThemePerkInfo, stPerkInfo)
safe_call_cs_func(CS.AdventureModuleHelper.ChangeThemePerkIds, tbThemePerkInfo)
local mapNpc = ConfigTable.GetData("NPC", nNpcId)
if mapNpc.completeDestroy then
safe_call_cs_func(CS.InteractiveManager.Instance.setInteractiveNpcState, CS.InteractiveManager.Instance, nNpcUid)
end
NovaAPI.DispatchEventWithData("PROLOGUELEVEL_SELECTPERK")
end
if mapBoxReward[self.nBoxId] == nil then
printError(string.format("没有配置宝箱id为%d的奖励", self.nBoxId))
return
end
local tbPerks = {}
for _, nPerkId in ipairs(mapBoxReward[self.nBoxId]) do
table.insert(tbPerks, {
Id = nPerkId,
Level = 1,
nMaxLevel = 3
})
end
local mapBag = {
mapPerk = {},
mapItem = {},
mapSlotPerk = {
[1] = {
nPerkId = 0,
nQty = 0,
nMaxLevel = 0
},
[2] = {
nPerkId = 0,
nQty = 0,
nMaxLevel = 0
},
[3] = {
nPerkId = 0,
nQty = 0,
nMaxLevel = 0
},
[4] = {
nPerkId = 0,
nQty = 0,
nMaxLevel = 0
}
}
}
EventManager.Add(EventId.SelectPerk, self, SelectPerkCallBack)
EventManager.Hit(EventId.OpenPanel, PanelId.FRThemePerkSelect, {
{Perks = tbPerks, Theme = 0}
}, 0, mapBag, {}, true, true)
end
function MainlinePrologueLevel:OnEvent_LevelStateChanged()
self.bDesertComplete = true
if 0 < #tbAfterDesertFloor and #tbAfterDesertFloor > self.curFloorIdx and not self.bBattleEnd then
self:ChangeFloor()
return
end
local function func_AvgEnd()
EventManager.Remove("StoryDialog_DialogEnd", self, func_AvgEnd)
NovaAPI.EnterModule("MainMenuModuleScene", true)
self.parent:LevelEnd()
end
local function UnloadCallback()
CS.GameCameraStackManager.Instance:CloseMainCamera(0.1)
CS.ClientManager.Instance:CloseLoadingView(nil)
PlayerData.Char:DeleteTrialChar()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, UnloadCallback)
local ModuleManager = require("GameCore.Module.ModuleManager")
if ModuleManager.GetIsAdventure() then
NovaAPI.InputDisable()
end
if self.sAfterBattleAvg ~= "" then
self.bBattleEnd = true
self:SetLocalData()
EventManager.Add("StoryDialog_DialogEnd", self, func_AvgEnd)
EventManager.Hit("StoryDialog_DialogStart", self.sAfterBattleAvg, nil, self.nCurAvgCmdIdx)
else
func_AvgEnd()
end
end
self:UnsetFloor()
local ModuleManager = require("GameCore.Module.ModuleManager")
if ModuleManager.GetIsAdventure() then
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, UnloadCallback)
CS.AdventureModuleHelper.LevelStateChanged(true)
NovaAPI.InputDisable()
else
UnloadCallback()
end
end
function MainlinePrologueLevel:OnEvent_ExitModule(_, sEnterModuleName)
end
function MainlinePrologueLevel:OnEvent_AfterEnterModule(sEnterModuleName)
if sEnterModuleName == "EmptyModuleScene" then
local wait = function()
self.bDesertComplete = true
self:SetLocalData()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
self.tbChar = {}
self.tbTrialId = {}
if #tbTrialCharacter[self.curFloorIdx] > 0 then
PlayerData.Char:CreateTrialChar(tbTrialCharacter[self.curFloorIdx])
for _, nTrialId in pairs(tbTrialCharacter[self.curFloorIdx]) do
if 0 < nTrialId then
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
table.insert(self.tbChar, mapTrialChar.nId)
table.insert(self.tbTrialId, nTrialId)
end
end
end
for _, nTrialId in ipairs(self.tbTrialId) do
if 0 < nTrialId then
local mapTrialChar = PlayerData.Char:GetTrialCharById(nTrialId)
local tbstInfo, stActorInfo, nHeartStoneLevel = self.CalCharFixedEffectTrial(nTrialId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, mapTrialChar.nId, stActorInfo)
end
end
self:SetFloor(2)
CS.AdventureModuleHelper.EnterProloguelBattleMap(tbAfterDesertFloor[self.curFloorIdx], self.tbChar, {}, self.isThreePlayer, self.revivalPoint, self.btnNames)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
cs_coroutine.start(wait)
EventManager.Hit(EventId.CloesCurPanel)
end
end
function MainlinePrologueLevel:OnEvent_PrologueBattleReload()
local function levelUnloadCallback()
NovaAPI.EnterModule("EmptyModuleScene", true)
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
CS.AdventureModuleHelper.LevelStateChanged(true)
end
function MainlinePrologueLevel:ChangeFloor()
local function levelUnloadCallback()
PlayerData.Char:DeleteTrialChar()
self.curFloorIdx = self.curFloorIdx + 1
NovaAPI.EnterModule("EmptyModuleScene", true)
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
self.btnNames = {}
self.revivalPoint = Vector3.zero
self:SetLocalData()
end
local id = CS.AdventureModuleHelper.GetCurrentActivePlayer()
self.curCharId = CS.AdventureModuleHelper.GetCharacterId(id)
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
self:UnsetFloor()
CS.AdventureModuleHelper.LevelStateChanged(true)
end
function MainlinePrologueLevel:OnEvent_LoadLevelRefresh()
if self.curFloorIdx > 0 then
for _, nTrialId in ipairs(self.tbTrialId) do
if 0 < nTrialId then
local tbstInfo, stActorInfo, nHeartStoneLevel = self.CalCharFixedEffectTrial(nTrialId)
end
end
end
end
function MainlinePrologueLevel:OnEvent_PrologueBattleArchive(isThreePlayer, revivalPoint, btnNames, nCmdId, nBoxId)
if nCmdId == -1 then
local lastAccount = LocalData.GetLocalData("LoginUIData", "LastUserName_All")
LocalData.SetLocalData(lastAccount, "MainlinePrologueLevel", "")
end
self.nBoxId = nBoxId
if isThreePlayer == nil then
end
self.isThreePlayer = isThreePlayer
self.revivalPoint = revivalPoint == nil and Vector3.zero or revivalPoint
btnNames = btnNames == nil and {
[0] = "",
Count = 1
} or btnNames
self.nCurAvgCmdIdx = nCmdId
local tbNames = {}
local nCount = btnNames.Count - 1
for i = 0, nCount do
table.insert(tbNames, btnNames[i])
end
self.btnNames = tbNames
self:SetLocalData()
end
function MainlinePrologueLevel:OnEvent_AdventureModuleEnter()
if self.bDesertComplete then
self:SetTheme()
self:SetThemePerk()
EventManager.Hit(EventId.OpenPanel, PanelId.Hud)
end
end
function MainlinePrologueLevel:OnEvent_EnterModule()
if not self.bDesertComplete then
EventManager.Hit(EventId.OpenPanel, PanelId.Prologue, self.tbChar)
else
EventManager.Hit(EventId.OpenPanel, PanelId.PrologueAdventurePanel, self.tbChar)
end
end
return MainlinePrologueLevel
@@ -0,0 +1,164 @@
local PreviewLevel = class("PreviewLevel")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
BattlePause = "OnEvent_AbandonBattle",
LevelStateChanged = "OnEvent_LevelResult",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter"
}
function PreviewLevel:Init(nLevelType, nLevelId, bView, nStarTowerFloorSetId, nPrefabID, nPrefabExtension, nPlayType, nSceneMir, parent)
self.parent = parent
self.tbCharId = PlayerData.Team:GetTeamCharId(1)
self.nLevelType = nLevelType
self.nLevelId = nLevelId
self:BindEvent()
CS.AdventureModuleHelper.EnterViewSceneLevel(nLevelType, nLevelId, self.tbCharId, bView, nStarTowerFloorSetId, nPrefabID, nPrefabExtension, nPlayType, nSceneMir)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
function PreviewLevel:OnEvent_LoadLevelRefresh()
end
function PreviewLevel:OnEvent_LevelResult(nState)
self:PlaySuccessPerform({}, {}, 3)
end
function PreviewLevel:OnEvent_AbandonBattle()
self:OnEvent_LevelResult(true, 0)
end
function PreviewLevel:OnEvent_AdventureModuleEnter()
EventManager.Hit(EventId.OpenPanel, PanelId.Adventure, self.tbCharId)
self:SetTheme()
for _, value in ipairs(self.tbCharId) do
self:SetTempActorAttribute(value)
end
end
function PreviewLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function PreviewLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function PreviewLevel:PlaySuccessPerform()
local func_OpenResult = function(bSuccess)
end
local tbChar = self.tbCharId
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local sName = ""
if self.nLevelType == GameEnum.worldLevelType.Mainline then
local nType = ConfigTable.GetData("MainlineFloor", self.nLevelId).Theme
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
elseif self.nLevelType == GameEnum.worldLevelType.RegionBoss then
local nType = ConfigTable.GetData("RegionBossFloor", self.nLevelId).Theme
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
elseif self.nLevelType == GameEnum.worldLevelType.TravelerDuel then
local nType = ConfigTable.GetData("TravelerDuelFloor", self.nLevelId).Theme
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
elseif self.nLevelType == GameEnum.worldLevelType.DailyInstance then
local nType = ConfigTable.GetData("DailyInstanceFloor", self.nLevelId).Theme
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
else
local nType = ConfigTable.GetData("StarTowerMap", self.nLevelId).Theme
sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
end
local jumpPerform = function()
NovaAPI.DispatchEventWithData("SKIP_SETTLEMENT_PERFORM")
end
EventManager.Hit(EventId.OpenPanel, PanelId.BtnTips, jumpPerform)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, true, 3, {}, {}, {}, 0, false, sLarge, sSmall, 13001, self.tbCharId)
self.bSettle = false
self.parent:LevelEnd()
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_OpenResult)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
CS.AdventureModuleHelper.LevelStateChanged(true)
end
function PreviewLevel:SetTempActorAttribute(nCharId)
local mapChar = {nLevel = 1, nAdvance = 0}
local nLevel = mapChar.nLevel
local nAdvance = mapChar.nAdvance
local nAttrId = UTILS.GetCharacterAttributeId(nCharId, nAdvance, nLevel)
local mapCharAttr = ConfigTable.GetData_Attribute(tostring(nAttrId))
if mapCharAttr == nil then
printError("属性配置不存在:" .. nAttrId)
return {}
end
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
stActorInfo.Atk = mapCharAttr.Atk
stActorInfo.Def = mapCharAttr.Def
stActorInfo.MDef = mapCharAttr.Mdef
stActorInfo.ShieldBonus = mapCharAttr.ShieldBonus
stActorInfo.IncomingShieldBonus = mapCharAttr.IncomingShieldBonus
stActorInfo.Evd = mapCharAttr.Evd
stActorInfo.CritRate = mapCharAttr.CritRate
stActorInfo.CritResistance = mapCharAttr.CritResistance
stActorInfo.CritPower = mapCharAttr.CritPower
stActorInfo.HitRate = mapCharAttr.HitRate
stActorInfo.DefPierce = mapCharAttr.DefPierce
stActorInfo.WEE = mapCharAttr.WEE
stActorInfo.FEE = mapCharAttr.FEE
stActorInfo.SEE = mapCharAttr.SEE
stActorInfo.AEE = mapCharAttr.AEE
stActorInfo.LEE = mapCharAttr.LEE
stActorInfo.DEE = mapCharAttr.DEE
stActorInfo.WEP = mapCharAttr.WEP
stActorInfo.FEP = mapCharAttr.FEP
stActorInfo.AEP = mapCharAttr.AEP
stActorInfo.SEP = mapCharAttr.SEP
stActorInfo.LEP = mapCharAttr.LEP
stActorInfo.DEP = mapCharAttr.DEP
stActorInfo.WER = mapCharAttr.WER
stActorInfo.FER = mapCharAttr.FER
stActorInfo.AER = mapCharAttr.AER
stActorInfo.SER = mapCharAttr.SER
stActorInfo.LER = mapCharAttr.LER
stActorInfo.DER = mapCharAttr.DER
stActorInfo.Hp = mapCharAttr.Hp
stActorInfo.Suppress = mapCharAttr.Suppress
stActorInfo.SkillLevel = {
1,
1,
1
}
stActorInfo.skinId = PlayerData.Char:GetCharSkinId(nCharId)
stActorInfo.attrId = mapCharAttr.sAttrId
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
function PreviewLevel:SetCharFixedAttribute()
for nCharId, mapInfo in pairs(self.mapActorInfo) do
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, mapInfo.stActorInfo)
end
end
function PreviewLevel.CalCharFixedEffect(nCharId, bMainChar)
local tbstInfo = {}
local stActorInfo = {}
local nHeartStoneLevel = 1
return tbstInfo, stActorInfo, nHeartStoneLevel
end
function PreviewLevel:SetTheme()
end
return PreviewLevel
@@ -0,0 +1,33 @@
local BasePrologueFloor = class("BasePrologueFloor")
function BasePrologueFloor:ctor(parentData)
self.parent = parentData
end
function BasePrologueFloor:Enter()
self:_BindEventCallback()
end
function BasePrologueFloor:_BindEventCallback()
if type(self._mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(self._mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function BasePrologueFloor:_UnbindEventCallback()
if type(self._mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(self._mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function BasePrologueFloor:Exit()
self:_UnbindEventCallback()
end
return BasePrologueFloor
@@ -0,0 +1,21 @@
local BaseFloor = require("Game.Adventure.MainlineLevel.PrologueFloor.BasePrologueFloor")
local BattleFloor = class("BattleFloor", BaseFloor)
BattleFloor._mapEventConfig = {
InteractiveNpc = "OnEvent_InteractiveNpc",
InteractiveBoxGet = "OnEvent_InteractiveBoxGet"
}
function BattleFloor:OnEvent_InteractiveNpc(nNpcId, nNpcUid)
local mapNpc = ConfigTable.GetData("NPC", nNpcId)
if mapNpc == nil then
print("NPC不存在" .. nNpcId)
return
end
if mapNpc.type ~= GameEnum.npcType.PrologueReward then
return
end
self.parent:GetRewardNpc(nNpcId, nNpcUid)
end
function BattleFloor:OnEvent_InteractiveBox(nBoxId, _, _, _)
self.parent:GetRewardBox(nBoxId)
end
return BattleFloor
@@ -0,0 +1,4 @@
local BaseFloor = require("Game.Adventure.MainlineLevel.PrologueFloor.BasePrologueFloor")
local DesertFloor = class("DesertFloor", BaseFloor)
DesertFloor._mapEventConfig = {}
return DesertFloor
@@ -0,0 +1,305 @@
local RegionBossBattleLevel = class("RegionBossBattleLevel")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local AdventureModuleHelper = CS.AdventureModuleHelper
local TimerManager = require("GameCore.Timer.TimerManager")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
Region_Boss_Result = "LevelResultChange",
BattlePause = "OnEvnet_Pause"
}
function RegionBossBattleLevel:Init(parent, nLevelId, nBuildId, isWeekBoss)
self.parent = parent
self.nLevelId = nLevelId
self.nBuildId = nBuildId
self.isSettlement = false
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.tbCharId = {}
if mapBuildData == nil then
local sTip = ConfigTable.GetUIText("RegionBoss_Team_Delete")
EventManager.Hit(EventId.OpenMessageBox, sTip)
return
end
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
self.mapActorInfo = {}
for idx, nTid in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
self.mapActorInfo[nTid] = stActorInfo
end
local nFloorId = 0
if isWeekBoss == 1 then
PlayerData.RogueBoss:SetIsWeeklyCopies(false)
nFloorId = ConfigTable.GetData("RegionBossLevel", nLevelId).FloorId
elseif isWeekBoss == 2 then
PlayerData.RogueBoss:SetIsWeeklyCopies(true)
nFloorId = ConfigTable.GetData("WeekBossLevel", nLevelId).FloorId
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.Rogueboss
CS.AdventureModuleHelper.EnterRogueBossMap(nFloorId, self.tbCharId, nLevelId, 0, isWeekBoss)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
self.nResultTime = 0
end
function RegionBossBattleLevel:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function RegionBossBattleLevel:SettleRegionBoss(isWin)
if self.isSettlement then
return
end
self.isSettlement = true
self:RefreshCharDamageData()
local isWeeklyCopies = PlayerData.RogueBoss:GetIsWeeklyCopies()
print("is week " .. tostring(isWeeklyCopies))
if isWeeklyCopies then
local callback = function(mapMsgData, nPassStar)
local nExp = 0
local CacheRewardTab = {}
for i, v in ipairs(mapMsgData.FirstItems) do
v.rewardType = AllEnum.RewardType.First
table.insert(CacheRewardTab, v)
end
for i, v in ipairs(mapMsgData.AwardItems) do
table.insert(CacheRewardTab, v)
end
if isWin then
self:PlaySuccessPerform(ConfigTable.GetData("WeekBossLevel", self.nLevelId).FloorId, self.nBuildId, nExp, CacheRewardTab, mapMsgData.Change, true)
else
EventManager.Hit(EventId.OpenPanel, PanelId.RogueBossResult, 2, self.nResultTime, self.nBuildId, nExp, CacheRewardTab, mapMsgData.Change, self.tbCharDamage)
end
self:UnBindEvent()
self.parent:LevelEnd()
end
self.parent:WeeklyCopiesLevelSettleReq(isWin, self.nResultTime, callback)
else
local callback = function(mapMsgData, nPassStar)
self.passStar = nPassStar
local nExp = mapMsgData.Exp
local CacheRewardTab = {}
for i, v in ipairs(mapMsgData.FirstItems) do
v.rewardType = AllEnum.RewardType.First
table.insert(CacheRewardTab, v)
end
for i, v in ipairs(mapMsgData.ThreeStarItems) do
v.rewardType = AllEnum.RewardType.Three
table.insert(CacheRewardTab, v)
end
for i, v in ipairs(mapMsgData.SurpriseItems) do
v.rewardType = AllEnum.RewardType.Extra
table.insert(CacheRewardTab, v)
end
for i, v in ipairs(mapMsgData.AwardItems) do
table.insert(CacheRewardTab, v)
end
if isWin then
self:PlaySuccessPerform(ConfigTable.GetData("RegionBossLevel", self.nLevelId).FloorId, self.nBuildId, nExp, CacheRewardTab, mapMsgData.Change, false)
else
EventManager.Hit(EventId.OpenPanel, PanelId.BossInstanceResultPanel, false, 0, CacheRewardTab, nExp, self.nLevelId, self.tbCharId, mapMsgData.Change, self.tbCharDamage)
end
self:UnBindEvent()
self.parent:LevelEnd()
end
self.parent:RegionBossLevelSettleReq(isWin, self.nResultTime, callback)
end
end
function RegionBossBattleLevel:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
end
function RegionBossBattleLevel:OnEvent_AbandonBattle()
self:SettleRegionBoss(false)
end
function RegionBossBattleLevel:OnEvent_AdventureModuleEnter()
local isWeeklyCopies = PlayerData.RogueBoss:GetIsWeeklyCopies()
if isWeeklyCopies then
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.WeeklyCopies)
else
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.RegionBoss)
end
EventManager.Hit(EventId.OpenPanel, PanelId.RegionBossBattlePanel, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function RegionBossBattleLevel:OnEvent_OpenChest()
local wait = function()
self:SettleRegionBoss(true)
end
TimerManager.Add(1, 1, self, wait, true, true, true, nil)
end
function RegionBossBattleLevel:LevelResultChange(isWin, totaltime)
self.nResultTime = totaltime
self:SettleRegionBoss(isWin)
end
function RegionBossBattleLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function RegionBossBattleLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function RegionBossBattleLevel:PlaySuccessPerform(nMapId, buildId, nExp, tbReward, mapChangeInfo, isWeekBoss)
local func_SettlementFinish = function(bSuccess)
end
local tbChar = self.tbCharId
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
if isWeekBoss then
local nType = ConfigTable.GetData("WeekBossFloor", nMapId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
print("sceneName:" .. sName)
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
else
local nType = ConfigTable.GetData("RegionBossFloor", nMapId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
print("sceneName:" .. sName)
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
if self.passStar == nil then
self.passStar = 1
end
if isWeekBoss then
EventManager.Hit(EventId.OpenPanel, PanelId.RogueBossResult, 1, self.nResultTime, buildId, nExp, tbReward, mapChangeInfo, self.tbCharDamage)
else
EventManager.Hit(EventId.OpenPanel, PanelId.BossInstanceResultPanel, true, self.passStar, tbReward, nExp, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
end
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
CS.AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function RegionBossBattleLevel:SetTempActorAttribute(nCharId)
local mapChar = {nLevel = 1, nAdvance = 0}
local nLevel = mapChar.nLevel
local nAdvance = mapChar.nAdvance
local nAttrId = UTILS.GetCharacterAttributeId(nCharId, nAdvance, nLevel)
local mapCharAttr = ConfigTable.GetData_Attribute(tostring(nAttrId))
if mapCharAttr == nil then
printError("属性配置不存在:" .. nAttrId)
return {}
end
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
stActorInfo.Atk = mapCharAttr.Atk
stActorInfo.Def = mapCharAttr.Def
stActorInfo.MDef = mapCharAttr.Mdef
stActorInfo.ShieldBonus = mapCharAttr.ShieldBonus
stActorInfo.IncomingShieldBonus = mapCharAttr.IncomingShieldBonus
stActorInfo.Evd = mapCharAttr.Evd
stActorInfo.CritRate = mapCharAttr.CritRate
stActorInfo.CritResistance = mapCharAttr.CritResistance
stActorInfo.CritPower = mapCharAttr.CritPower
stActorInfo.HitRate = mapCharAttr.HitRate
stActorInfo.DefPierce = mapCharAttr.DefPierce
stActorInfo.WEE = mapCharAttr.WEE
stActorInfo.FEE = mapCharAttr.FEE
stActorInfo.SEE = mapCharAttr.SEE
stActorInfo.AEE = mapCharAttr.AEE
stActorInfo.LEE = mapCharAttr.LEE
stActorInfo.DEE = mapCharAttr.DEE
stActorInfo.WEP = mapCharAttr.WEP
stActorInfo.FEP = mapCharAttr.FEP
stActorInfo.AEP = mapCharAttr.AEP
stActorInfo.SEP = mapCharAttr.SEP
stActorInfo.LEP = mapCharAttr.LEP
stActorInfo.DEP = mapCharAttr.DEP
stActorInfo.WER = mapCharAttr.WER
stActorInfo.FER = mapCharAttr.FER
stActorInfo.AER = mapCharAttr.AER
stActorInfo.SER = mapCharAttr.SER
stActorInfo.LER = mapCharAttr.LER
stActorInfo.DER = mapCharAttr.DER
stActorInfo.Hp = mapCharAttr.Hp
stActorInfo.Suppress = mapCharAttr.Suppress
stActorInfo.SkillLevel = {
1,
1,
1
}
stActorInfo.skinId = PlayerData.Char:GetCharSkinId(nCharId)
stActorInfo.attrId = mapCharAttr.sAttrId
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
function RegionBossBattleLevel:SetCharFixedAttribute()
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function RegionBossBattleLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function RegionBossBattleLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function RegionBossBattleLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function RegionBossBattleLevel:OnEvnet_Pause()
EventManager.Hit("OpenRegionBossPause", self.nLevelId, self.tbCharId)
end
return RegionBossBattleLevel
@@ -0,0 +1,29 @@
local BossFloor = {}
function BossFloor:Init()
self.touchPortal = false
end
function BossFloor:OnRoguelikeEnter(PlayerRoguelikeData)
PlayerRoguelikeData:SetActorEffects()
PlayerRoguelikeData:ResetBoxCount()
PlayerRoguelikeData:ResetPerkEffect()
PlayerRoguelikeData:SetActorAttribute(false)
end
function BossFloor:OnTouchPortal(PlayerRoguelikeData)
if self.touchPortal then
return
end
self.touchPortal = true
PlayerRoguelikeData:CacheCharAttr()
PlayerRoguelikeData:SendSettleReq()
end
function BossFloor:SettleCallback(PlayerRoguelikeData)
PlayerRoguelikeData:FloorEnd()
end
function BossFloor:OnBossDied(PlayerRoguelikeData)
PlayerRoguelikeData:SyncKillBoss()
safe_call_cs_func(CS.AdventureModuleHelper.Lua2CSharp_RoguelikeOpenTeleporter)
end
function BossFloor:OnAbandon(PlayerRoguelikeData, bFailed)
PlayerRoguelikeData:AbandonRoguelike(bFailed)
end
return BossFloor
@@ -0,0 +1,21 @@
local TimerManager = require("GameCore.Timer.TimerManager")
local EditorFloor = {}
function EditorFloor:Init()
end
function EditorFloor:OnRoguelikeEnter(PlayerRoguelikeData)
PlayerRoguelikeData:SetActorEffects()
PlayerRoguelikeData:SetActorAttribute()
end
function EditorFloor:OnTouchPortal(PlayerRoguelikeData)
PlayerRoguelikeData:CacheCharAttr()
PlayerRoguelikeData:FloorEndEditor()
end
function EditorFloor:SettleCallback(PlayerRoguelikeData)
end
function EditorFloor:OnBossDied(PlayerRoguelikeData)
safe_call_cs_func(CS.AdventureModuleHelper.Lua2CSharp_RoguelikeOpenTeleporter)
end
function EditorFloor:OnAbandon(PlayerRoguelikeData)
PlayerRoguelikeData:FloorEndEditor()
end
return EditorFloor
@@ -0,0 +1,25 @@
local FirstFloor = {}
function FirstFloor:Init()
self._bStart = true
self.touchPortal = false
end
function FirstFloor:OnRoguelikeEnter(PlayerRoguelikeData)
PlayerRoguelikeData:SetActorEffects()
PlayerRoguelikeData:SetActorAttribute(true)
PlayerRoguelikeData:ResetBoxCount()
end
function FirstFloor:OnTouchPortal(PlayerRoguelikeData)
if self.touchPortal then
return
end
self.touchPortal = true
PlayerRoguelikeData:CacheCharAttr()
PlayerRoguelikeData:SendSettleReq()
end
function FirstFloor:SettleCallback(PlayerRoguelikeData)
PlayerRoguelikeData:FloorEnd()
end
function FirstFloor:OnAbandon(PlayerRoguelikeData, bFailed)
PlayerRoguelikeData:AbandonRoguelike(bFailed)
end
return FirstFloor
@@ -0,0 +1,25 @@
local NormalFloor = {}
function NormalFloor:Init()
self.touchPortal = false
end
function NormalFloor:OnRoguelikeEnter(PlayerRoguelikeData)
PlayerRoguelikeData:SetActorEffects()
PlayerRoguelikeData:SetActorAttribute(false)
PlayerRoguelikeData:ResetBoxCount()
PlayerRoguelikeData:ResetPerkEffect()
end
function NormalFloor:OnTouchPortal(PlayerRoguelikeData)
if self.touchPortal then
return
end
self.touchPortal = true
PlayerRoguelikeData:CacheCharAttr()
PlayerRoguelikeData:SendSettleReq()
end
function NormalFloor:SettleCallback(PlayerRoguelikeData)
PlayerRoguelikeData:FloorEnd()
end
function NormalFloor:OnAbandon(PlayerRoguelikeData, bFailed)
PlayerRoguelikeData:AbandonRoguelike(bFailed)
end
return NormalFloor
@@ -0,0 +1,26 @@
local RenterBossDiedFloor = {}
function RenterBossDiedFloor:Init()
self._bBossTalent = true
self.touchPortal = false
end
function RenterBossDiedFloor:OnRoguelikeEnter(PlayerRoguelikeData)
PlayerRoguelikeData:SetActorEffects()
PlayerRoguelikeData:SetActorAttribute(false)
PlayerRoguelikeData:ResetBoxCount()
PlayerRoguelikeData:ResetPerkEffect()
end
function RenterBossDiedFloor:OnTouchPortal(PlayerRoguelikeData)
if self.touchPortal then
return
end
self.touchPortal = true
PlayerRoguelikeData:CacheCharAttr()
PlayerRoguelikeData:SendSettleReq()
end
function RenterBossDiedFloor:SettleCallback(PlayerRoguelikeData)
PlayerRoguelikeData:FloorEnd()
end
function RenterBossDiedFloor:OnAbandon(PlayerRoguelikeData, bFailed)
PlayerRoguelikeData:AbandonRoguelike(bFailed)
end
return RenterBossDiedFloor
@@ -0,0 +1,282 @@
local ScoreBossLevel = class("ScoreBossLevel")
local LocalData = require("GameCore.Data.LocalData")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvent_Pause",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
ScoreBossLevelGameEnd = "OnEvent_LevelResult",
BossRush_Spawn_Id = "OnEvent_BossRushSpawnId",
ScoreBoss_Result_Time = "ScoreBossResultTime",
LevelStateChanged = "ScoreBossResult",
ScoreBoss_BehaviorScore = "OnEvent_ControlScore",
ScoreBossSettleSuccess = "OnEvent_ScoreBossSettleSuccess",
ScoreBossSettleGiveUp = "OnEvent_ScoreBossSettleGiveUp",
Upload_Dodge_Event = "OnEvent_UploadDodgeEvent"
}
function ScoreBossLevel:Init(parent, nLevelId, nBuildId)
self.isSettlement = false
self.parent = parent
self.LevelId = nLevelId
self.tmpBuildId = nBuildId
self.BossId = 0
self.BossMaxHp = 0
self.BossCurLvMinHp = -1
self.BossCurLvTotalChangeHp = 0
self.BattleLv = 1
self.nTime = 0
local leveData = ConfigTable.GetData("ScoreBossLevel", nLevelId)
if leveData == nil then
printError("ScoreBossLevel 表不存在 id ==== " .. nLevelId)
return
end
local getControlData = ConfigTable.GetData("ScoreBossGetControl", leveData.NonDamageScoreGet)
if getControlData == nil then
printError("ScoreBossGetControl 表不存在 id ==== " .. leveData.NonDamageScoreGet)
return
end
self.totalControlScore = 0
self.OnceControlScore = getControlData.OnceScore
self.MaxControlScore = getControlData.MaxLimit
self.ScoreBossBehavior = getControlData.ScoreBossBehavior
self.ScoreGetSwitchGroupId = leveData.ScoreGetSwitchGroup
self.SwitchRate = 300
local getSwitchData = ConfigTable.GetData("ScoreGetSwitch", self.ScoreGetSwitchGroupId * 1000 + 1)
if getSwitchData ~= nil then
self.SwitchRate = getSwitchData.SwitchRate
end
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.tbCharId = {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
self.mapActorInfo = {}
for idx, nTid in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
self.mapActorInfo[nTid] = stActorInfo
end
self.parent:CacheBuildCharTid(self.tbCharId)
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.ScoreBoss
CS.AdventureModuleHelper.EnterScoreBossFloor(self.LevelId, self.tbCharId)
local sKey = LocalData.GetPlayerLocalData("ScoreBossRecordKey")
safe_call_cs_func(CS.AdventureModuleHelper.SetDamageRecordId, sKey)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
end
function ScoreBossLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function ScoreBossLevel:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
PlayerData.Build:SetBuildReportInfo(self.mapBuildData.nBuildId)
end
function ScoreBossLevel:OnEvent_AdventureModuleEnter()
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.ScoreBoss)
EventManager.Hit(EventId.OpenPanel, PanelId.ScoreBossBattlePanel, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function ScoreBossLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function ScoreBossLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function ScoreBossLevel:OnEvent_Pause()
EventManager.Hit("OpenScoreBossPause", self.LevelId, self.tbCharId)
end
function ScoreBossLevel:OnEvent_AbandonBattle()
self.parent:QuiteLevel()
end
function ScoreBossLevel:OnEvent_LevelResult(tbStar, bAbandon)
self.parent:LevelEnd()
end
function ScoreBossLevel:OnEvent_BossRushSpawnId(bossId)
self.BossId = bossId
EventManager.AddEntityEvent("HpChanged", self.BossId, self, self.OnEvent_HpChanged)
EventManager.AddEntityEvent("BossRushMonsterLevelChanged", self.BossId, self, self.OnEvent_BossRushMonsterLevelChanged)
EventManager.AddEntityEvent("BossRushMonsterBattleAttrChanged", self.BossId, self, self.OnEvent_BossRushMonsterBattleAttrChanged)
end
function ScoreBossLevel:OnEvent_HpChanged(hp, hpMax)
if self.isSettlement then
return
end
if self.isDontChangeHp then
return
end
self.BossMaxHp = hpMax
if self.BossCurLvMinHp == -1 then
self.BossCurLvMinHp = hp
self.parent:DamageToScore(hpMax - hp, self.SwitchRate, self.BattleLv)
end
if hp < self.BossCurLvMinHp then
self.BossCurLvMinHp = hp
self.parent:DamageToScore(hpMax - hp, self.SwitchRate, self.BattleLv)
end
end
function ScoreBossLevel:OnEvent_BossRushMonsterLevelChanged(oldLevel, battleLevel)
if self.isSettlement then
return
end
self.isDontChangeHp = true
self.BossCurLvTotalChangeHp = self.BossCurLvTotalChangeHp + self.BossCurLvMinHp
self.BossCurLvMinHp = -1
self.BattleLv = battleLevel
self.parent:DamageToScore(self.BossMaxHp, self.SwitchRate, self.BattleLv)
self.BossCurLvTotalChangeHp = 0
if battleLevel <= 100 then
local getSwitchData = ConfigTable.GetData("ScoreGetSwitch", self.ScoreGetSwitchGroupId * 1000 + battleLevel)
if getSwitchData ~= nil then
self.SwitchRate = getSwitchData.SwitchRate
end
end
self.parent:HPLevelChanged()
end
function ScoreBossLevel:OnEvent_BossRushMonsterBattleAttrChanged()
self.isDontChangeHp = false
end
function ScoreBossLevel:ScoreBossResultTime(nTime)
self.nTime = nTime
end
function ScoreBossLevel:ScoreBossResult(levelState, totalTime)
if self.isSettlement then
return
end
self.isSettlement = true
self.parent:SendScoreBossSettleReq(self.nTime)
end
function ScoreBossLevel:PlaySuccessPerform(entryLevelId, totalScore, totalStar)
local tbChar = {}
self:RefreshCharDamageData()
for _, nCharId in ipairs(self.tbCharId) do
table.insert(tbChar, nCharId)
end
local func_SettlementFinish = function(bSuccess)
end
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nLevelData = ConfigTable.GetData("ScoreBossLevel", self.LevelId)
local nType = ConfigTable.GetData("ScoreBossFloor", nLevelData.FloorId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
print("sceneName:" .. sName)
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
EventManager.Hit(EventId.OpenPanel, PanelId.ScoreBossResult, entryLevelId, totalScore, totalStar, self.tbCharDamage)
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
CS.AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function ScoreBossLevel:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function ScoreBossLevel:OnEvent_ControlScore(Id, nBehavior)
if self.isSettlement then
return
end
if self.BossId == Id and nBehavior == self.ScoreBossBehavior and self.totalControlScore < self.MaxControlScore then
self.totalControlScore = self.totalControlScore + self.OnceControlScore
self.parent:BehaviorToScore(self.totalControlScore)
end
end
function ScoreBossLevel:OnEvent_ScoreBossSettleSuccess(entryLevelId, totalScore, totalStar)
self:PlaySuccessPerform(entryLevelId, totalScore, totalStar)
end
function ScoreBossLevel:OnEvent_ScoreBossSettleGiveUp(totalScore, totalStar)
self.parent:LevelEnd()
end
function ScoreBossLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function ScoreBossLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
if self.BossId then
EventManager.RemoveEntityEvent("HpChanged", self.BossId, self, self.OnEvent_HpChanged)
EventManager.RemoveEntityEvent("BossRushMonsterLevelChanged", self.BossId, self, self.OnEvent_BossRushMonsterLevelChanged)
EventManager.RemoveEntityEvent("BossRushMonsterBattleAttrChanged", self.BossId, self, self.OnEvent_BossRushMonsterBattleAttrChanged)
self.BossId = nil
end
end
function ScoreBossLevel:OnEvent_UploadDodgeEvent(padMode)
local tab = {}
table.insert(tab, {
"role_id",
tostring(PlayerData.Base._nPlayerId)
})
table.insert(tab, {"pad_mode", padMode})
table.insert(tab, {"level_type", "ScoreBoss"})
table.insert(tab, {
"build_id",
tostring(self.tmpBuildId)
})
table.insert(tab, {
"level_id",
tostring(self.LevelId)
})
table.insert(tab, {
"up_time",
tostring(CS.ClientManager.Instance.serverTimeStamp)
})
NovaAPI.UserEventUpload("use_dodge_key", tab)
end
return ScoreBossLevel
@@ -0,0 +1,194 @@
local SkillInstanceLevel = class("SkillInstanceLevel")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local AdventureModuleHelper = CS.AdventureModuleHelper
local TimerManager = require("GameCore.Timer.TimerManager")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
SkillInstanceGameEnd = "OnEvent_LevelResult",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvent_Pause"
}
function SkillInstanceLevel:Init(parent, nLevelId, nBuildId)
self.parent = parent
self.nLevelId = nLevelId
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.tbCharId = {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
self.mapActorInfo = {}
for idx, nTid in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nTid, idx == 1, self.tbDiscId)
self.mapActorInfo[nTid] = stActorInfo
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.SkillInstance
CS.AdventureModuleHelper.EnterSkillInstanceMap(nLevelId, self.tbCharId)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
end
function SkillInstanceLevel:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function SkillInstanceLevel:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
EventManager.Hit("OpenSkillInstanceRoomInfo", ConfigTable.GetData("SkillInstance", self.nLevelId).FloorId, self.nLevelId)
end
function SkillInstanceLevel:OnEvent_LevelResult(tbStar, bAbandon)
EventManager.Hit("SkillInstanceBattleEnd")
if self.parent:GetSettlementState() then
printError("技能素材副本结算流程重复进入,本次退出")
return
end
self:RefreshCharDamageData()
self.parent:SetSettlementState(true)
local mapDILevelCfgData = ConfigTable.GetData("SkillInstance", self.nLevelId)
local nStar = 0
local nStarCount = 0
nStar = tbStar[0] and 1 or nStar
nStar = tbStar[1] and 2 or nStar
nStar = tbStar[2] and 3 or nStar
for i = 0, 2 do
if tbStar[i] then
nStarCount = nStarCount + 1
end
end
local callback = function(tbStarReward, tbFirstReward, tbThreeStarItems, tbSurpriseItems, nExp, mapChangeInfo)
local waitCallback = function()
NovaAPI.InputEnable()
if 0 < nStar then
self:PlaySuccessPerform(tbFirstReward, tbStarReward, tbThreeStarItems, tbSurpriseItems, nExp, tbStar, mapChangeInfo)
else
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.SkillInstanceResult, false, tbStar, {}, {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, {}, self.tbCharDamage)
self.parent:LevelEnd()
end
end
EventManager.Hit("SkillInstanceLevelEnd", mapDILevelCfgData.FloorId)
if bAbandon then
waitCallback()
else
TimerManager.Add(1, 2, self, waitCallback, true, true, true, nil)
end
end
NovaAPI.InputDisable()
self.parent:MsgSettleSkillInstance(self.nLevelId, self.mapBuildData.nBuildId, nStar, callback)
end
function SkillInstanceLevel:OnEvent_AbandonBattle()
self:OnEvent_LevelResult({
false,
false,
false
}, true)
end
function SkillInstanceLevel:OnEvent_AdventureModuleEnter()
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.SkillInstance)
EventManager.Hit(EventId.OpenPanel, PanelId.SkillInstanceBattlePanel, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function SkillInstanceLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function SkillInstanceLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function SkillInstanceLevel:PlaySuccessPerform(FirstRewardItems, tbStarReward, tbThreeStarItems, tbSurpriseItems, nExp, tbStar, mapChangeInfo)
local func_SettlementFinish = function(bSuccess)
end
local tbChar = self.tbCharId
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nType = ConfigTable.GetData("SkillInstanceFloor", ConfigTable.GetData("SkillInstance", self.nLevelId).FloorId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.SkillInstanceResult, true, tbStar, tbStarReward or {}, FirstRewardItems or {}, tbThreeStarItems or {}, nExp or 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, tbSurpriseItems or {}, self.tbCharDamage)
self.bSettle = false
self.parent:LevelEnd()
self:UnBindEvent()
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
CS.AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function SkillInstanceLevel:SetCharFixedAttribute()
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function SkillInstanceLevel:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function SkillInstanceLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function SkillInstanceLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function SkillInstanceLevel:OnEvent_Pause()
EventManager.Hit("OpenSkillInstancePause", self.nLevelId, self.tbCharId)
end
return SkillInstanceLevel
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,217 @@
local BaseRoom = require("Game.Adventure.StarTower.StarTowerRoom.BaseRoom")
local BattleRoom = class("BattleRoom", BaseRoom)
BattleRoom._mapEventConfig = {
CSHARP2LUA_BATTLE_DROP_COIN = "OnEvent_GetCoin",
ADVENTURE_BATTLE_MONSTER_DIED = "OnEvent_MonsterDied",
LevelStateChanged = "OnEvent_LevelStateChanged",
LevelUseTotalTime = "OnEvent_TimeEnd",
LevelPauseUseTotalTime = "OnEvent_TimeEnd",
InteractiveNpc = "OnEvent_InteractiveNpc",
Level_Settlement = "OnEvent_ActorFinishDie"
}
function BattleRoom:LevelStart()
local mapBattleCase = self.mapCases[self.EnumCase.Battle]
self.nCoinTemp = 0
self.bBattleEnd = false
if mapBattleCase == nil then
self.bBattleEnd = true
EventManager.Hit("ShowStarTowerRoomInfo", true, self.parent.nTeamLevel, self.parent.nTeamExp, clone(self.parent._mapNote), clone(self.parent._mapFateCard))
local nCoin = self.parent._mapItem[AllEnum.CoinItemId.FixedRogCurrency]
if nCoin == nil then
nCoin = 0
end
local nBuildScore = self.parent:CalBuildScore()
EventManager.Hit("ShowStarTowerCoin", true, nCoin, nBuildScore)
self:AddTimer(1, 0.1, function()
CS.WwiseAudioManager.Instance:SetState("combat", "explore")
end, true, true, true)
return
end
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.StarTower)
if mapBattleCase.Data.TimeLimit then
local nLevel = self.parent.nCurLevel
local nType = self.parent.nRoomType
local nStage = self.parent:GetStage(nLevel)
EventManager.Hit("OpenBossTime", nStage, nType)
end
EventManager.Hit("ShowStarTowerCoin", false)
self.bFailed = false
local nType = self.parent.nRoomType
if nType == GameEnum.starTowerRoomType.BossRoom or nType == GameEnum.starTowerRoomType.FinalBossRoom then
EventManager.Hit("StartClientRankTimer")
end
end
function BattleRoom:OnLoadLevelRefresh()
end
function BattleRoom:OnEvent_LevelStateChanged(nState)
if self.bFailed then
printError("角色已死亡")
return
end
if nState == GameEnum.levelState.Teleporter then
if self.mapCases[self.EnumCase.OpenDoor] == nil then
printError("无传送门case 无法进入下一层")
return
end
local tbDoorCase = self.mapCases[self.EnumCase.OpenDoor]
self.parent:EnterRoom(tbDoorCase[1], tbDoorCase[2])
return
end
if self.mapCases[self.EnumCase.Battle] == nil then
printError("无战斗事件需要处理")
return
end
EventManager.Hit("CloseBossTime", nState == GameEnum.levelState.Success)
local msg = {}
local nEventId = self.mapCases[self.EnumCase.Battle].Id
msg.Id = nEventId
msg.BattleEndReq = {}
local nType = self.parent.nRoomType
if nType == GameEnum.starTowerRoomType.BossRoom or nType == GameEnum.starTowerRoomType.FinalBossRoom then
EventManager.Hit("ResetClientRankTimer")
end
if nState == GameEnum.levelState.Success then
self.bBattleEnd = true
EventManager.Hit("ShowStarTowerRoomInfo", true, self.parent.nTeamLevel, self.parent.nTeamExp, clone(self.parent._mapNote), clone(self.parent._mapFateCard))
local nCoin = self.parent._mapItem[AllEnum.CoinItemId.FixedRogCurrency]
if nCoin == nil then
nCoin = 0
end
local nBuildScore = self.parent:CalBuildScore()
EventManager.Hit("ShowStarTowerCoin", true, nCoin, nBuildScore)
local mapCharHpInfo = self.parent.GetActorHp()
local nMainChar = self.parent.tbTeam[1]
local nHp = -1
if mapCharHpInfo[nMainChar] ~= nil then
nHp = mapCharHpInfo[nMainChar]
end
local tbUsage = self.parent:GetFateCardUsage()
local clientData, nDataLength = self.parent:CacheTempData()
local tbDamage = self.parent:GetDamageRecord()
local tbSamples = UTILS.GetBattleSamples()
if self.parent.nTotalTime ~= nil then
self.parent.nTotalTime = self.parent.nTotalTime + self.nTime
end
local tbEvent = {}
tbEvent = PlayerData.Achievement:GetBattleAchievement(GameEnum.levelType.StarTower, true)
msg.BattleEndReq.Victory = {
HP = nHp,
Time = self.nTime,
ClientData = clientData,
fateCardUsage = tbUsage,
DateLen = nDataLength,
Damages = tbDamage,
Sample = tbSamples,
Events = {List = tbEvent}
}
local tabUpLevel = {}
table.insert(tabUpLevel, {
"role_id",
tostring(PlayerData.Base._nPlayerId)
})
table.insert(tabUpLevel, {
"game_cost_time",
tostring(self.nTime)
})
table.insert(tabUpLevel, {
"real_cost_time",
tostring(CS.ClientManager.Instance.serverTimeStampWithTimeZone - self._EntryTime)
})
table.insert(tabUpLevel, {
"tower_id",
tostring(self.parent.nTowerId)
})
table.insert(tabUpLevel, {
"room_floor",
tostring(self.parent.nCurLevel)
})
table.insert(tabUpLevel, {
"room_type",
tostring(self.parent.nRoomType)
})
table.insert(tabUpLevel, {
"action",
tostring(2)
})
NovaAPI.UserEventUpload("star_tower", tabUpLevel)
elseif nState == GameEnum.levelState.Failed then
self.bFailed = true
return
end
local callback = function(msgData, tbChangeFateCard, mapChangeNote, mapItemChange, nLevelChange, nExpChange)
self.nCoinTemp = 0
self.mapCases[self.EnumCase.Battle].bFinish = true
self.nWaitShowTime = 0
self.showFinishCall = nil
local setTime = function(nTime, callback)
self.nWaitShowTime = nTime
self.showFinishCall = callback
end
EventManager.Hit("ShowBattleReward", nLevelChange, nExpChange, tbChangeFateCard, mapChangeNote, mapItemChange, setTime)
self.blockNpcBtn = true
local waitCallback = function()
if self.showFinishCall ~= nil then
self.showFinishCall()
self.showFinishCall = nil
end
self:HandleCases()
end
if 0 < self.nWaitShowTime then
self:AddTimer(1, self.nWaitShowTime, waitCallback, true, true, true, nil)
else
waitCallback()
end
end
self.parent:StarTowerInteract(msg, callback)
end
function BattleRoom:OnEvent_MonsterDied()
end
function BattleRoom:OnEvent_InteractiveNpc(nNpcId, nNpcUid)
self:HandleNpc(nNpcId, nNpcUid)
end
function BattleRoom:OnEvent_GetCoin(num)
end
function BattleRoom:OnEvent_TimeEnd(nTime)
self.nTime = nTime
end
function BattleRoom:OnEvent_ActorFinishDie()
if self.bBattleEnd then
EventManager.Hit("AbandonStarTower")
else
local msg = {}
local nEventId = self.mapCases[self.EnumCase.Battle].Id
msg.Id = nEventId
msg.BattleEndReq = {}
msg.BattleEndReq.Defeat = true
local callback = function(msgData)
self.nCoinTemp = 0
self.mapCases[self.EnumCase.Battle].bFinish = true
print("遗迹失败")
self.parent:StarTowerFailed(msgData.Settle.Change, msgData.Settle.Build, msgData.Settle.TotalTime, msgData.Settle.Reward, msgData.Settle.TowerRewards, msgData.Settle.NpcInteraction)
end
local ConfirmCallback = function()
self.parent:ReBattle()
PanelManager.InputEnable()
end
local CancelCallback = function()
self.parent:StarTowerInteract(msg, callback)
PanelManager.InputEnable()
end
if self.parent.bPrologue == true then
self.parent:StarTowerInteract(msg, callback)
else
do
local data = {
nType = AllEnum.MessageBox.Confirm,
sContent = ConfigTable.GetUIText("Startower_ReBattleHint"),
sContentSub = "",
callbackConfirm = ConfirmCallback,
callbackCancel = CancelCallback
}
EventManager.Hit(EventId.OpenMessageBox, data)
PanelManager.InputDisable()
end
end
end
end
return BattleRoom
@@ -0,0 +1,35 @@
local BaseRoom = require("Game.Adventure.StarTower.StarTowerRoom.BaseRoom")
local EventRoom = class("EventRoom", BaseRoom)
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
EventRoom._mapEventConfig = {
LevelStateChanged = "OnEvent_LevelStateChanged",
InteractiveNpc = "OnEvent_InteractiveNpc"
}
function EventRoom:LevelStart()
self:HandleCases()
EventManager.Hit("ShowStarTowerRoomInfo", true, self.parent.nTeamLevel, self.parent.nTeamExp, clone(self.parent._mapNote), clone(self.parent._mapFateCard))
local nCoin = self.parent._mapItem[AllEnum.CoinItemId.FixedRogCurrency]
if nCoin == nil then
nCoin = 0
end
local nBuildScore = self.parent:CalBuildScore()
EventManager.Hit("ShowStarTowerCoin", true, nCoin, nBuildScore)
EventManager.Hit("PlayStarTowerDiscBgm")
end
function EventRoom:OnEvent_InteractiveNpc(nNpcId, nNpcUid)
self:HandleNpc(nNpcId, nNpcUid)
end
function EventRoom:OnLoadLevelRefresh()
end
function EventRoom:OnEvent_LevelStateChanged(nState)
if nState == GameEnum.levelState.Teleporter then
if self.mapCases[self.EnumCase.OpenDoor] == nil then
printError("无传送门case 无法进入下一层")
return
end
local tbDoorCase = self.mapCases[self.EnumCase.OpenDoor]
self.parent:EnterRoom(tbDoorCase[1], tbDoorCase[2])
return
end
end
return EventRoom
File diff suppressed because it is too large Load Diff
+404
View File
@@ -0,0 +1,404 @@
local StoryLevel = class("StoryLevel")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local mapEventConfig = {
LevelStateChanged = "OnEvent_SendMsgFinishBattle",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
Mainline_Time_CountUp = "OnEvent_Time",
BattlePause = "OnEvnet_Pause",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter"
}
function StoryLevel:Init(parent, nLevelId, nBuildId)
self.bSettle = false
self.parent = parent
self.nMainLineTime = 0
self.nCacheFloorTime = 0
self.nLevelId = nLevelId
self.curFloorIdx = 1
self.mapCharacterTempData = {}
local mapStory = ConfigTable.GetData_Story(nLevelId)
if mapStory == nil then
printError("mapStory is nil,id = " .. nLevelId)
return
end
self.bTrialLevel = mapStory.TrialBuild ~= nil and nBuildId == 0
local GetBuildCallback = function(mapBuildData)
self.mapBuildData = mapBuildData
self.tbCharId, self.tbCharTrialId = {}, {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
self.tbCharTrialId[mapChar.nTid] = mapChar.nTrialId
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.Mainline
CS.AdventureModuleHelper.EnterMainlineMap(mapStory.FloorId[1], self.tbCharId, {})
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
if self.bTrialLevel then
local mapBuildData = PlayerData.Build:GetTrialBuild(mapStory.TrialBuild)
GetBuildCallback(mapBuildData)
else
PlayerData.Build:GetBuildDetailData(GetBuildCallback, nBuildId)
end
end
function StoryLevel:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function StoryLevel:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = {}, {}, {}, {}
if self.bTrialLevel then
mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetTrialBuildAllEft()
else
mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
end
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
self:ResetCharacter()
end
function StoryLevel:OnEvent_SendMsgFinishBattle(LevelResult, FadeTime, sVideoName)
if self.bSettle == true then
print("已在结算流程中!")
return
end
self.bSettle = true
print("OnEvent_SendMsgFinishBattle")
local fadeT = 0
if FadeTime ~= nil then
fadeT = FadeTime
end
if LevelResult == AllEnum.LevelResult.Failed then
self:OnEvent_AbandonBattle()
return
end
local mapStory = ConfigTable.GetData_Story(self.nLevelId)
if self.curFloorIdx < #mapStory.FloorId then
self:ChangeFloor()
return
end
local func_cbFinishSucc = function(mapChangeInfo)
self:PlaySuccessPerform(fadeT, mapChangeInfo, sVideoName)
end
print("====== 当前通关主线关卡ID" .. self.nLevelId .. " ======")
local events = {
List = PlayerData.Achievement:GetBattleAchievement(GameEnum.levelType.Mainline, LevelResult ~= AllEnum.LevelResult.Failed)
}
PlayerData.Avg:SendMsg_STORY_DONE(func_cbFinishSucc, events)
end
function StoryLevel:OnEvent_AbandonBattle()
self:RefreshCharDamageData()
if self.nLevelId > 0 then
local nMainlineId = self.nLevelId
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, false, 0, {}, {}, {}, 0, false, "", "", nMainlineId, self.tbCharId, {}, self.tbCharDamage)
self:UnBindEvent()
self.parent:LevelEnd()
end
end
function StoryLevel:OnEvent_AdventureModuleEnter()
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.Mainline)
EventManager.Hit(EventId.OpenPanel, PanelId.Adventure, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local nTrialOrCharId = self.bTrialLevel and self.tbCharTrialId[nCharId] or nCharId
local stActorInfo = self:CalCharFixedEffect(nTrialOrCharId, idx == 1, self.tbDiscId, self.bTrialLevel)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function StoryLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function StoryLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function StoryLevel:PlaySuccessPerform(FadeTime, mapChangeInfo, sVideoName)
local func_SettlementFinish = function(bSuccess)
end
local bHasReward = mapChangeInfo and mapChangeInfo.Props and #mapChangeInfo.Props > 0
local FirstRewardItems = {}
if bHasReward then
local tbRewardDisplay = UTILS.DecodeChangeInfo(mapChangeInfo)
for _, v in pairs(tbRewardDisplay) do
for k, value in pairs(v) do
table.insert(FirstRewardItems, {
Tid = value.Tid,
Qty = value.Qty,
rewardType = AllEnum.RewardType.First
})
end
end
end
local tbChar = self.tbCharId
self:RefreshCharDamageData()
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
local sLarge, sSmall = "", ""
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResult, true, 3, {}, FirstRewardItems or {}, {}, 0, false, sLarge, sSmall, self.nLevelId, self.tbCharId, mapChangeInfo, self.tbCharDamage)
self.bSettle = false
self.parent:LevelEnd()
self:UnBindEvent()
end
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
EventManager.Hit(EventId.SetTransition)
local function videoCallback()
EventManager.Remove("VIDEO_END", self, videoCallback)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
local nFloorCount = #ConfigTable.GetData_Story(self.nLevelId).FloorId
local nMapId = ConfigTable.GetData_Story(self.nLevelId).FloorId[nFloorCount]
local nType = ConfigTable.GetData("MainlineFloor", nMapId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
if sVideoName ~= nil and sVideoName ~= "" then
EventManager.Add("VIDEO_END", self, videoCallback)
EventManager.Hit(EventId.OpenPanel, PanelId.ProVideoGUI, sVideoName, true, 0.5, false, 0, true)
else
videoCallback()
end
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
CS.AdventureModuleHelper.LevelStateChanged(true, FadeTime or 0.5)
end
function StoryLevel:CalCharFixedEffect(nTrialOrCharId, bMainChar, tbDiscId, bTrialLevel)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
if bTrialLevel then
PlayerData.Char:CalCharacterTrialAttrBattle(nTrialOrCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
else
PlayerData.Char:CalCharacterAttrBattle(nTrialOrCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
end
return stActorInfo
end
function StoryLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = {}
if self.bTrialLevel then
if self.tbCharTrialId[nCharId] then
mapAddLevel = PlayerData.Talent:GetTrialEnhancedPotential(self.tbCharTrialId[nCharId])
else
printError("体验build内,有多余角色的潜能" .. nCharId)
end
else
mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
end
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function StoryLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo
if self.bTrialLevel then
discInfo = PlayerData.Disc:CalcTrialInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
else
discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
end
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function StoryLevel:OnEvent_Time(nTime)
self.nMainLineTime = self.nCacheFloorTime + nTime
end
function StoryLevel:OnEvnet_Pause()
local sAim = ConfigTable.GetData_Story(self.nLevelId).Aim
EventManager.Hit(EventId.OpenPanel, PanelId.MainBattlePause, self.nMainLineTime or 0, self.mapBuildData.tbChar, sAim)
end
function StoryLevel:ChangeFloor()
self:CacheTempData()
local mapStory = ConfigTable.GetData_Story(self.nLevelId)
self.curFloorIdx = self.curFloorIdx + 1
self.nCacheFloorTime = self.nMainLineTime
local function levelUnloadCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local nTrialOrCharId = self.bTrialLevel and self.tbCharTrialId[nCharId] or nCharId
local stActorInfo = self:CalCharFixedEffect(nTrialOrCharId, idx == 1, self.tbDiscId, self.bTrialLevel)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
self:SetCharStatus()
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelUnloadCallback)
CS.AdventureModuleHelper.EnterMainlineMap(mapStory.FloorId[self.curFloorIdx], self.tbCharId, {})
CS.AdventureModuleHelper.LevelStateChanged(false)
self.bSettle = false
end
function StoryLevel:SetCharStatus()
local nStatus = 0
local nStatusTime = 0
local tbActorInfo = {}
for _, nTid in pairs(self.tbCharId) do
local stCharInfo = CS.Lua2CSharpInfo_ActorStatus()
if self.mapCharacterTempData.stateInfo ~= nil and self.mapCharacterTempData.stateInfo[nTid] ~= nil then
nStatus = self.mapCharacterTempData.stateInfo[nTid].nState
nStatusTime = self.mapCharacterTempData.stateInfo[nTid].nStateTime
end
stCharInfo.actorID = nTid
stCharInfo.status = nStatus
stCharInfo.specialStatusTime = nStatusTime
table.insert(tbActorInfo, stCharInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.SetActorStatus, tbActorInfo)
end
function StoryLevel:ResetCharacter()
if self.mapCharacterTempData.hpInfo ~= nil then
local tbActorInfo = {}
for nTid, nHp in pairs(self.mapCharacterTempData.hpInfo) do
local stCharInfo = CS.Lua2CSharpInfo_ActorAttribute()
stCharInfo.actorID = nTid
stCharInfo.curHP = nHp
table.insert(tbActorInfo, stCharInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorAttributes, tbActorInfo)
end
if self.mapCharacterTempData.skillInfo ~= nil then
local tbSkillInfos = {}
for _, skillInfo in ipairs(self.mapCharacterTempData.skillInfo) do
local stSkillInfo = CS.Lua2CSharpInfo_ResetSkillInfo()
stSkillInfo.skillId = skillInfo.nSkillId
stSkillInfo.currentSectionAmount = skillInfo.nSectionAmount
stSkillInfo.cd = skillInfo.nCd
stSkillInfo.currentResumeTime = skillInfo.nSectionResumeTime
stSkillInfo.currentUseTimeHint = skillInfo.nUseTimeHint
stSkillInfo.energy = skillInfo.nEnergy
if tbSkillInfos[skillInfo.nCharId] == nil then
tbSkillInfos[skillInfo.nCharId] = {}
end
table.insert(tbSkillInfos[skillInfo.nCharId], stSkillInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetActorSkillInfo, tbSkillInfos)
end
if self.mapCharacterTempData.buffInfo ~= nil then
local tbBuffinfo = {}
for nCharId, mapBuff in pairs(self.mapCharacterTempData.buffInfo) do
if mapBuff.mapBuff ~= nil then
for _, mapBuffInfo in pairs(mapBuff.mapBuff) do
local stBuffInfo = CS.Lua2CSharpInfo_ResetBuffInfo()
stBuffInfo.Id = mapBuffInfo.Id
stBuffInfo.Cd = mapBuffInfo.CD
stBuffInfo.buffNum = mapBuffInfo.nNum
if tbBuffinfo[nCharId] == nil then
tbBuffinfo[nCharId] = {}
end
table.insert(tbBuffinfo[nCharId], stBuffInfo)
end
end
end
safe_call_cs_func(CS.AdventureModuleHelper.ResetBuff, tbBuffinfo)
end
end
function StoryLevel:CacheTempData()
local FP = CS.TrueSync.FP
self.mapCharacterTempData = {}
local AdventureModuleHelper = CS.AdventureModuleHelper
local id = AdventureModuleHelper.GetCurrentActivePlayer()
self.mapCharacterTempData.curCharId = CS.AdventureModuleHelper.GetCharacterId(id)
self.mapCharacterTempData.skillInfo = {}
self.mapCharacterTempData.effectInfo = {}
self.mapCharacterTempData.buffInfo = {}
self.mapCharacterTempData.hpInfo = {}
self.mapCharacterTempData.stateInfo = {}
local playerids = AdventureModuleHelper.GetCurrentGroupPlayers()
local Count = playerids.Count - 1
for i = 0, Count do
local charTid = AdventureModuleHelper.GetCharacterId(playerids[i])
local clsSkillId = AdventureModuleHelper.GetPlayerSkillCd(playerids[i])
local nStatus = AdventureModuleHelper.GetPlayerActorStatus(playerids[i])
local nStatusTime = AdventureModuleHelper.GetPlayerActorSpecialStatusTime(playerids[i])
self.mapCharacterTempData.hpInfo[charTid] = AdventureModuleHelper.GetEntityHp(playerids[i])
if clsSkillId ~= nil then
local tbSkillInfos = clsSkillId.skillInfos
local nSkillCount = tbSkillInfos.Count - 1
for j = 0, nSkillCount do
local clsSkillInfo = tbSkillInfos[j]
local mapSkill = ConfigTable.GetData_Skill(clsSkillInfo.skillId)
if mapSkill.Type == GameEnum.skillType.ULTIMATE then
table.insert(self.mapCharacterTempData.skillInfo, {
nCharId = charTid,
nSkillId = clsSkillInfo.skillId,
nCd = clsSkillInfo.currentUseInterval.RawValue,
nSectionAmount = clsSkillInfo.currentSectionAmount,
nSectionResumeTime = clsSkillInfo.currentResumeTime.RawValue,
nUseTimeHint = clsSkillInfo.currentUseTimeHint.RawValue,
nEnergy = clsSkillInfo.currentEnergy.RawValue
})
end
end
self.mapCharacterTempData.effectInfo[charTid] = {
mapEffect = {}
}
local tbClsEfts = AdventureModuleHelper.GetEffectList(playerids[i])
if tbClsEfts ~= nil then
local nEftCount = tbClsEfts.Count - 1
for k = 0, nEftCount do
local eftInfo = tbClsEfts[k]
local mapEft = ConfigTable.GetData_Effect(eftInfo.effectConfig.Id)
local nCd = eftInfo.CD.RawValue
if mapEft.Remove and 0 < nCd then
self.mapCharacterTempData.effectInfo[charTid].mapEffect[eftInfo.effectConfig.Id] = {nCount = 0, nCd = nCd}
end
end
end
local tbBuffInfo = AdventureModuleHelper.GetEntityBuffList(playerids[i])
self.mapCharacterTempData.buffInfo[charTid] = {
mapBuff = {}
}
if tbBuffInfo ~= nil then
local nBuffCount = tbBuffInfo.Count - 1
for l = 0, nBuffCount do
local eftInfo = tbBuffInfo[l]
local mapBuff = ConfigTable.GetData_Buff(eftInfo.buffConfig.Id)
if mapBuff.NotRemove then
table.insert(self.mapCharacterTempData.buffInfo[charTid].mapBuff, {
Id = eftInfo.buffConfig.Id,
CD = eftInfo:GetBuffLeftTime().RawValue,
nNum = eftInfo:GetBuffNum()
})
end
end
end
end
self.mapCharacterTempData.stateInfo[charTid] = {nState = nStatus, nStateTime = nStatusTime}
end
end
return StoryLevel
@@ -0,0 +1,254 @@
local TravelerDuelLevelData = class("TravelerDuelLevelData")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local AdventureModuleHelper = CS.AdventureModuleHelper
local TimerManager = require("GameCore.Timer.TimerManager")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
TravelerDuel_Result = "OnEvent_LevelResult",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvnet_Pause",
Upload_Dodge_Event = "OnEvent_UploadDodgeEvent"
}
function TravelerDuelLevelData:Init(parent, nLevel, tbAffixes, nBuildId)
self._EntryTime = CS.ClientManager.Instance.serverTimeStampWithTimeZone
local LocalData = require("GameCore.Data.LocalData")
local sKey = LocalData.GetPlayerLocalData("TravelerDuelRecordKey")
if sKey ~= nil or sKey ~= "" then
NovaAPI.DeleteRecFile(sKey)
end
self.bEnd = false
local ClientManager = CS.ClientManager.Instance
sKey = tostring(ClientManager.serverTimeStamp)
LocalData.SetPlayerLocalData("TravelerDuelRecordKey", sKey)
self.parent = parent
self.nlevelId = nLevel
self.tmpBuildId = nBuildId
self.tbAffixes = tbAffixes
local mapCfg = ConfigTable.GetData("TravelerDuelBossLevel", nLevel)
if mapCfg then
self.nTime = mapCfg.Timelimit
end
local GetDataCallback = function(mapBuildData)
local mapLevel = ConfigTable.GetData("TravelerDuelBossLevel", nLevel)
if mapLevel == nil then
printError("TravelerDuelBossLevel missing:" .. nLevel)
return
end
self.mapBuildData = mapBuildData
self.tbCharId = {}
for i, v in pairs(mapBuildData.tbChar) do
table.insert(self.tbCharId, v.nTid)
end
self.tbDiscId = {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
end
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.TravelerDuel
CS.AdventureModuleHelper.EnterTravelerDuel(nLevel, mapLevel.FloorId, self.tbCharId, tbAffixes)
safe_call_cs_func(CS.AdventureModuleHelper.SetDamageRecordId, sKey)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
PlayerData.Build:GetBuildDetailData(GetDataCallback, nBuildId)
end
function TravelerDuelLevelData:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function TravelerDuelLevelData:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetBuildAllEft(self.mapBuildData.nBuildId)
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
end
function TravelerDuelLevelData:OnEvent_LevelResult(bSuccess, nTime)
if self.bEnd then
return
end
self.bEnd = true
self:RefreshCharDamageData()
local msgCallback = function(mapMsgData)
self._EndTime = CS.ClientManager.Instance.serverTimeStampWithTimeZone
local tabUpLevel = {}
local nResult = bSuccess and "1" or "2"
table.insert(tabUpLevel, {
"role_id",
tostring(PlayerData.Base._nPlayerId)
})
table.insert(tabUpLevel, {
"game_cost_time",
tostring(nTime)
})
table.insert(tabUpLevel, {
"real_cost_time",
tostring(self._EndTime - self._EntryTime)
})
table.insert(tabUpLevel, {
"build_id",
tostring(self.mapBuildData.nBuildId)
})
table.insert(tabUpLevel, {
"battle_id",
tostring(self.nlevelId)
})
table.insert(tabUpLevel, {
"battle_result",
tostring(nResult)
})
NovaAPI.UserEventUpload("traveler_duel_battle", tabUpLevel)
if bSuccess then
self:PlaySuccessPerform(mapMsgData, 3, nTime)
else
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
EventManager.Hit(EventId.OpenPanel, PanelId.TDBattleResultPanel, false, {
false,
false,
false
}, mapMsgData.AwardItems, mapMsgData.FirstItems, {}, 0, false, nTime, self.nlevelId, self.tbCharId, self.tbAffixes, mapMsgData.TimeScore, mapMsgData.BaseScore, mapMsgData.FinalScore, mapMsgData.FinalScore > mapMsgData.MaxScore, mapMsgData.Change, mapMsgData.SurpriseItems, mapMsgData.CustomItems, self.tbCharDamage)
self.parent:LevelEnd()
end
end
local nStar = 0
if bSuccess then
nStar = 3
end
local wait = function()
self.parent:SendMsg_TravelerDuelSettle(nStar, self.nlevelId, nTime, msgCallback)
end
if bSuccess then
TimerManager.Add(1, 2, self, wait, true, true, nil, nil)
else
wait()
end
end
function TravelerDuelLevelData:OnEvent_AbandonBattle()
self:OnEvent_LevelResult(false, 0)
end
function TravelerDuelLevelData:OnEvent_AdventureModuleEnter()
PlayerData.Achievement:SetSpecialBattleAchievement(GameEnum.levelType.TravelerDuel)
EventManager.Hit(EventId.OpenPanel, PanelId.TDBattlePanel, self.tbCharId)
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(nCharId, idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function TravelerDuelLevelData:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function TravelerDuelLevelData:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function TravelerDuelLevelData:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapAddLevel = PlayerData.Char:GetCharEnhancedPotential(nCharId)
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function TravelerDuelLevelData:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcDiscInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function TravelerDuelLevelData:PlaySuccessPerform(mapMsgData, nStar, nTime)
local func_OpenResult = function(bSuccess)
end
local tbChar = self.tbCharId
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nFloorId = ConfigTable.GetData("TravelerDuelBossLevel", self.nlevelId).FloorId
local nType = ConfigTable.GetData("TravelerDuelFloor", nFloorId).Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
local jumpPerform = function()
NovaAPI.DispatchEventWithData("SKIP_SETTLEMENT_PERFORM")
end
EventManager.Hit(EventId.OpenPanel, PanelId.BtnTips, jumpPerform)
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_OpenResult)
end
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
EventManager.Hit(EventId.OpenPanel, PanelId.TDBattleResultPanel, true, {
true,
true,
true
}, mapMsgData.AwardItems, mapMsgData.FirstItems, {}, 0, false, nTime, self.nlevelId, self.tbCharId, self.tbAffixes, mapMsgData.TimeScore, mapMsgData.BaseScore, mapMsgData.FinalScore, mapMsgData.FinalScore > mapMsgData.MaxScore, mapMsgData.Change, mapMsgData.SurpriseItems, mapMsgData.CustomItems, self.tbCharDamage)
self.bSettle = false
self.parent:LevelEnd()
self:UnBindEvent()
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
CS.AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function TravelerDuelLevelData:CalCharFixedEffect(nCharId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterAttrBattle(nCharId, stActorInfo, bMainChar, tbDiscId, self.mapBuildData.nBuildId)
return stActorInfo
end
function TravelerDuelLevelData:OnEvnet_Pause()
EventManager.Hit("OpenTDPause", self.nlevelId, self.tbCharId)
end
function TravelerDuelLevelData:OnEvent_UploadDodgeEvent(padMode)
local tab = {}
table.insert(tab, {
"role_id",
tostring(PlayerData.Base._nPlayerId)
})
table.insert(tab, {"pad_mode", padMode})
table.insert(tab, {
"level_type",
"TravelerDuel"
})
table.insert(tab, {
"build_id",
tostring(self.tmpBuildId)
})
table.insert(tab, {
"level_id",
tostring(self.nlevelId)
})
table.insert(tab, {
"up_time",
tostring(CS.ClientManager.Instance.serverTimeStamp)
})
NovaAPI.UserEventUpload("use_dodge_key", tab)
end
return TravelerDuelLevelData
+243
View File
@@ -0,0 +1,243 @@
local TrialLevel = class("TrialLevel")
local TimerManager = require("GameCore.Timer.TimerManager")
local mapEventConfig = {
LoadLevelRefresh = "OnEvent_LoadLevelRefresh",
[EventId.AbandonBattle] = "OnEvent_AbandonBattle",
TrialGameEnd = "OnEvent_LevelResult",
AdventureModuleEnter = "OnEvent_AdventureModuleEnter",
BattlePause = "OnEvent_Pause",
TrialDepot = "OnEvent_Depot",
TaskLevel_InitTask = "OnEvent_InitQuest",
Trial_QuestComplete = "OnEvent_QuestComplete",
Trial_Time = "OnEvent_Time"
}
function TrialLevel:Init(parent, nLevelId)
self.parent = parent
self.nLevelId = nLevelId
self.mapChangeInfo = {}
self.mapLevelCfg = ConfigTable.GetData("TrialFloor", nLevelId)
if not self.mapLevelCfg then
return
end
self.mapBuildData = PlayerData.Build:GetTrialBuild(self.mapLevelCfg.TrialBuild)
self.tbCharId, self.tbCharTrialId, self.mapCharData, self.mapTalentAddLevel = {}, {}, {}, {}
for _, mapChar in ipairs(self.mapBuildData.tbChar) do
table.insert(self.tbCharId, mapChar.nTid)
self.tbCharTrialId[mapChar.nTid] = mapChar.nTrialId
self.mapCharData[mapChar.nTid] = PlayerData.Char:GetTrialCharById(mapChar.nTrialId)
self.mapTalentAddLevel[mapChar.nTid] = PlayerData.Talent:GetTrialEnhancedPotential(mapChar.nTrialId)
end
self.tbDiscId, self.mapDiscData = {}, {}
for _, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if 0 < nDiscId then
table.insert(self.tbDiscId, nDiscId)
local mapCfg = ConfigTable.GetData("TrialDisc", nDiscId)
if mapCfg then
self.mapDiscData[mapCfg.DiscId] = PlayerData.Disc:GetTrialDiscById(nDiscId)
end
end
end
self:ParseDepotData()
self.mapActorInfo = {}
for idx, nTid in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(self.tbCharTrialId[nTid], idx == 1, self.tbDiscId)
self.mapActorInfo[nTid] = stActorInfo
end
PlayerData.nCurGameType = AllEnum.WorldMapNodeType.Trial
local params = NovaAPI.GetDynamicLevelParamsBootConfig()
CS.AdventureModuleHelper.EnterDynamic(nLevelId, self.tbCharId, GameEnum.dynamicLevelType.Trial, params)
NovaAPI.EnterModule("AdventureModuleScene", true, 17)
end
function TrialLevel:ParseDepotData()
self.tbDepotPotential = {}
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
if self.tbCharTrialId[nCharId] then
if not self.tbDepotPotential[nCharId] then
self.tbDepotPotential[nCharId] = {}
end
for _, v in ipairs(tbPerk) do
self.tbDepotPotential[nCharId][v.nPotentialId] = v.nLevel
end
else
printError("体验build内,有多余角色的潜能" .. nCharId)
end
end
end
function TrialLevel:OnEvent_LoadLevelRefresh()
local mapAllEft, mapDiscEft, mapNoteEffect, tbNoteInfo = PlayerData.Build:GetTrialBuildAllEft()
safe_call_cs_func(CS.AdventureModuleHelper.SetNoteInfo, tbNoteInfo)
self.mapEftData = UTILS.AddBuildEffect(mapAllEft, mapDiscEft, mapNoteEffect)
EventManager.Hit("OpenTrialInfo", self.nQuestId)
end
function TrialLevel:RefreshCharDamageData()
self.tbCharDamage = UTILS.GetCharDamageResult(self.tbCharId)
end
function TrialLevel:OnEvent_LevelResult(nLevelTime)
self:RefreshCharDamageData()
local bReceived = PlayerData.Trial:CheckGroupReceived()
local bAbandon = not bReceived
EventManager.Hit("TrialBattleEnd")
if self.parent:GetSettlementState() then
printError("试玩关结算流程重复进入,本次退出")
return
end
self.parent:SetSettlementState(true)
if bAbandon then
EventManager.Hit("TrialLevelEnd", self.nLevelId)
EventManager.Hit(EventId.ClosePanel, PanelId.BtnTips)
EventManager.Hit(EventId.OpenPanel, PanelId.TrialResult, false, nLevelTime or 0, self.tbCharId, self.parent.nActId, {}, self.tbCharDamage)
self.parent:LevelEnd()
return
end
EventManager.Hit("TrialLevelEnd", self.nLevelId)
self:PlaySuccessPerform(nLevelTime)
end
function TrialLevel:OnEvent_AbandonBattle()
self:OnEvent_LevelResult(self.nLevelTime)
end
function TrialLevel:OnEvent_AdventureModuleEnter()
self:SetPersonalPerk()
self:SetDiscInfo()
for idx, nCharId in ipairs(self.tbCharId) do
local stActorInfo = self:CalCharFixedEffect(self.tbCharTrialId[nCharId], idx == 1, self.tbDiscId)
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
local tbDisc = {}
for _, v in ipairs(self.tbDiscId) do
local mapCfg = ConfigTable.GetData("TrialDisc", v)
if mapCfg then
table.insert(tbDisc, mapCfg.DiscId)
end
end
EventManager.Hit(EventId.OpenPanel, PanelId.TrialBattlePanel, self.tbCharId, tbDisc, self.mapCharData, self.mapDiscData, self.mapTalentAddLevel)
end
function TrialLevel:BindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Add(nEventId, self, callback)
end
end
end
function TrialLevel:UnBindEvent()
if type(mapEventConfig) ~= "table" then
return
end
for nEventId, sCallbackName in pairs(mapEventConfig) do
local callback = self[sCallbackName]
if type(callback) == "function" then
EventManager.Remove(nEventId, self, callback)
end
end
end
function TrialLevel:PlaySuccessPerform(nLevelTime)
local func_SettlementFinish = function(bSuccess)
end
local tbChar = self.tbCharId
local function levelEndCallback()
EventManager.Remove("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local nType = self.mapLevelCfg.Theme
local sName = ConfigTable.GetData("EndSceneType", nType).EndSceneName
local tbSkin = {}
for _, nCharId in ipairs(tbChar) do
local nSkinId = PlayerData.Char:GetCharSkinId(nCharId)
table.insert(tbSkin, nSkinId)
end
CS.AdventureModuleHelper.PlaySettlementPerform(sName, "", tbSkin, func_SettlementFinish)
end
EventManager.Add("ADVENTURE_LEVEL_UNLOAD_COMPLETE", self, levelEndCallback)
local function openBattleResultPanel()
EventManager.Remove("SettlementPerformLoadFinish", self, openBattleResultPanel)
EventManager.Hit(EventId.OpenPanel, PanelId.TrialResult, true, nLevelTime or 0, self.tbCharId, self.parent.nActId, self.mapChangeInfo, self.tbCharDamage)
self.bSettle = false
self.parent:LevelEnd()
self:UnBindEvent()
end
EventManager.Add("SettlementPerformLoadFinish", self, openBattleResultPanel)
CS.AdventureModuleHelper.LevelStateChanged(true)
EventManager.Hit(EventId.OpenPanel, PanelId.BattleResultMask)
end
function TrialLevel:SetCharFixedAttribute()
for nCharId, stActorInfo in pairs(self.mapActorInfo) do
safe_call_cs_func(CS.AdventureModuleHelper.SetActorAttribute, nCharId, stActorInfo)
end
end
function TrialLevel:CalCharFixedEffect(nTrialId, bMainChar, tbDiscId)
local stActorInfo = CS.Lua2CSharpInfo_CharAttribute()
PlayerData.Char:CalCharacterTrialAttrBattle(nTrialId, stActorInfo, bMainChar, tbDiscId, self.mapLevelCfg.TrialBuild)
return stActorInfo
end
function TrialLevel:SetPersonalPerk()
if self.mapBuildData ~= nil then
for nCharId, tbPerk in pairs(self.mapBuildData.tbPotentials) do
local mapTalentAddLevel = {}
if self.tbCharTrialId[nCharId] then
mapTalentAddLevel = PlayerData.Talent:GetTrialEnhancedPotential(self.tbCharTrialId[nCharId])
else
printError("体验build内,有多余角色的潜能" .. nCharId)
end
local tbPerkInfo = {}
for _, mapPerkInfo in ipairs(tbPerk) do
local nAddLv = mapTalentAddLevel[mapPerkInfo.nPotentialId] or 0
local stPerkInfo = CS.Lua2CSharpInfo_TPPerkInfo()
stPerkInfo.perkId = mapPerkInfo.nPotentialId
stPerkInfo.nCount = mapPerkInfo.nLevel + nAddLv
table.insert(tbPerkInfo, stPerkInfo)
end
safe_call_cs_func(CS.AdventureModuleHelper.ChangePersonalPerkIds, tbPerkInfo, nCharId)
end
end
end
function TrialLevel:SetDiscInfo()
local tbDiscInfo = {}
for k, nDiscId in ipairs(self.mapBuildData.tbDisc) do
if k <= 3 then
local discInfo = PlayerData.Disc:CalcTrialInfoInBuild(nDiscId, self.mapBuildData.tbSecondarySkill)
table.insert(tbDiscInfo, discInfo)
end
end
safe_call_cs_func(CS.AdventureModuleHelper.SetDiscInfo, tbDiscInfo)
end
function TrialLevel:OnEvent_InitQuest(nQuestId)
self.nQuestId = nQuestId
end
function TrialLevel:OnEvent_QuestComplete()
local bReceived = PlayerData.Trial:CheckGroupReceived()
if not bReceived then
PanelManager.InputDisable()
local callback = function(mapChangeInfo)
PanelManager.InputEnable()
self.mapChangeInfo = mapChangeInfo or {}
end
self.parent:SendReceiveTrialRewardReq(callback)
end
self:ShowTeleportIndicator()
end
function TrialLevel:ShowTeleportIndicator()
local tbTeleports = CS.AdventureModuleHelper.GetLevelTeleporters()
if tbTeleports ~= nil then
for i = 0, tbTeleports.Count - 1 do
EventManager.Hit("SetIndicator", 2, tbTeleports[i], Vector3.zero, nil)
end
end
end
function TrialLevel:OnEvent_Time(nTime)
self.nLevelTime = nTime
end
function TrialLevel:OnEvent_Pause()
EventManager.Hit("OpenTrialPause", self.tbCharId, self.mapCharData, self.mapLevelCfg.TrialChar)
end
function TrialLevel:OnEvent_Depot()
local tbDisc = {}
for _, v in ipairs(self.tbDiscId) do
local mapCfg = ConfigTable.GetData("TrialDisc", v)
if mapCfg then
table.insert(tbDisc, mapCfg.DiscId)
end
end
EventManager.Hit(EventId.OpenPanel, PanelId.TrialDepot, self.tbCharId, tbDisc, self.mapCharData, self.mapDiscData, self.mapTalentAddLevel, self.tbDepotPotential, self.mapBuildData.tbNotes, true)
end
return TrialLevel
File diff suppressed because it is too large Load Diff