2021-04-21 13:12:04 +08:00
require ( " Base/BasePanel " )
2020-05-09 13:31:21 +08:00
require ( " Base/Stack " )
require ( " Modules.Battle.Config.PokemonEffectConfig " )
local BattleView = require ( " Modules/Battle/View/BattleView " )
2021-03-19 18:14:52 +08:00
local GuideBattleLogic = require ( " Modules/Battle/View/GuideBattleLogic " )
2020-05-09 13:31:21 +08:00
BattlePanel = Inherit ( BasePanel )
local this = BattlePanel
local battleTimeScaleKey = " battleTimeScaleKey "
2021-04-26 16:20:22 +08:00
local ArtResourcesConfig = ConfigManager.GetConfig ( ConfigName.ArtResourcesConfig )
2020-05-09 13:31:21 +08:00
local timeCount
local endFunc
local isBack = false --是否为战斗回放
local fightType -- 1关卡 2副本 3限时怪, 5兽潮, 6新关卡, 7公会boss
local orginLayer
2020-12-03 15:11:24 +08:00
local boxList = { } --新将来袭奖励盒子
2021-04-26 16:20:22 +08:00
local boxList2 = { } --踏碎凌霄奖励盒子
2020-05-09 13:31:21 +08:00
-- 显示跳过战斗使用
local hadCounted = 0
2021-05-24 19:20:22 +08:00
local SKIP_STATE = {
UNLOCK = 0 ,
LOCK = 1 ,
NOUSE = 2 ,
}
2021-05-13 21:15:24 +08:00
local UpdateBtnGMFunc = {
[ - 1 ] = function ( )
2021-05-24 19:20:22 +08:00
if not BattleManager.IsUnlockBattlePass ( ) then
return SKIP_STATE.LOCK , Language [ 12237 ]
end
return SKIP_STATE.UNLOCK
2021-05-13 21:15:24 +08:00
end ,
[ BATTLE_TYPE.BACK ] = function ( )
2021-05-24 19:20:22 +08:00
return SKIP_STATE.UNLOCK
2021-05-13 21:15:24 +08:00
end ,
[ BATTLE_TYPE.BACK_BATTLE ] = function ( )
2021-05-24 19:20:22 +08:00
return SKIP_STATE.UNLOCK
2021-05-13 21:15:24 +08:00
end ,
[ BATTLE_TYPE.Test ] = function ( )
2021-05-24 19:20:22 +08:00
return SKIP_STATE.UNLOCK
2021-05-13 21:15:24 +08:00
end ,
[ BATTLE_TYPE.MONSTER_CAMP ] = function ( )
2021-05-24 19:20:22 +08:00
return SKIP_STATE.UNLOCK
2021-05-13 21:15:24 +08:00
end ,
2021-05-27 16:16:21 +08:00
-- [BATTLE_TYPE.DAILY_CHALLENGE] = function()
-- return SKIP_STATE.NOUSE, "日常副本战斗无法跳过!"
-- end,
2021-05-21 15:31:40 +08:00
[ BATTLE_TYPE.STORY_FIGHT ] = function ( )
if not BattleManager.IsUnlockBattlePass ( ) then
2021-05-24 19:20:22 +08:00
return SKIP_STATE.LOCK , Language [ 12237 ]
2021-05-21 15:31:40 +08:00
end
2021-06-03 14:19:45 +08:00
-- if FightPointPassManager.GetCurOpenFightIdIsBoss() then
-- return SKIP_STATE.NOUSE, "首领关卡无法跳过!"
-- end
2021-05-24 19:20:22 +08:00
return SKIP_STATE.UNLOCK
2021-05-13 21:15:24 +08:00
end ,
}
2020-05-09 13:31:21 +08:00
2021-05-24 19:20:22 +08:00
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
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function this : InitComponent ( )
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New ( )
2020-10-31 17:01:46 +08:00
BattleView : InitComponent ( self , self.gameObject )
2020-05-09 13:31:21 +08:00
orginLayer = 0
2020-06-18 20:39:29 +08:00
this.BG = Util.GetGameObject ( self.gameObject , " BG " )
2020-05-09 13:31:21 +08:00
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 " )
2021-05-21 15:31:40 +08:00
this.BtnJumpFight = Util.GetGameObject ( this.DownRoot , " option/Button " )
this.jumpLock = Util.GetGameObject ( this.DownRoot , " option/Button/lock " )
2020-07-30 10:57:29 +08:00
this.submit = Util.GetGameObject ( this.DownRoot , " bg " )
2020-05-09 13:31:21 +08:00
this.DefResult = Util.GetGameObject ( this.UpRoot , " result " )
this.AtkResult = Util.GetGameObject ( this.DownRoot , " result " )
2020-12-03 15:11:24 +08:00
this.damagePanel = Util.GetGameObject ( this.UpRoot , " damage " ) --公会boss的血条
2020-05-09 13:31:21 +08:00
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 " )
2021-01-26 17:08:39 +08:00
2020-12-03 15:11:24 +08:00
this.dmg2 = Util.GetGameObject ( this.UpRoot , " dmg2 " ) --新将来袭的血条
2020-12-04 19:42:47 +08:00
for i = 1 , 7 do
2020-12-03 15:11:24 +08:00
boxList [ i ] = Util.GetGameObject ( this.dmg2 , " box " .. i )
boxList [ i ] : SetActive ( false )
2020-12-03 18:36:01 +08:00
local effect = Util.GetGameObject ( boxList [ i ] , " effect " )
effect : SetActive ( false )
2020-12-03 15:11:24 +08:00
end
2020-12-03 18:36:01 +08:00
boxList [ 1 ] : SetActive ( true )
2020-12-03 15:11:24 +08:00
this.dmg2Progress = Util.GetGameObject ( this.dmg2 , " progress/Fill " ) : GetComponent ( " Image " )
this.dmg2Text = Util.GetGameObject ( this.dmg2 , " progress/Text " ) : GetComponent ( " Text " )
2020-12-03 18:36:01 +08:00
this.bar = Util.GetGameObject ( this.dmg2 , " bar " )
2021-04-26 10:23:19 +08:00
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 " )
2021-04-26 16:20:22 +08:00
this.bar3 = Util.GetGameObject ( this.dmg3 , " bar " )
this.boxpre = Util.GetGameObject ( this.dmg3 , " boxpre " )
2020-05-09 13:31:21 +08:00
end
--绑定事件(用于子类重写)
function this : BindEvent ( )
2020-07-30 10:57:29 +08:00
Util.AddLongPressClick ( this.submit , function ( )
BattleRecordManager.SubmitBattleRecord ( )
end , 0.5 )
2020-05-09 13:31:21 +08:00
Util.AddClick ( this.BtnTimeScale , function ( )
2020-05-15 16:52:35 +08:00
if not BattleManager.IsCanOperate ( ) then
2020-05-09 13:31:21 +08:00
return
end
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
BattleManager.SetTimeScale ( BATTLE_TIME_SCALE_ONE )
end
end )
2021-05-24 19:20:22 +08:00
-- 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)
2020-05-09 13:31:21 +08:00
2021-05-21 15:31:40 +08:00
Util.AddClick ( this.BtnJumpFight , function ( )
2021-05-24 19:20:22 +08:00
local state , tip = self : GetSkipState ( )
if state ~= SKIP_STATE.UNLOCK then
if tip then
PopupTipPanel.ShowTip ( tip )
end
return
end
2020-05-15 16:52:35 +08:00
if BattleManager.IsCanOperate ( ) and not BattleLogic.IsEnd then
2020-07-15 17:33:19 +08:00
BattleView.EndBattle ( )
2020-05-09 13:31:21 +08:00
BattleLogic.IsEnd = true
end
end )
end
function this : LoseJump ( id )
2020-11-16 15:24:09 +08:00
if not MapManager.Mapping then
2020-05-09 13:31:21 +08:00
if JumpManager.CheckJump ( id ) then
this : ClosePanel ( )
JumpManager.GoJumpWithoutTip ( id )
end
else
2021-04-09 12:26:35 +08:00
PopupTipPanel.ShowTip ( Language [ 10210 ] )
2020-05-09 13:31:21 +08:00
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 )
2021-04-27 22:30:17 +08:00
for _ , v in pairs ( boxList2 ) do
Util.AddParticleSortLayer ( v.obj , this.sortingOrder - orginLayer )
end
2020-05-09 13:31:21 +08:00
orginLayer = this.sortingOrder
2020-05-15 16:52:35 +08:00
BattleView : OnSortingOrderChange ( this.sortingOrder )
2020-05-09 13:31:21 +08:00
end
2021-04-27 13:32:41 +08:00
function this : IsBossFight ( fightType )
if fightType == BATTLE_TYPE.TASUILINGXIAO then
return true
end
return false
end
2020-05-09 13:31:21 +08:00
--界面打开时调用(用于子类重写)
2021-05-24 20:22:38 +08:00
function this : OnOpen ( _fightData , _fightType , _endFunc , _guideType , isChangeBGM )
2021-03-19 18:14:52 +08:00
GuideBattleLogic : Init ( _guideType )
2021-04-27 13:32:41 +08:00
BattleView : OnOpen ( _fightData , _fightType , this : IsBossFight ( _fightType ) )
2020-05-09 13:31:21 +08:00
endFunc = _endFunc
2020-06-03 19:09:01 +08:00
fightType = _fightType --判定战斗类型
isBack = _fightType == BATTLE_TYPE.BACK --判定是否是战斗回放
2020-05-09 13:31:21 +08:00
hadCounted = 0
2021-01-06 16:12:54 +08:00
LogPink ( fightType )
2021-04-21 13:12:04 +08:00
this.BG : GetComponent ( " Image " ) . sprite = this.spLoader : LoadSprite ( BattleManager.GetBattleBg ( fightType ) )
2020-05-09 13:31:21 +08:00
2021-05-18 17:18:52 +08:00
-- SoundManager.PlayMusic(SoundConfig.BGM_Battle_1, true, function()
2021-05-24 20:22:38 +08:00
if not isChangeBGM then
SoundManager.PlayMusic ( SoundConfig.BGM_Battle_2 , false )
end
2021-05-18 17:18:52 +08:00
-- end)
2020-05-09 13:31:21 +08:00
2020-06-03 19:09:01 +08:00
this.fightResult = nil
-- 清空名字数据
BattleView : SetNameStr ( nil )
this.DefResult : SetActive ( false )
this.AtkResult : SetActive ( false )
2021-03-19 18:14:52 +08:00
-- 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
2020-05-09 13:31:21 +08:00
-- 开始战斗
BattleView : StartBattle ( )
this.InitPanelData ( )
end
2020-06-03 19:09:01 +08:00
-- 设置战斗结果
function this : SetResult ( result )
this.fightResult = result
end
-- 外部调用
function this : ShowNameShow ( result , str )
this.fightResult = result
2021-01-22 11:57:56 +08:00
if true then return end
2020-06-03 19:09:01 +08:00
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
2020-05-09 13:31:21 +08:00
-- 初始化
function this . InitPanelData ( )
2020-12-03 15:11:24 +08:00
this.dmg2 : SetActive ( fightType == BATTLE_TYPE.XINJIANG )
2021-04-26 20:45:42 +08:00
this.dmg3 : SetActive ( fightType == BATTLE_TYPE.TASUILINGXIAO )
2020-06-03 19:09:01 +08:00
if fightType == BATTLE_TYPE.GUILD_BOSS and fightType == BATTLE_TYPE.GUILD_CAR_DELAY then
2020-05-09 13:31:21 +08:00
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
2020-12-03 15:11:24 +08:00
elseif fightType == BATTLE_TYPE.XINJIANG then
2020-12-03 18:36:01 +08:00
boxList [ 1 ] : SetActive ( true )
2020-12-03 15:11:24 +08:00
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
2021-01-27 17:05:47 +08:00
this.RefreshMyDamageShow ( list [ 1 ] )
2020-12-03 15:11:24 +08:00
end )
end
2021-04-26 10:23:19 +08:00
elseif fightType == BATTLE_TYPE.TASUILINGXIAO then --踏碎凌霄
2021-04-26 16:20:22 +08:00
boxList2 = { }
local actData = CommonActPageManager.GetData ( ActivityTypeDef.TaSuiLingXiao )
local boxs = ConfigManager.GetConfigDataByKey ( ConfigName.NewHeroConfig , " Id " , actData.activityId ) . BoxList
local maxDmg = actData.value
2021-04-26 10:23:19 +08:00
this.myDamage = 0
this.myDamageLevel = 0
2021-04-26 16:20:22 +08:00
this.dmg3Text . text = string.format ( " 0/%s " , boxs [ 1 ] [ 1 ] )
2021-04-26 10:23:19 +08:00
this.dmg3Progress . fillAmount = 0
2021-04-26 16:20:22 +08:00
for i = 1 , # actData.rewards do
local index = # boxList2 + 1
2021-04-26 16:46:03 +08:00
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 )
2021-05-19 15:06:02 +08:00
Util.GetGameObject ( boxList2 [ index ] . obj , " iconRoot/icon " ) : GetComponent ( " Image " ) . sprite = this.spLoader : LoadSprite ( ArtResourcesConfig [ boxs [ i ] [ 2 ] ] . Name )
2021-04-26 16:20:22 +08:00
end
if # boxList2 > 0 then
boxList2 [ 1 ] . obj : SetActive ( true )
end
2021-04-26 10:23:19 +08:00
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
2020-12-02 17:14:52 +08:00
end
2020-05-09 13:31:21 +08:00
2021-05-24 19:20:22 +08:00
this : InitOption ( )
2020-05-09 13:31:21 +08:00
end
2021-05-24 19:20:22 +08:00
function this : InitOption ( )
2020-05-09 13:31:21 +08:00
--显示倒计时
local curRound , maxRound = BattleLogic.GetCurRound ( )
2020-11-02 19:15:17 +08:00
curRound = curRound <= 0 and 1 or curRound -- 最小显示第一回合
2021-02-19 15:47:06 +08:00
if curRound > maxRound then
curRound = maxRound
end
2021-04-09 12:26:35 +08:00
this.roundText . text = string.format ( Language [ 10211 ] , curRound , maxRound )
2020-05-09 13:31:21 +08:00
hadCounted = 0
2020-05-15 16:52:35 +08:00
this.Option : SetActive ( true )
2020-05-09 13:31:21 +08:00
Util.GetGameObject ( this.BtnTimeScale , " lock " ) : SetActive ( not BattleManager.IsUnlockBattleSpeed ( ) )
2021-05-18 17:18:52 +08:00
2021-05-24 19:20:22 +08:00
local state , tip = self : GetSkipState ( )
this.jumpLock : SetActive ( state == SKIP_STATE.LOCK )
Util.SetColor ( this.BtnJumpFight , state == SKIP_STATE.NOUSE and UIColor.DEEPGRAY or UIColor.WRITE )
2020-05-09 13:31:21 +08:00
-- 初始化战斗时间,刷新前端显示
BattleManager.InitTimeScale ( )
this.SwitchTimeScale ( )
end
function this . SwitchTimeScale ( )
local _scale = BattleManager.GetTimeScale ( )
local child = this.BtnTimeScale . transform.childCount - 3 -- 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 )
BattleManager.PauseBattle ( )
2020-05-25 19:16:23 +08:00
-- 强制停止倍速
Time.timeScale = 1
2020-07-13 17:53:15 +08:00
-- 设置音效播放的速度
SoundManager.SetAudioSpeed ( 1 )
2020-05-09 13:31:21 +08:00
--用一个变量接收最近的战斗结果
this.lastBattleResult = {
result = result ,
hpList = { } ,
drop = { } ,
}
2021-05-25 20:37:12 +08:00
LogGreen ( " fightType: " .. fightType )
2020-06-03 19:09:01 +08:00
-- 需要和服务器确认结果
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 ( )
2020-05-09 13:31:21 +08:00
NetManager.MapFightResultRequest ( 10000 , " " , levelId , fightType , function ( msg )
2020-11-02 16:05:24 +08:00
-- 结果检测
if msg.result ~= this.lastBattleResult . result then
2021-01-22 12:20:53 +08:00
BattleRecordManager.SubmitCheckFight ( this.lastBattleResult . result , msg.result )
2020-11-02 16:05:24 +08:00
end
2020-05-09 13:31:21 +08:00
for i = 1 , # msg.remainHpList do
2021-01-09 14:20:06 +08:00
Log ( " 服务器剩余血量 : " .. msg.remainHpList [ i ] )
2020-05-09 13:31:21 +08:00
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
2021-01-06 16:12:54 +08:00
BattleManager.SetLastBattleResult ( this.lastBattleResult , fightType )
2020-05-09 13:31:21 +08:00
this.ShowBattleResult ( msg.result , msg )
end )
2020-06-03 19:09:01 +08:00
elseif fightType == BATTLE_TYPE.EXECUTE_FIGHT then --远征处理
2020-06-28 17:52:29 +08:00
if ExpeditionManager.ExpeditionState == 1 then
local GetCurNodeInfo = ExpeditionManager.curAttackNodeInfo
NetManager.EndExpeditionBattleRequest ( GetCurNodeInfo.sortId , " " , function ( msg )
--ExpeditionManager.UpdateHeroHpValue(msg.heroInfo)
--ExpeditionManager.UpdateNodeValue(msg) --nodeInfo
2020-11-02 16:05:24 +08:00
if msg.result ~= this.lastBattleResult . result then
2021-01-22 12:20:53 +08:00
BattleRecordManager.SubmitCheckFight ( this.lastBattleResult . result , msg.result )
2020-11-02 16:05:24 +08:00
end
this.lastBattleResult . result = msg.result
this.lastBattleResult . drop = msg.drop
2021-01-06 16:12:54 +08:00
BattleManager.SetLastBattleResult ( this.lastBattleResult , fightType )
2020-06-28 17:52:29 +08:00
this.ShowBattleResult ( msg.result , msg )
end )
else
2020-11-02 16:05:24 +08:00
--
2020-06-28 17:52:29 +08:00
this : ClosePanel ( )
ExpeditionManager.RefreshPanelShowByState ( )
end
2020-12-03 15:11:24 +08:00
elseif fightType == BATTLE_TYPE.XINJIANG then --新将来袭
Timer.New ( function ( )
this : ClosePanel ( )
2020-12-03 18:36:01 +08:00
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
2020-12-03 15:11:24 +08:00
end , 1.3 ) : Start ( )
2021-04-26 10:23:19 +08:00
elseif fightType == BATTLE_TYPE.TASUILINGXIAO then --踏碎凌霄
2021-04-26 16:53:36 +08:00
BattleManager.SetLastBattleResult ( this.lastBattleResult , fightType )
2021-04-26 10:23:19 +08:00
this.ShowBattleResult ( result )
2020-06-03 19:09:01 +08:00
else
2020-11-02 16:05:24 +08:00
-- 判断是否需要进行结果检测
if this.fightResult then
if result ~= this.fightResult then
2021-01-22 12:20:53 +08:00
BattleRecordManager.SubmitCheckFight ( this.fightResult , result )
2020-11-02 16:05:24 +08:00
end
end
2020-06-03 19:09:01 +08:00
-- 直接显示结果
2021-01-06 16:12:54 +08:00
if fightType ~= BATTLE_TYPE.BACK_BATTLE then
BattleManager.SetLastBattleResult ( this.lastBattleResult , fightType )
end
2020-06-03 19:09:01 +08:00
this.ShowBattleResult ( result )
2020-05-09 13:31:21 +08:00
end
end
function this . ShowBattleResult ( result , msg )
SoundManager.StopMusic ( )
-- 战斗结束时,如果元素光环面板还开着,则先关闭
if UIManager.IsOpen ( UIName.ElementPopup ) then
UIManager.ClosePanel ( UIName.ElementPopup )
end
2020-06-03 19:09:01 +08:00
-- 回放直接关闭界面
2020-09-27 18:27:20 +08:00
if fightType == BATTLE_TYPE.BACK or fightType == BATTLE_TYPE.ARENA then
2020-05-09 13:31:21 +08:00
this : ClosePanel ( )
2020-06-03 19:09:01 +08:00
return
end
-- 播放结算音效
if result == 0 then
this.resultSoundAudio = SoundManager.PlaySound ( SoundConfig.Sound_BattleLose )
2020-05-09 13:31:21 +08:00
else
2020-06-03 19:09:01 +08:00
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
2021-01-07 11:32:26 +08:00
this.ShowBattleResultByCarDeleayType ( )
2020-06-03 19:09:01 +08:00
-- 十绝阵结算界面特殊显示
elseif fightType == BATTLE_TYPE.DEATH_POS then
2021-01-07 11:32:26 +08:00
this.ShowBattleResultByDeathPos ( )
2020-08-20 20:05:38 +08:00
--公会副本
elseif fightType == BATTLE_TYPE.GuildTranscript then
2021-01-07 11:32:26 +08:00
this.ShowBattleResultByGuildTranscript ( )
2021-05-25 20:37:12 +08:00
-- --无尽副本
-- elseif fightType == BATTLE_TYPE.MAP_FIGHT and CarbonManager.difficulty == CARBON_TYPE.ENDLESS then
-- this.ShowBattleResultByMapFight()
2021-01-07 11:32:26 +08:00
--新回放功能(判断上次战斗是什么类型并做什么内容 逻辑和正常战斗处理一样)
2021-01-06 16:12:54 +08:00
elseif fightType == BATTLE_TYPE.BACK_BATTLE then
2021-01-07 11:32:26 +08:00
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 ( )
2021-01-07 18:03:57 +08:00
elseif BattleManager.GetLastBattleType ( ) == BATTLE_TYPE.BACK or BattleManager.GetLastBattleType ( ) == BATTLE_TYPE.ARENA then
this : ClosePanel ( )
2021-04-26 16:53:36 +08:00
elseif BattleManager.GetLastBattleType ( ) == BATTLE_TYPE.TASUILINGXIAO then
this.ShowBattleResultByTaSuiLingXiao ( )
2021-01-06 16:12:54 +08:00
else
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
2021-04-25 15:07:36 +08:00
elseif fightType == BATTLE_TYPE.TASUILINGXIAO then
this.ShowBattleResultByTaSuiLingXiao ( )
2020-06-03 19:09:01 +08:00
else
if result == 0 then -- 失败
local haveRecord = BattleRecordManager.isHaveRecord ( )
2020-06-13 11:47:13 +08:00
UIManager.OpenPanel ( UIName.BattleFailPopup , this , haveRecord , nil , fightType )
2020-06-03 19:09:01 +08:00
else -- 胜利
UIManager.OpenPanel ( UIName.BattleWinPopup , this , isBack , fightType , this.lastBattleResult )
2020-05-09 13:31:21 +08:00
end
end
end
2021-01-07 11:32:26 +08:00
-- 车迟斗法结算界面特殊显示
function this . ShowBattleResultByCarDeleayType ( )
-- 延时执行避免事件冲突
Timer.New ( function ( )
local bestData , allDamage = BattleRecordManager.GetBattleBestData ( )
if bestData then
2021-05-15 14:40:43 +08:00
if fightType == BATTLE_TYPE.GUILD_CAR_DELAY then
--车迟挑战cd计时
GuildCarDelayManager.SetCdTime ( GuildCarDelayProType.Challenge )
end
2021-01-07 11:32:26 +08:00
-- 胜利显示本场比赛的表现最好的英雄
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 . 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 ( )
2021-05-25 20:37:12 +08:00
local haveRecord = BattleRecordManager.isHaveRecord ( )
UIManager.OpenPanel ( UIName.BattleFailPopup , this , haveRecord , nil , fightType )
2021-01-07 11:32:26 +08:00
end
2021-04-25 15:07:36 +08:00
-- 踏碎凌霄结算界面特殊显示
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
2020-05-09 13:31:21 +08:00
-- 战斗波次变化回调
function this . OnOrderChanged ( order )
-- body
--显示波次
this.orderText . text = string.format ( " %d/%d " , order , BattleLogic.TotalOrder )
end
-- 战斗回合变化回调
2021-03-19 18:14:52 +08:00
this.curRound = 1
2020-05-09 13:31:21 +08:00
function this . OnRoundChanged ( round )
2021-03-19 18:14:52 +08:00
-- 轮数变化
this.curRound = round
2020-05-09 13:31:21 +08:00
--显示波次
local curRound , maxRound = BattleLogic.GetCurRound ( )
2020-11-02 19:15:17 +08:00
curRound = curRound <= 0 and 1 or curRound -- 最小显示第一回合
2021-02-19 16:04:56 +08:00
if curRound > maxRound then
curRound = maxRound
end
2021-04-09 12:26:35 +08:00
this.roundText . text = string.format ( Language [ 10211 ] , curRound , maxRound )
2020-05-09 13:31:21 +08:00
end
2021-03-19 18:14:52 +08:00
-- 角色轮转回调
function this . RoleTurnChange ( role )
GuideBattleLogic : RoleTurnChange ( this.curRound , role )
end
2020-05-09 13:31:21 +08:00
-- 由BattleView驱动
function this . OnUpdate ( )
end
-- 刷新我的伤害显示
2021-01-27 17:05:47 +08:00
function this . RefreshMyDamageShow ( role )
2020-05-09 13:31:21 +08:00
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
2021-04-21 13:12:04 +08:00
this.damageBoxIcon . sprite = this.spLoader : LoadSprite ( GuildBossManager.GetBoxSpriteByLevel ( curLevel or 0 ) )
2020-05-09 13:31:21 +08:00
-- this.damageText.text = myDamage.."/"..nextLevelData.Damage -- 显示总伤害
2020-12-03 15:11:24 +08:00
2020-05-09 13:31:21 +08:00
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 )
2020-12-03 15:11:24 +08:00
2021-04-25 15:07:36 +08:00
elseif fightType == BATTLE_TYPE.XINJIANG and role then --新将来袭
2020-12-03 15:11:24 +08:00
local myDamage = this.myDamage -- *10
2020-12-03 18:36:01 +08:00
local curLevel = 0
2020-12-03 15:11:24 +08:00
local boxs = { }
local newHeroConfig = ConfigManager.GetConfig ( ConfigName.NewHeroConfig )
2021-01-27 17:05:47 +08:00
local bossData = role.data
local curBossHp = role.data : GetData ( RoleDataName.Hp )
local maxBossHp = role.data : GetData ( RoleDataName.MaxHp )
2020-12-03 15:11:24 +08:00
local curPercent = ( maxBossHp - curBossHp ) * 100 / maxBossHp
2021-01-21 15:31:22 +08:00
curPercent = curPercent > 0.01 and curPercent or 0.01
2020-12-03 15:11:24 +08:00
this.dmg2Text . text = string.format ( " %.2f " , curPercent ) .. " % "
local num = 0
2021-01-27 17:05:47 +08:00
local d = ConfigManager.GetConfigDataByKey ( ConfigName.NewHeroConfig , " HeroId " , role.roleId )
2020-12-03 15:11:24 +08:00
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 )
2020-12-03 18:36:01 +08:00
curLevel = i
2020-12-03 15:11:24 +08:00
break
end
end
this.dmg2Progress . fillAmount = num
2020-12-03 18:36:01 +08:00
for i = 1 , # boxs do
if curPercent >= ( boxs [ i ] [ 1 ] / boxs [ # boxs ] [ 1 ] ) * 100 then
2020-12-04 19:42:47 +08:00
if boxList [ i + 1 ] then
boxList [ i + 1 ] : SetActive ( true )
end
2020-12-03 18:36:01 +08:00
boxList [ i ] . transform : SetParent ( this.bar . transform )
2020-12-04 19:42:47 +08:00
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 )
2020-12-03 18:36:01 +08:00
Util.GetGameObject ( boxList [ i ] , " effect " ) : SetActive ( true )
end
end
2021-04-25 15:07:36 +08:00
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
2021-04-26 10:23:19 +08:00
-- local curBossHp = role.data:GetData(RoleDataName.Hp)
2021-04-25 15:07:36 +08:00
local maxBossHp = role.data : GetData ( RoleDataName.MaxHp )
2021-04-26 16:20:22 +08:00
local num1 , num2 = 0 , 0
2021-04-25 15:07:36 +08:00
local actData = CommonActPageManager.GetData ( ActivityTypeDef.TaSuiLingXiao )
2021-04-26 10:23:19 +08:00
local boxs = ConfigManager.GetConfigDataByKey ( ConfigName.NewHeroConfig , " Id " , actData.activityId ) . BoxList
2021-04-25 15:07:36 +08:00
for i = 1 , # boxs do
local lastValue = boxs [ i - 1 ] and boxs [ i - 1 ] [ 1 ] or 0
if myDamage < boxs [ i ] [ 1 ] then
2021-04-26 16:20:22 +08:00
num1 = myDamage - lastValue
num2 = boxs [ i ] [ 1 ] - lastValue
2021-04-25 15:07:36 +08:00
curLevel = i
break
2021-04-26 16:20:22 +08:00
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
2020-12-03 18:36:01 +08:00
2021-04-27 22:30:17 +08:00
LogGreen ( # boxs )
2021-04-26 16:20:22 +08:00
for i = 1 , # boxs do
2021-04-27 22:30:17 +08:00
LogGreen ( tostring ( myDamage ) .. " | " .. tostring ( boxs [ i ] [ 1 ] ) )
2021-04-26 16:46:03 +08:00
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
2021-04-26 16:20:22 +08:00
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
2021-04-25 15:07:36 +08:00
end
end
2020-05-09 13:31:21 +08:00
end
end
--界面关闭时调用(用于子类重写)
function this : OnClose ( )
BattleView : OnClose ( )
-- 停止音效
--if this.resultSoundAudio then
-- SoundManager.StopSound(this.resultSoundAudio)
--end
--
2020-05-25 19:16:23 +08:00
-- BattleManager.SetTimeScale(1)
-- 真正生效的敌方
Time.timeScale = 1
2020-07-13 17:53:15 +08:00
-- 设置音效播放的速度
SoundManager.SetAudioSpeed ( 1 )
2020-05-09 13:31:21 +08:00
if endFunc then
endFunc ( this.lastBattleResult )
end
2020-06-13 11:47:13 +08:00
--检测是否需要弹每日任务飘窗
TaskManager.RefreshShowDailyMissionTipPanel ( )
2021-04-26 16:20:22 +08:00
for i = 1 , # boxList2 do
destroy ( boxList2 [ i ] . obj )
end
2021-04-28 01:51:16 +08:00
boxList2 = { }
2020-05-09 13:31:21 +08:00
end
--界面销毁时调用(用于子类重写)
function this : OnDestroy ( )
BattleView : OnDestroy ( )
2021-04-21 13:12:04 +08:00
this.spLoader : Destroy ( )
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return BattlePanel