miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/View/BattlePanel.lua

991 lines
40 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

require("Base/BasePanel")
require("Base/Stack")
require("Modules.Battle.Config.PokemonEffectConfig")
local BattleView = require("Modules/Battle/View/BattleView")
local GuideBattleLogic = require("Modules/Battle/View/GuideBattleLogic")
BattlePanel = Inherit(BasePanel)
local this = BattlePanel
local battleTimeScaleKey = "battleTimeScaleKey"
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local ArtResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local timeCount
local endFunc
local isBack = false --是否为战斗回放
local fightType -- 1关卡 2副本 3限时怪, 5兽潮, 6新关卡, 7公会boss
local orginLayer
local boxList={}--新将来袭奖励盒子
local boxList2={}--踏碎凌霄奖励盒子
local _NO_JUMP_ROUND = 2
-- 显示跳过战斗使用
local hadCounted = 0
local SKIP_STATE = {
UNLOCK = 0,
LOCK = 1,
NOUSE = 2,
}
local UpdateBtnGMFunc = {
[-1] = function()
-- local isUnlock, tip = BattleManager.IsUnlockBattlePass()
-- if not isUnlock then
-- return SKIP_STATE.LOCK, tip
-- end
return SKIP_STATE.UNLOCK
end,
[BATTLE_TYPE.BACK]= function()
return SKIP_STATE.UNLOCK
end,
[BATTLE_TYPE.BACK_BATTLE] = function()
return SKIP_STATE.UNLOCK
end,
[BATTLE_TYPE.Test] = function()
return SKIP_STATE.UNLOCK
end,
-- [BATTLE_TYPE.MONSTER_CAMP] = function()
-- return SKIP_STATE.UNLOCK
-- end,
-- [BATTLE_TYPE.DAILY_CHALLENGE] = function()
-- return SKIP_STATE.NOUSE, "日常副本战斗无法跳过!"
-- end,
[BATTLE_TYPE.STORY_FIGHT] = function()
local isUnlock, tip = BattleManager.IsUnlockBattlePass()
if not isUnlock then
return SKIP_STATE.LOCK, tip
end
if FightPointPassManager.GetCurOpenFightIdIsBoss() then
if this.curRound <= _NO_JUMP_ROUND then
return SKIP_STATE.NOUSE, "首领关卡第二回合结束后可以跳过"
end
-- return SKIP_STATE.NOUSE, "首领关卡无法跳过!"
end
return SKIP_STATE.UNLOCK
end,
-- [BATTLE_TYPE.DAILY_CHALLENGE] = function()
-- -- if not BattleManager.IsUnlockBattlePass() then
-- -- return SKIP_STATE.LOCK, "25级或充值任意金额后解锁"
-- -- end
-- -- if FightPointPassManager.GetCurOpenFightIdIsBoss() then
-- -- return SKIP_STATE.NOUSE, "首领关卡无法跳过!"
-- -- end
-- if this.curRound <= _NO_JUMP_ROUND then
-- return SKIP_STATE.NOUSE, "第二回合结束后可以跳过"
-- end
-- return SKIP_STATE.UNLOCK
-- end,
}
function this:GetSkipState()
if AppConst.isOpenGM then
return SKIP_STATE.UNLOCK
end
-- LogError("fightType "..fightType)
if UpdateBtnGMFunc[fightType] then
return UpdateBtnGMFunc[fightType]()
else
return UpdateBtnGMFunc[-1]()
end
end
--初始化组件(用于子类重写)
function this:InitComponent()
this.spLoader = SpriteLoader.New()
BattleView:InitComponent(self, self.gameObject)
orginLayer = 0
this.BG = Util.GetGameObject(self.gameObject, "BG")
this.UpRoot = Util.GetGameObject(self.gameObject, "UpRoot")
this.Option = Util.GetGameObject(this.UpRoot, "option")
this.DownRoot = Util.GetGameObject(self.gameObject, "DownRoot")
this.roundText = Util.GetGameObject(this.Option, "timeCount"):GetComponent("Text")
this.orderText = Util.GetGameObject(this.Option, "order/text"):GetComponent("Text")
this.BtnTimeScale = Util.GetGameObject(this.DownRoot, "option/BtnTimeScale")
this.TimeScaleTxt = Util.GetGameObject(this.DownRoot, "option/BtnTimeScale/icon/num"):GetComponent("Text")
this.BtnJumpFight = Util.GetGameObject(this.DownRoot, "option/Button")
this.jumpLock = Util.GetGameObject(this.DownRoot, "option/Button/lock")
-- this.jumpLock:GetComponent("Image").fillAmount = 1
this.submit = Util.GetGameObject(this.DownRoot, "bg")
this.DefResult = Util.GetGameObject(this.UpRoot, "result")
this.AtkResult = Util.GetGameObject(this.DownRoot, "result")
this.damagePanel = Util.GetGameObject(this.UpRoot, "damage")--公会boss的血条
this.damageBoxBg = Util.GetGameObject(this.damagePanel, "bg")
this.damageBoxIcon = Util.GetGameObject(this.damagePanel, "bg/iconRoot/icon"):GetComponent("Image")
this.damageBoxLevel = Util.GetGameObject(this.damagePanel, "lv"):GetComponent("Text")
this.damageProgress = Util.GetGameObject(this.damagePanel, "progress/Fill")
this.damageText = Util.GetGameObject(this.damagePanel, "progress/Text"):GetComponent("Text")
this.dmg2 = Util.GetGameObject(this.UpRoot, "dmg2")--新将来袭的血条
for i = 1, 7 do
boxList[i] = Util.GetGameObject(this.dmg2, "box"..i)
boxList[i]:SetActive(false)
local effect = Util.GetGameObject(boxList[i], "effect")
effect:SetActive(false)
end
boxList[1]:SetActive(true)
this.dmg2Progress = Util.GetGameObject(this.dmg2, "progress/Fill"):GetComponent("Image")
this.dmg2Text = Util.GetGameObject(this.dmg2, "progress/Text"):GetComponent("Text")
this.bar = Util.GetGameObject(this.dmg2, "bar")
this.dmg3 = Util.GetGameObject(this.UpRoot, "dmg3")--踏碎凌霄的血条
this.dmg3Progress = Util.GetGameObject(this.dmg3, "progress/Fill"):GetComponent("Image")
this.dmg3Text = Util.GetGameObject(this.dmg3, "progress/Text"):GetComponent("Text")
this.dmg3grid = Util.GetGameObject(this.dmg3, "grid")
this.bar3 = Util.GetGameObject(this.dmg3, "bar")
this.boxpre = Util.GetGameObject(this.dmg3, "boxpre")
end
--绑定事件(用于子类重写)
function this:BindEvent()
Util.AddLongPressClick(this.submit, function()
BattleRecordManager.SubmitBattleRecord()
end, 0.5)
Util.AddClick(this.BtnTimeScale, function ()
-- 没开始不能调整
if not BattleManager.IsCanOperate() then
return
end
-- 2倍速没开始表示没解锁倍速
if not BattleManager.IsUnlockBattleSpeed() then
PopupTipPanel.ShowTip(PrivilegeManager.GetPrivilegeOpenTip(PRIVILEGE_TYPE.DoubleTimesFight))
return
end
-- 判断当前倍速
local scale = BattleManager.GetTimeScale()
scale = math.floor(scale*10 + 0.5)/10
if scale == BATTLE_TIME_SCALE_ONE then
-- 一倍速回到二倍速
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_TWO)
elseif scale == BATTLE_TIME_SCALE_TWO then
-- 2倍速时判断是否解锁了3倍速没解锁就回到1倍速
-- if BattleManager.IsUnlockBattleSpeedThree() then
-- BattleManager.SetTimeScale(BATTLE_TIME_SCALE_THREE)
--else
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_ONE)
--end
elseif scale == BATTLE_TIME_SCALE_THREE then
-- 三倍速回到一倍速
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_ONE)
else
-- 其他异常数据回到一倍速
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_ONE)
end
end)
-- Util.AddClick(this.jumpLock, function ()
-- local _, tip
-- if UpdateBtnGMFunc[fightType] then
-- _, tip = UpdateBtnGMFunc[fightType]()
-- else
-- _, tip = UpdateBtnGMFunc[-1]()
-- end
-- if tip then
-- PopupTipPanel.ShowTip(tip)
-- end
-- end)
Util.AddClick(this.BtnJumpFight, function ()
local state, tip = self:GetSkipState()
if state ~= SKIP_STATE.UNLOCK then
if tip then
PopupTipPanel.ShowTip(tip)
end
return
end
if BattleManager.IsCanOperate() and not BattleLogic.IsEnd then
BattleView.EndBattle()
BattleLogic.IsEnd = true
this:ClosePanel()
end
end)
end
function this:LoseJump(id)
if not MapManager.Mapping then
if JumpManager.CheckJump(id) then
this:ClosePanel()
JumpManager.GoJumpWithoutTip(id)
end
else
PopupTipPanel.ShowTip(Language[10210])
end
end
--添加事件监听(用于子类重写)
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Battle.OnTimeScaleChanged, this.SwitchTimeScale)
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Battle.OnTimeScaleChanged, this.SwitchTimeScale)
end
function this:OnSortingOrderChange()
Util.AddParticleSortLayer(this.gameObject, this.sortingOrder - orginLayer)
for _, v in pairs(boxList2) do
Util.AddParticleSortLayer(v.obj, this.sortingOrder - orginLayer)
end
orginLayer = this.sortingOrder
BattleView:OnSortingOrderChange(this.sortingOrder)
this.UpRoot:GetComponent("Canvas").sortingOrder = this.sortingOrder + 10
this.DownRoot:GetComponent("Canvas").sortingOrder = this.sortingOrder + 10
end
function this:IsBossFight(fightType)
if fightType == BATTLE_TYPE.TASUILINGXIAO then
return true
end
return false
end
--界面打开时调用(用于子类重写)
function this:OnOpen(_fightData, _fightType, _endFunc, _guideType,isChangeBGM)
GuideBattleLogic:Init(_guideType)
BattleView:OnOpen(_fightData,_fightType, this:IsBossFight(_fightType))
this.guideType=_guideType
endFunc = _endFunc
fightType = _fightType --判定战斗类型
isBack = _fightType == BATTLE_TYPE.BACK --判定是否是战斗回放
hadCounted = 0
-- _fightType ~= BATTLE_TYPE.BACK and _fightType ~= BATTLE_TYPE.BACK_BATTLE
if _fightType==BATTLE_TYPE.STORY_FIGHT and PlayerPrefs.GetInt(PlayerManager.uid.."isJumpFight")==1 then
local record = {
fightData = _fightData.fightData,
fightSeed = _fightData.fightSeed,
fightType = _fightType,
maxRound = _fightData.maxRound,
fightId = _fightData.fightId
}
local recordId = BattleRecordManager.SetBattleRecord(record)
local result=BattleRecordManager.GetBattleRecordResult(recordId)
this.BattleEnd(result)
this:ClosePanel()
return
end
this.curRound = 1
LogPink(fightType)
if _fightData.bg then
this.LiveBg=poolManager:LoadLive(_fightData.bg, this.BG.transform, Vector3.New(1.5,1.5,1.5), Vector3.zero)
else
this.LiveBg=poolManager:LoadLive(BattleManager.GetBattleBg(fightType), this.BG.transform, Vector3.New(1.5,1.5,1.5), Vector3.zero)
--s this.BG:GetComponent("Image").sprite = this.spLoader:LoadSprite(BattleManager.GetBattleBg(fightType))
end
-- SoundManager.PlayMusic(SoundConfig.BGM_Battle_1, true, function()
if not isChangeBGM then
SoundManager.PlayMusic(SoundConfig.BGM_Battle_2, false)
end
-- end)
this.fightResult = nil
-- 清空名字数据
BattleView:SetNameStr(nil)
this.DefResult:SetActive(false)
this.AtkResult:SetActive(false)
-- local lvOpenTimeScaleConFig = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.PrivilegeTypeConfig,"PrivilegeType",PRIVILEGE_TYPE.DoubleTimesFight,"UnlockType",1)
-- if lvOpenTimeScaleConFig and PlayerManager.level == lvOpenTimeScaleConFig.Condition[1][1] and BattleManager.GetTimeScale() == BATTLE_TIME_SCALE_ONE then
-- BattleManager.SetTimeScale(BATTLE_TIME_SCALE_TWO)
-- end
-- 开始战斗
BattleView:StartBattle()
this.InitPanelData()
end
-- 设置战斗结果
function this:SetResult(result)
this.fightResult = result
end
-- 外部数据传递
function this:SetExternalData(externalData)
this.externalData = externalData
end
-- 外部调用
function this:ShowNameShow(result, str)
this.fightResult = result
if true then return end
if str then
local nameList = string.split(str, "|")
BattleView:SetNameStr(str)
this.DefResult:SetActive(true)
this.AtkResult:SetActive(true)
Util.GetGameObject(this.AtkResult, "win"):SetActive(result == 1)
Util.GetGameObject(this.AtkResult, "lose"):SetActive(result == 0)
Util.GetGameObject(this.DefResult, "win"):SetActive(result == 0)
Util.GetGameObject(this.DefResult, "lose"):SetActive(result == 1)
Util.GetGameObject(this.AtkResult, "win/Text"):GetComponent("Text").text = nameList[1]
Util.GetGameObject(this.AtkResult, "lose/Text"):GetComponent("Text").text = nameList[1]
Util.GetGameObject(this.DefResult, "win/Text"):GetComponent("Text").text = nameList[2]
Util.GetGameObject(this.DefResult, "lose/Text"):GetComponent("Text").text = nameList[2]
else
this.DefResult:SetActive(false)
this.AtkResult:SetActive(false)
end
end
-- 初始化
function this.InitPanelData()
this.dmg2:SetActive(fightType == BATTLE_TYPE.XINJIANG)
this.dmg3:SetActive(fightType == BATTLE_TYPE.TASUILINGXIAO)
if fightType == BATTLE_TYPE.GUILD_BOSS and fightType == BATTLE_TYPE.GUILD_CAR_DELAY then
this.myDamage = 0
this.myDamageLevel = 0
this.RefreshMyDamageShow()
local list = RoleManager.Query(function (r) return r.camp == 1 end)
if list[1] then
list[1].Event:AddEvent(BattleEventName.RoleBeDamaged, function (atkRole, damage, bCrit, finalDmg, damageType, dotType)
--Log("damage:"..damage)
this.myDamage = this.myDamage + damage
this.RefreshMyDamageShow()
end)
end
elseif fightType == BATTLE_TYPE.XINJIANG then
boxList[1]:SetActive(true)
this.myDamage = 0
this.myDamageLevel = 0
this.dmg2Text.text = "0%"
this.dmg2Progress.fillAmount = 0
this.RefreshMyDamageShow()
local list = RoleManager.Query(function (r) return r.camp == 1 end)
if list[1] then
list[1].Event:AddEvent(BattleEventName.RoleBeDamaged, function (atkRole, damage, bCrit, finalDmg, damageType, dotType)
--Log("damage:"..damage)
this.myDamage = this.myDamage + damage
this.RefreshMyDamageShow(list[1])
end)
end
elseif fightType == BATTLE_TYPE.TASUILINGXIAO then--踏碎凌霄
boxList2={}
local actData = CommonActPageManager.GetData(ActivityTypeDef.TaSuiLingXiao)
local boxs = ConfigManager.GetConfigDataByKey(ConfigName.NewHeroConfig,"Id",actData.activityId).BoxList
local maxDmg = actData.value
this.myDamage = 0
this.myDamageLevel = 0
this.dmg3Text.text = string.format("0/%s",boxs[1][1])
this.dmg3Progress.fillAmount = 0
for i = 1, #actData.rewards do
local index = #boxList2 + 1
boxList2[index] = {}
boxList2[index].obj = newObject(this.boxpre)
boxList2[index].obj.transform:SetParent(this.dmg3grid.transform)
boxList2[index].obj.transform.localScale = Vector3.one
boxList2[index].obj.transform.localPosition = Vector3.zero
boxList2[index].moved = false
boxList2[index].obj:SetActive(false)
Util.GetGameObject(boxList2[index].obj,"iconRoot/icon"):GetComponent("Image").sprite = this.spLoader:LoadSprite(ArtResourcesConfig[boxs[i][2]].Name)
end
if #boxList2 > 0 then
boxList2[1].obj:SetActive(true)
end
this.RefreshMyDamageShow()
local list = RoleManager.Query(function (r) return r.camp == 1 end)
if list[1] then
list[1].Event:AddEvent(BattleEventName.RoleBeDamaged, function (atkRole, damage, bCrit, finalDmg, damageType, dotType)
this.myDamage = this.myDamage + damage
this.RefreshMyDamageShow(list[1])
end)
end
end
this:InitOption()
end
function this:InitOption()
--显示倒计时
local curRound, maxRound = BattleLogic.GetCurRound()
curRound = curRound <= 0 and 1 or curRound -- 最小显示第一回合
if curRound>maxRound then
curRound=maxRound
end
this.roundText.text = string.format(Language[10211], curRound, maxRound)
hadCounted = 0
this.Option:SetActive(true)
Util.GetGameObject(this.BtnTimeScale, "lock"):SetActive(not BattleManager.IsUnlockBattleSpeed())
-- 设置跳过按钮的状态
this.SetJumpBtnState()
-- 初始化战斗时间,刷新前端显示
BattleManager.InitTimeScale()
this.SwitchTimeScale()
end
-- 设置跳过按钮的状态
function this.SetJumpBtnState()
local state, tip = this:GetSkipState()
local isLock = state ~= SKIP_STATE.UNLOCK
-- 战斗跳过按钮显示
this.jumpLock:SetActive(isLock)
-- 进度展示
-- if isLock then
-- local filter = 1 - (this.curRound - 1)/_NO_JUMP_ROUND
-- this.jumpLock:GetComponent("Image").fillAmount = filter > 0 and filter or 0
-- end
end
function this.SwitchTimeScale()
local _scale = math.floor(BattleManager.GetTimeScale())
--如果之前是三倍速,强制转成二倍速
if _scale==2 then
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_TWO)
_scale=3
end
this.TimeScaleTxt.text = _scale
-- local child = this.BtnTimeScale.transform.childCount - 2 -- 3倍速时-2
-- local s = "x".. math.floor(_scale)
-- for i=1, child do
-- local g = this.BtnTimeScale.transform:GetChild(i-1).gameObject
-- g:SetActive(g.name == s)
-- end
end
function this.BattleEnd(result)
LogGreen(tostring(result))
BattleManager.PauseBattle()
-- 强制停止倍速
Time.timeScale = 1
-- 设置音效播放的速度
SoundManager.SetAudioSpeed(1)
--用一个变量接收最近的战斗结果
this.lastBattleResult = {
result = result,
hpList = {},
drop = {},
}
LogGreen("fightType:"..fightType)
-- 需要和服务器确认结果
if fightType == BATTLE_TYPE.MAP_FIGHT
or fightType == BATTLE_TYPE.MONSTER_CAMP
or fightType == BATTLE_TYPE.STORY_FIGHT
or fightType == BATTLE_TYPE.GUILD_BOSS then
local levelId = FightPointPassManager.GetCurFightId()
NetManager.MapFightResultRequest(10000, "", levelId, fightType, function (msg)
-- 结果检测
if msg.result ~= this.lastBattleResult.result then
BattleRecordManager.SubmitCheckFight(this.lastBattleResult.result, msg.result)
end
for i=1, #msg.remainHpList do
Log("服务器剩余血量 : "..msg.remainHpList[i])
this.lastBattleResult.hpList[i] = msg.remainHpList[i]
end
this.lastBattleResult.drop = msg.enventDrop
this.lastBattleResult.missionDrop = msg.missionDrop
this.lastBattleResult.result = msg.result
this.lastBattleResult.mission = msg.mission
this.lastBattleResult.eventId = msg.eventId
this.lastBattleResult.lastTowerTime = msg.lastTowerTime
if msg.lastXY then
this.lastBattleResult.lastPos = msg.lastXY
else
this.lastBattleResult.lastPos = 0
end
BattleManager.SetLastBattleResult(this.lastBattleResult,fightType)
this.ShowBattleResult(msg.result, msg)
end)
elseif fightType == BATTLE_TYPE.EXECUTE_FIGHT then--远征处理
if ExpeditionManager.ExpeditionState == 1 then
local GetCurNodeInfo = ExpeditionManager.curAttackNodeInfo
NetManager.EndExpeditionBattleRequest(GetCurNodeInfo.sortId, "", function (msg)
--ExpeditionManager.UpdateHeroHpValue(msg.heroInfo)
--ExpeditionManager.UpdateNodeValue(msg) --nodeInfo
if msg.result ~= this.lastBattleResult.result then
BattleRecordManager.SubmitCheckFight(this.lastBattleResult.result, msg.result)
end
this.lastBattleResult.result = msg.result
this.lastBattleResult.drop = msg.drop
BattleManager.SetLastBattleResult(this.lastBattleResult,fightType)
this.ShowBattleResult(msg.result, msg)
end)
else
--
this:ClosePanel()
ExpeditionManager.RefreshPanelShowByState()
end
elseif fightType == BATTLE_TYPE.XINJIANG then--新将来袭
Timer.New(function ()
this:ClosePanel()
for i = 1, #boxList do
boxList[i].transform:SetParent(this.dmg2.transform)
boxList[i].transform:DOLocalMove(Vector3.New(414,16,0), 0)
boxList[i]:SetActive(false)
Util.GetGameObject(boxList[i], "effect"):SetActive(false)
end
end,1.3):Start()
elseif fightType == BATTLE_TYPE.TASUILINGXIAO then--踏碎凌霄
BattleManager.SetLastBattleResult(this.lastBattleResult,fightType)
this.ShowBattleResult(result)
else
-- 判断是否需要进行结果检测
if this.fightResult then
if result ~= this.fightResult then
BattleRecordManager.SubmitCheckFight(result, this.fightResult)
end
end
-- 直接显示结果
if fightType ~= BATTLE_TYPE.BACK_BATTLE then
BattleManager.SetLastBattleResult(this.lastBattleResult,fightType)
end
this.ShowBattleResult(result)
end
end
function this.ShowBattleResult(result, msg)
SoundManager.StopMusic()
-- 战斗结束时,如果元素光环面板还开着,则先关闭
if UIManager.IsOpen(UIName.ElementPopup) then
UIManager.ClosePanel(UIName.ElementPopup)
end
-- 回放直接关闭界面
if fightType == BATTLE_TYPE.BACK or fightType == BATTLE_TYPE.ARENA or fightType == BATTLE_TYPE.LINGMAIMIJING then
this:ClosePanel()
return
end
-- 播放结算音效
if result == 0 then
this.resultSoundAudio = SoundManager.PlaySound(SoundConfig.Sound_BattleLose)
else
--this.resultSoundAudio = SoundManager.PlaySound(SoundConfig.Sound_BattleWin)
end
-- 公会boss结算界面
if fightType == BATTLE_TYPE.GUILD_BOSS then
UIManager.OpenPanel(UIName.GuildBossFightResultPopup, msg.enventDrop, msg.missionDrop, msg.essenceValue, function()
this:ClosePanel()
end)
-- 车迟斗法结算界面特殊显示
elseif fightType == BATTLE_TYPE.GUILD_CAR_DELAY and GuildCarDelayManager.progress == 1 then
this.ShowBattleResultByCarDeleayType()
-- 十绝阵结算界面特殊显示
elseif fightType == BATTLE_TYPE.DEATH_POS then
this.ShowBattleResultByDeathPos()
--公会副本
elseif fightType == BATTLE_TYPE.GuildTranscript then
this.ShowBattleResultByGuildTranscript()
--罗浮争锋
elseif fightType == BATTLE_TYPE.JumpServerhightLadder then
this.ShowBattleResultByJumpServerHightLadder(result)
--新回放功能(判断上次战斗是什么类型并做什么内容 逻辑和正常战斗处理一样)
elseif fightType == BATTLE_TYPE.BACK_BATTLE then
if BattleManager.GetLastBattleType() == BATTLE_TYPE.GuildTranscript then-- 公会副本结算界面特殊显示
this.ShowBattleResultByGuildTranscript()
elseif BattleManager.GetLastBattleType() == BATTLE_TYPE.GUILD_CAR_DELAY and GuildCarDelayManager.progress == 1 then-- 车迟结算界面特殊显示
this.ShowBattleResultByCarDeleayType()
elseif BattleManager.GetLastBattleType() == BATTLE_TYPE.DEATH_POS then-- 十绝阵结算界面特殊显示
this.ShowBattleResultByDeathPos()
elseif BattleManager.GetLastBattleType() == BATTLE_TYPE.BACK or BattleManager.GetLastBattleType() == BATTLE_TYPE.ARENA then
this:ClosePanel()
elseif BattleManager.GetLastBattleType() == BATTLE_TYPE.TASUILINGXIAO then
this.ShowBattleResultByTaSuiLingXiao()
elseif BattleManager.GetLastBattleType() == BATTLE_TYPE.JumpServerhightLadder then
this.ShowBattleResultByJumpServerHightLadder(result)
elseif BattleManager.GetLastBattleType() == BATTLE_TYPE.LINGMAIMIJING then
this:ClosePanel()
elseif BattleManager.GetLastBattleType() == BATTLE_TYPE.CHALLENG_COPY_1 or BattleManager.GetLastBattleType() == BATTLE_TYPE.CHALLENG_COPY_2 then
--只显示胜利界面
UIManager.OpenPanel(UIName.BattleWinPopup, this, isBack, fightType, this.lastBattleResult)
else
if result == 0 then -- 失败
local haveRecord = BattleRecordManager.isHaveRecord()
UIManager.OpenPanel(UIName.BattleFailPopup, this, haveRecord,nil,fightType)
else -- 胜利
LogRed("isBack:"..tostring(isBack))
UIManager.OpenPanel(UIName.BattleWinPopup, this, isBack, fightType, this.lastBattleResult)
end
end
elseif fightType == BATTLE_TYPE.TASUILINGXIAO then
this.ShowBattleResultByTaSuiLingXiao()
elseif fightType == BATTLE_TYPE.LINGMAIMIJING then
this:ClosePanel()
elseif BattleManager.GetLastBattleType() == BATTLE_TYPE.CHALLENG_COPY_1 or BattleManager.GetLastBattleType() == BATTLE_TYPE.CHALLENG_COPY_2 then
--只显示胜利界面
UIManager.OpenPanel(UIName.BattleWinPopup, this, isBack, fightType, this.lastBattleResult)
elseif BattleManager.GetLastBattleType()==BATTLE_TYPE.QIJIE_FIGHT then
LogRed("result:"..tostring(result))
if result == 0 then -- 失败
local haveRecord = BattleRecordManager.isHaveRecord()
UIManager.OpenPanel(UIName.BattleFailPopup, this, haveRecord,nil,fightType)
else -- 胜利
PrivilegeManager.RefreshPrivilegeUsedTimes(3201, 1)--更新特权
UIManager.OpenPanel(UIName.BattleWinPopup, this, isBack, fightType, this.lastBattleResult)
end
else
LogRed("result:"..tostring(result))
if result == 0 then -- 失败
local haveRecord = BattleRecordManager.isHaveRecord()
UIManager.OpenPanel(UIName.BattleFailPopup, this, haveRecord,nil,fightType)
else -- 胜利
UIManager.OpenPanel(UIName.BattleWinPopup, this, isBack, fightType, this.lastBattleResult)
end
end
end
-- 车迟斗法结算界面特殊显示
function this.ShowBattleResultByCarDeleayType()
-- 延时执行避免事件冲突
Timer.New(function()
local bestData, allDamage= BattleRecordManager.GetBattleBestData()
if bestData then
if fightType == BATTLE_TYPE.GUILD_CAR_DELAY then
--车迟挑战cd计时
GuildCarDelayManager.SetCdTime(GuildCarDelayProType.Challenge)
end
-- 胜利显示本场比赛的表现最好的英雄
UIManager.OpenPanel(UIName.BattleBestPopup, bestData.roleId,bestData.skinId, bestData.damage, allDamage, function(_BattleBestPopup)
-- 打开关卡奖励界面
UIManager.OpenPanel(UIName.RewardItemPopup,nil, 1,function(isBackBattle)--isBackBattle true时 为回放不走回调
LogPink("isBackBattle "..tostring(isBackBattle))
if not isBackBattle then
if _BattleBestPopup then
_BattleBestPopup:ClosePanel()
end
this:ClosePanel()
end
end, 3,true,true)
end)
end
end, 0.1):Start()
end
-- 罗浮争锋结算界面特殊显示
function this.ShowBattleResultByJumpServerHightLadder(_result)
if _result == 0 then -- 失败
if fightType == BATTLE_TYPE.JumpServerhightLadder then
PopupTipPanel.ShowTip("挑战失败,罗浮争锋排行无变化!")
if JumpServerManager.curBattleDrop.itemlist ~= nil and #JumpServerManager.curBattleDrop.itemlist > 0 then
local content = {}
for i = 1, #JumpServerManager.curBattleDrop.itemlist do
local itemdata = {}
itemdata.configData = itemConfig[JumpServerManager.curBattleDrop.itemlist[i].itemId]
itemdata.name = GetLanguageStrById(itemdata.configData.Name)
itemdata.icon = this.spLoader:LoadSprite(GetResourcePath(itemdata.configData.ResourceID))
itemdata.num = JumpServerManager.curBattleDrop.itemlist[i].itemNum
table.insert(content, itemdata)
end
PopupText(content, 0.5, 2)
end
end
local haveRecord = BattleRecordManager.isHaveRecord()
UIManager.OpenPanel(UIName.BattleFailPopup, this, haveRecord,nil,fightType)
else -- 胜利
UIManager.OpenPanel(UIName.BattleWinPopup, this, isBack, fightType, this.lastBattleResult)
end
end
-- 十绝阵结算界面特殊显示
function this.ShowBattleResultByDeathPos()
-- 延时执行避免事件冲突
Timer.New(function()
local bestData, allDamage= BattleRecordManager.GetBattleBestData()
if bestData then
-- 胜利显示本场比赛的表现最好的英雄
UIManager.OpenPanel(UIName.BattleBestPopup, bestData.roleId,bestData.skinId, bestData.damage, allDamage, function(_BattleBestPopup)
-- 打开关卡奖励界面
UIManager.OpenPanel(UIName.RewardItemPopup, DeathPosManager.drop, 1,function(isBackBattle)--isBackBattle true时 为回放不走回调
LogPink("isBackBattle "..tostring(isBackBattle))
if not isBackBattle then
if _BattleBestPopup then
_BattleBestPopup:ClosePanel()
end
this:ClosePanel()
end
end, 4,true,true)
end)
end
end, 0.1):Start()
end
--公会副本结算界面特殊显示
function this.ShowBattleResultByGuildTranscript()
-- 延时执行避免事件冲突
Timer.New(function()
local bestData, allDamage= BattleRecordManager.GetBattleBestData()
if bestData then
-- 胜利显示本场比赛的表现最好的英雄
UIManager.OpenPanel(UIName.BattleBestPopup, bestData.roleId,bestData.skinId, bestData.damage, allDamage, function(_BattleBestPopup)
-- 打开关卡奖励界面
UIManager.OpenPanel(UIName.RewardItemPopup,GuildTranscriptManager.drop, 1,function(isBackBattle)--isBackBattle true时 为回放不走回调
LogPink("isBackBattle "..tostring(isBackBattle))
if not isBackBattle then
if _BattleBestPopup then
_BattleBestPopup:ClosePanel()
end
this:ClosePanel()
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.RefreshGuildTranscripQuickBtn)
Game.GlobalEvent:DispatchEvent(GameEvent.Guild.RefreshGuildTranscript)
GuildTranscriptManager.IsKillShowTip()
end
end, 6,true,true)
end)
end
end, 0.1):Start()
end
--无尽结算界面特殊显示
function this.ShowBattleResultByMapFight()
local haveRecord = BattleRecordManager.isHaveRecord()
UIManager.OpenPanel(UIName.BattleFailPopup, this, haveRecord,nil,fightType)
end
-- 踏碎凌霄结算界面特殊显示
function this.ShowBattleResultByTaSuiLingXiao()
-- 延时执行避免事件冲突
Timer.New(function()
local bestData, allDamage= BattleRecordManager.GetBattleBestData()
if bestData then
-- 胜利显示本场比赛的表现最好的英雄
UIManager.OpenPanel(UIName.BattleBestPopup, bestData.roleId,bestData.skinId, bestData.damage, allDamage, function(_BattleBestPopup)
-- 打开关卡奖励界面
UIManager.OpenPanel(UIName.RewardItemPopup, CommonActPageManager.TaSuiLingXiaoMsg.drop, 1,function(isBackBattle)
LogPink("isBackBattle "..tostring(isBackBattle))
if not isBackBattle then
if _BattleBestPopup then
_BattleBestPopup:ClosePanel()
end
this:ClosePanel()
end
end, 7,true,true)
end)
end
end, 0.1):Start()
end
function this.ShowBattleResultByLingMaiMiJing()
-- 延时执行避免事件冲突
Timer.New(function()
local bestData, allDamage= BattleRecordManager.GetBattleBestData()
if bestData then
-- 胜利显示本场比赛的表现最好的英雄
UIManager.OpenPanel(UIName.BattleBestPopup, bestData.roleId,bestData.skinId, bestData.damage, allDamage, function(_BattleBestPopup)
-- 打开关卡奖励界面
UIManager.OpenPanel(UIName.RewardItemPopup, CommonActPageManager.TaSuiLingXiaoMsg.drop, 1,function(isBackBattle)
LogPink("isBackBattle "..tostring(isBackBattle))
if not isBackBattle then
if _BattleBestPopup then
_BattleBestPopup:ClosePanel()
end
this:ClosePanel()
end
end, 7,true,true)
end)
end
end, 0.1):Start()
end
-- 战斗波次变化回调
function this.OnOrderChanged(order)
-- body
--显示波次
this.orderText.text = string.format("%d/%d", order, BattleLogic.TotalOrder)
end
-- 战斗回合变化回调
this.curRound = 1
function this.OnRoundChanged(round)
-- 轮数变化
this.curRound = round
--显示波次
local curRound, maxRound = BattleLogic.GetCurRound()
curRound = curRound <= 0 and 1 or curRound -- 最小显示第一回合
if curRound>maxRound then
curRound=maxRound
end
this.roundText.text = string.format(Language[10211], curRound, maxRound)
-- 设置跳过按钮的状态
this.SetJumpBtnState()
end
-- 角色轮转回调
function this.RoleTurnChange(role)
GuideBattleLogic:RoleTurnChange(this.curRound, role)
-- 设置跳过按钮的状态
-- this.SetJumpBtnState()
end
-- 由BattleView驱动
function this.OnUpdate()
end
-- 刷新我的伤害显示
function this.RefreshMyDamageShow(role)
if fightType == 7 or fightType == 10 then
local myDamage = this.myDamage-- *10
local bossRewardConfig = ConfigManager.GetConfig(ConfigName.GuildBossRewardConfig)
local curLevel, curLevelData, nextLevelData
for level, data in ConfigPairs(bossRewardConfig) do
if data.Damage > myDamage then
nextLevelData = data
break
end
curLevel = level
curLevelData = data
end
if not nextLevelData then
nextLevelData = curLevelData
end
-- 有等级变化
if curLevel ~= this.myDamageLevel then
this.myDamageLevel = curLevel
-- 播放升级特效
this.damageBoxBg:SetActive(false)
this.damageBoxBg:SetActive(true)
end
this.damageBoxLevel.text = curLevel or 0
this.damageBoxIcon.sprite = this.spLoader:LoadSprite(GuildBossManager.GetBoxSpriteByLevel(curLevel or 0))
-- this.damageText.text = myDamage.."/"..nextLevelData.Damage -- 显示总伤害
local curLevelDamage = not curLevelData and 0 or curLevelData.Damage
local deltaDamage = nextLevelData.Damage - curLevelDamage
local myDeltaDamage = myDamage - curLevelDamage
local rate = deltaDamage == 0 and 1 or myDeltaDamage/deltaDamage
this.damageText.text = myDeltaDamage.."/"..deltaDamage -- 显示当前等级伤害
this.damageProgress.transform.localScale = Vector3.New(rate, 1, 1)
elseif fightType == BATTLE_TYPE.XINJIANG and role then--新将来袭
local myDamage = this.myDamage-- *10
local curLevel = 0
local boxs={}
local newHeroConfig = ConfigManager.GetConfig(ConfigName.NewHeroConfig)
local bossData = role.data
local curBossHp = role.data:GetData(RoleDataName.Hp)
local maxBossHp = role.data:GetData(RoleDataName.MaxHp)
local curPercent = (maxBossHp-curBossHp)*100/maxBossHp
curPercent = curPercent > 0.01 and curPercent or 0.01
this.dmg2Text.text = string.format("%.2f",curPercent).."%"
local num = 0
local d = ConfigManager.GetConfigDataByKey(ConfigName.NewHeroConfig,"HeroId",role.roleId)
boxs = d.BoxList
for i = 1, #boxs do
local ex = boxs[i-1] and boxs[i-1][1] or 0
if (boxs[i][1]/boxs[#boxs][1])*100 > curPercent and (ex/boxs[#boxs][1])*100 < curPercent then
num = (curPercent*100-ex)/(boxs[i][1]-ex)
curLevel = i
break
end
end
this.dmg2Progress.fillAmount = num
for i = 1, #boxs do
if curPercent >= (boxs[i][1]/boxs[#boxs][1])*100 then
if boxList[i+1] then
boxList[i+1]:SetActive(true)
end
boxList[i].transform:SetParent(this.bar.transform)
local t = i%5 == 0 and 5 or i%5
boxList[i].transform:DOLocalMove(Vector3.New(math.floor(i/6)*-120,-329+t*100,0), 1.5)
Util.GetGameObject(boxList[i], "effect"):SetActive(true)
end
end
elseif fightType == BATTLE_TYPE.TASUILINGXIAO and role then--踏碎凌霄
local myDamage = this.myDamage-- *10
local curLevel = 0
local boxs={}
local newHeroConfig = ConfigManager.GetConfig(ConfigName.NewHeroConfig)
local bossData = role.data
-- local curBossHp = role.data:GetData(RoleDataName.Hp)
local maxBossHp = role.data:GetData(RoleDataName.MaxHp)
local num1,num2 = 0,0
local actData = CommonActPageManager.GetData(ActivityTypeDef.TaSuiLingXiao)
local boxs = ConfigManager.GetConfigDataByKey(ConfigName.NewHeroConfig,"Id",actData.activityId).BoxList
for i = 1, #boxs do
local lastValue = boxs[i-1] and boxs[i-1][1] or 0
if myDamage < boxs[i][1] then
num1 = myDamage - lastValue
num2 = boxs[i][1] - lastValue
curLevel = i
break
else
num1 = boxs[i][1] - lastValue
num2 = boxs[i][1] - lastValue
end
end
this.dmg3Text.text = string.format("%s/%s",num1,num2)
this.dmg3Progress.fillAmount = num1/num2
LogGreen(#boxs)
for i = 1, #boxs do
LogGreen(tostring(myDamage).."|"..tostring(boxs[i][1]))
if myDamage >= boxs[i][1] then
if boxList2[i+1] then
boxList2[i+1].obj:SetActive(true)
end
if boxs[i][1] < CommonActPageManager.TaSuiLingXiaoHistoryDmg then
boxList2[i].obj:SetActive(false)
else
if not boxList2[i].moved then
boxList2[i].obj.transform:SetParent(this.bar3.transform)
boxList2[i].obj.transform:DOLocalMove(Vector3.New(math.random(-400, 400),math.random(-100, 100),0), 1.5)
boxList2[i].moved = true
Util.GetGameObject(boxList2[i].obj, "effect"):SetActive(true)
end
end
end
end
end
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
BattleView:OnClose()
-- 停止音效
--if this.resultSoundAudio then
-- SoundManager.StopSound(this.resultSoundAudio)
--end
--
-- BattleManager.SetTimeScale(1)
-- 真正生效的敌方
Time.timeScale = 1
-- 设置音效播放的速度
SoundManager.SetAudioSpeed(1)
if endFunc then
endFunc(this.lastBattleResult)
end
--检测是否需要弹每日任务飘窗
TaskManager.RefreshShowDailyMissionTipPanel()
for i = 1, #boxList2 do
destroy(boxList2[i].obj)
end
boxList2 = {}
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
BattleView:OnDestroy()
this.spLoader:Destroy()
end
return BattlePanel