miduo_client/Assets/ManagedResources/~Lua/Modules/WorldArena/WorldArenaBattleInfoPanel.lua

670 lines
27 KiB
Lua
Raw Normal View History

2021-09-07 17:05:46 +08:00
require("Base/BasePanel")
local WorldArenaBattleInfoPanel = Inherit(BasePanel)
local endLess=ConfigManager.GetConfig(ConfigName.EndlessHeroProp)
2021-09-07 17:05:46 +08:00
local this = WorldArenaBattleInfoPanel
local state=1 -- 1:开战前 2.:开战中 3开战后
2021-09-07 17:05:46 +08:00
local myHeadObj=nil
local enHeadObj=nil
local resultList={}
2021-09-09 11:48:09 +08:00
local fightDataList={}
local type=0
local enemyId=0
local myInfoData=nil
local enInfoData=nil
2021-09-09 16:27:36 +08:00
local targetIndex=0
local currIndex=0
2021-09-13 14:11:48 +08:00
local myHeroNum=0
local isAnim = false
local _CloseFunc = nil
2021-09-11 15:05:37 +08:00
local leftAllTeam={}
local rightAllTeam={}
2021-10-13 19:35:30 +08:00
local myOldScore=0
local enOldScore=0
local allMyHeros={}
local isSame=false
2021-09-07 17:05:46 +08:00
local function OnBeginDrag(self, Pointgo, data)
if state~=1 then
return
end
2021-09-09 16:27:36 +08:00
local num=999
for i = 1, 3 do
local dis = math.abs(Pointgo.transform.parent.parent.localPosition.y - this.leftTeam[i].transform.localPosition.y )
if dis <= num then
num = dis
currIndex=i
end
end
2021-09-07 17:05:46 +08:00
self.oldGrid = Pointgo.transform.parent.parent
self.tempInfo.transform.localPosition = Pointgo.transform.parent.parent.localPosition
Pointgo.transform.parent:SetParent(self.tempInfo.transform)
Pointgo.transform.parent.localPosition = Vector3.zero
end
local function OnDrag(self, Pointgo, data)
if state~=1 then
return
end
local pos = self.tempInfo.transform.localPosition
2021-09-09 16:27:36 +08:00
local y = pos.y + data.delta.y >= -400 and pos.y + data.delta.y or -400
2021-09-07 17:05:46 +08:00
y = y <= 450 and y or 450
self.tempInfo.transform.localPosition = Vector2.New(pos.x , y)
end
local function OnEndDrag(self, Pointgo, data)
if state~=1 then
return
end
--Pointgo.transform.parent.localPosition = Vector3.zero
local num = 999
local obj = nil
2021-09-09 16:27:36 +08:00
2021-09-07 17:05:46 +08:00
for i = 1, 3 do
local dis = math.abs( self.tempInfo.transform.localPosition.y - this.leftTeam[i].transform.localPosition.y )
2021-09-09 16:27:36 +08:00
--LogError(" temp y=="..self.tempInfo.transform.localPosition.y.." leftteam y=="..this.leftTeam[i].transform.localPosition.y)
2021-09-07 17:05:46 +08:00
if dis <= num then
num = dis
obj = this.leftTeam[i]
2021-09-09 16:27:36 +08:00
targetIndex=i
2021-09-07 17:05:46 +08:00
end
end
--如果滑动距离太短,阵容放回原来的地方
2021-09-09 16:27:36 +08:00
if num>100 then
2021-09-07 17:05:46 +08:00
local target=Util.GetGameObject(self.tempInfo.transform, "Demons")
target.transform:SetParent(self.oldGrid.transform)
target.transform:SetSiblingIndex(1)
target.transform.localPosition=Vector3.New(0,-67,0)
return
end
if obj.transform.childCount > 0 then
local targetInfo=Util.GetGameObject(obj.transform, "Demons")
2021-09-09 16:27:36 +08:00
if targetInfo then
targetInfo.transform:SetParent(self.oldGrid.transform)
targetInfo.transform:SetSiblingIndex(1)
targetInfo.transform.localPosition=Vector3.New(0,-67,0)
else
2021-10-15 20:44:11 +08:00
local target=Util.GetGameObject(self.tempInfo.transform, "Demons")
target.transform:SetParent(self.oldGrid.transform)
target.transform:SetSiblingIndex(1)
target.transform.localPosition=Vector3.New(0,-67,0)
2021-09-09 16:27:36 +08:00
return
end
2021-09-07 17:05:46 +08:00
else
obj = self.oldGrid
end
--local curInfo = self.tempInfo.transform:GetChild(0)
local curInfo =Util.GetGameObject(self.tempInfo.transform, "Demons").transform
curInfo:SetParent(obj.transform)
curInfo.transform:SetSiblingIndex(1)
curInfo.localPosition = Vector3.New(0,-67,0)
2021-09-11 15:05:37 +08:00
--发送协议保存队伍
2021-09-10 21:34:45 +08:00
if currIndex ~= targetIndex then
-- 交换编队数据
local tempFormation = self.curFormation[2000 + currIndex]
self.curFormation[2000 + currIndex] = self.curFormation[2000 + targetIndex]
self.curFormation[2000 + targetIndex] = tempFormation
-- 保存
local upHeros={}
2021-09-10 21:34:45 +08:00
for i = 1, 3 do
local heros = {}
for _, hero in ipairs(self.curFormation[i+2000].teamHeroInfos) do
if BattleUtil.ChecklistIsContainValue(upHeros,hero.heroId) then
PopupTipPanel.ShowTip("编队中有相同神将!!")
return
else
table.insert(upHeros,hero.heroId)
end
2021-09-10 21:34:45 +08:00
table.insert(heros, {heroId = hero.heroId, position = hero.position})
end
FormationManager.SaveFormation(i+2000, heros,
FormationManager.formationList[2001].teamPokemonInfos)
end
2021-09-14 10:10:57 +08:00
local teampos={}
teampos=leftAllTeam[currIndex]
leftAllTeam[currIndex]=leftAllTeam[targetIndex]
leftAllTeam[targetIndex]=teampos
2021-09-10 21:34:45 +08:00
end
2021-09-07 17:05:46 +08:00
end
--初始化组件(用于子类重写)
function WorldArenaBattleInfoPanel:InitComponent()
2021-09-09 11:48:09 +08:00
2021-09-07 17:05:46 +08:00
this.spLoader = SpriteLoader.New()
this.btn_close=Util.GetGameObject(self.transform, "BG/BackBtn")
this.btn_fight=Util.GetGameObject(self.transform, "BG/btn_fight")
this.myName=Util.GetGameObject(self.transform, "BG/info/name"):GetComponent("Text")
this.rightName=Util.GetGameObject(self.transform, "BG/rightInfo/name"):GetComponent("Text")
this.myServer=Util.GetGameObject(self.transform, "BG/info/profess"):GetComponent("Text")
this.rightServer=Util.GetGameObject(self.transform, "BG/rightInfo/profess"):GetComponent("Text")
2021-09-09 11:48:09 +08:00
this.myHeadPar=Util.GetGameObject(self.transform, "BG/info/head")
this.enHeadPar=Util.GetGameObject(self.transform, "BG/rightInfo/head")
2021-09-07 17:05:46 +08:00
this.myRankImg=Util.GetGameObject(self.transform, "BG/info/Image"):GetComponent("Image")
this.enRankImg=Util.GetGameObject(self.transform, "BG/rightInfo/Image"):GetComponent("Image")
this.myScore=Util.GetGameObject(self.transform, "BG/info/Text"):GetComponent("Text")
this.enScore=Util.GetGameObject(self.transform, "BG/rightInfo/Text"):GetComponent("Text")
2021-09-09 11:48:09 +08:00
this.titleTxt=Util.GetGameObject(self.transform, "BG/title"):GetComponent("Text")
this.myTeamInfo=Util.GetGameObject(self.transform, "BG/myInfo")
this.enTeamInfo=Util.GetGameObject(self.transform, "BG/enInfo")
2021-09-11 18:53:58 +08:00
this.effect=Util.GetGameObject(self.transform, "BG/Effect")
this.effect:SetActive(false)
2021-10-15 15:47:55 +08:00
this.hintTxt=Util.GetGameObject(self.transform, "BG/hintTxt"):GetComponent("Text")
2021-09-11 18:53:58 +08:00
screenAdapte(this.effect)
2021-09-07 17:05:46 +08:00
--我方阵营
this.leftTeam={}
--第一局胜利图标
this.myResult={}
this.InfoList = {}
this.dragViewList = {}
this.triggerList = {}
self.tempInfo=Util.GetGameObject(self.transform, "BG/myInfo/teamInfo")
this.OnBeginDrag = function(p,d) OnBeginDrag(self,p,d) end
this.OnDrag= function(p,d) OnDrag(self,p,d) end
this.OnEndDrag= function(p,d) OnEndDrag(self,p,d) end
for i = 1, 3 do
table.insert(this.leftTeam,Util.GetGameObject(self.transform, "BG/myInfo/defendbox"..i))
table.insert(this.myResult,Util.GetGameObject(self.transform, "BG/myInfo/defendbox"..i.."/Image"))
this.myResult[i]:SetActive(false)
this.InfoList[i]=Util.GetGameObject(self.transform, "BG/myInfo/defendbox"..i.."/Demons")
this.dragViewList[i] = SubUIManager.Open(SubUIConfig.DragView, this.InfoList[i].transform)
this.dragViewList[i].transform:SetSiblingIndex(6)
this.triggerList[i]=Util.GetEventTriggerListener(this.dragViewList[i].gameObject)
this.triggerList[i].onBeginDrag = this.triggerList[i].onBeginDrag + this.OnBeginDrag
this.triggerList[i].onDrag = this.triggerList[i].onDrag + this.OnDrag
this.triggerList[i].onEndDrag = this.triggerList[i].onEndDrag + this.OnEndDrag
end
this.rightTeam={}
this.enResult={}
for i = 1, 3 do
table.insert(this.rightTeam,Util.GetGameObject(self.transform, "BG/enInfo/defendbox"..i))
table.insert(this.enResult,Util.GetGameObject(self.transform, "BG/enInfo/defendbox"..i .."/Image"))
this.enResult[i]:SetActive(false)
end
--回放按钮集合
this.playBacks={}
for i = 1, 3 do
table.insert(this.playBacks,Util.GetGameObject(self.transform, "BG/playBacks/Image"..i))
end
this.btnText = Util.GetGameObject(self.transform, "BG/btn_fight/Text"):GetComponent("Text")
this.btnItem = Util.GetGameObject(self.transform, "BG/btn_fight/Image"):GetComponent("Image")
2021-09-09 11:48:09 +08:00
this.btnItemNum = Util.GetGameObject(self.transform, "BG/btn_fight/Image/numText"):GetComponent("Text")
2021-09-07 17:05:46 +08:00
this.RefreshBattleCastInfo()
end
function this:OnSortingOrderChange()
if myHeadObj then
myHeadObj:SetLayer(self.sortingOrder)
end
2021-09-11 18:53:58 +08:00
Util.SetParticleSortLayer(this.effect, self.sortingOrder+10)
2021-09-07 17:05:46 +08:00
end
--刷新战斗消耗信息
function this.RefreshBattleCastInfo()
2021-10-12 10:03:20 +08:00
if type==1 then
local leftTimes = WorldArenaManager.GetFreeTime()
this.btnText.gameObject:SetActive(leftTimes > 0)
this.btnItem.gameObject:SetActive(leftTimes<=0)
this.btnItemNum.gameObject:SetActive(leftTimes<=0)
if leftTimes<=0 then
local itemId, needNum = WorldArenaManager.GetArenaChallengeCost()
local haveNum = BagManager.GetItemCountById(itemId)
this.btnItem.sprite = SetIcon(this.spLoader, itemId)
this.btnItemNum.text = "×"..needNum
this.btnItemNum.color = haveNum < needNum and UIColor.NOT_ENOUGH_RED or UIColor.BTN_TEXT
end
else
this.btnText.gameObject:SetActive(true)
this.btnItem.gameObject:SetActive(false)
2021-09-07 17:05:46 +08:00
end
2021-10-12 10:03:20 +08:00
2021-09-07 17:05:46 +08:00
end
function WorldArenaBattleInfoPanel:PlayFightAnim(leftList, rightList, num, func)
coroutine.start(function()
for i = 1, num do
leftList[i].transform:DOLocalMoveX(90, 0.2, false):OnComplete(function()
2021-09-11 18:53:58 +08:00
leftList[i].transform:DOLocalMoveX(10, 0.3, false):OnComplete(function()
if func then
func(i)
end
end)
end)
SoundManager.PlaySound(SoundConfig.Audio_c_skr_0028_skeff_slidesk_attacked)
2021-09-11 18:53:58 +08:00
this.effect:SetActive(true)
rightList[i].transform:DOLocalMoveX(-80, 0.2, false):OnComplete(function()
rightList[i].transform:DOLocalMoveX(10, 0.3, false)
end)
2021-09-11 18:53:58 +08:00
coroutine.wait(0.5)
this.effect:SetActive(false)
end
end)
end
2021-09-07 17:05:46 +08:00
--绑定事件(用于子类重写)
function WorldArenaBattleInfoPanel:BindEvent()
Util.AddClick(this.btn_close, function()
2021-09-09 20:32:02 +08:00
if state==2 then
return
end
if not isAnim then
self:ClosePanel()
end
2021-09-07 17:05:46 +08:00
end)
Util.AddClick(this.btn_fight, function()
if not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.JumpServer_YuXu) then
PopupTipPanel.ShowTip(Language[10075])
return
end
if type~=1 then
self:ClosePanel()
return
end
-- 动画中不能再执行
state=2
if isAnim then
return
end
2021-09-13 14:11:48 +08:00
if myHeroNum==0 then
PopupTipPanel.ShowTip("编队为空,无法挑战")
return
end
2021-09-09 11:48:09 +08:00
local list={2001,2002,2003}
2021-09-10 18:21:04 +08:00
2021-09-16 18:10:51 +08:00
local num=PrivilegeManager.GetPrivilegeRemainValue(0)
2021-09-11 18:53:58 +08:00
local costType=0
2021-09-10 18:21:04 +08:00
if num>0 then
2021-09-11 18:53:58 +08:00
costType=0
2021-09-10 18:21:04 +08:00
else
2021-09-11 18:53:58 +08:00
costType=1
2021-09-10 18:21:04 +08:00
end
2021-09-11 18:53:58 +08:00
if costType==1 then
2021-09-11 15:05:37 +08:00
local itemId, needNum = WorldArenaManager.GetArenaChallengeCost()
local haveNum = BagManager.GetItemCountById(itemId)
if haveNum < needNum then
--UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.yuxulundaoTicket })
2021-10-14 21:36:29 +08:00
PopupTipPanel.ShowTip("挑战券不足!")
2021-09-11 15:05:37 +08:00
return
end
end
if isSame then
PopupTipPanel.ShowTip("检测到多个阵容使用相同神将,无法开战")
return
end
2021-09-11 18:53:58 +08:00
NetManager.CrossYuXuLunDaoChallengeRequest(list,enemyId,costType,function(msg)
2021-09-09 11:48:09 +08:00
resultList=msg.fightResult
fightDataList=msg.fightData
isAnim = true
self:PlayFightAnim(this.leftTeam, this.rightTeam, 3, function(index)
this.ShowBattleState(index,3)
state=2
this.playBacks[index]:SetActive(true)
if index >= 3 then
isAnim = false
state = 3
type = 2
2021-09-11 18:53:58 +08:00
this.btnItem.gameObject:SetActive(false)
this.btnText.gameObject:SetActive(true)
this.btnText.text="确定"
end
end)
2021-09-10 15:50:24 +08:00
this.myScore.gameObject:SetActive(true)
this.enScore.gameObject:SetActive(true)
2021-10-15 15:47:55 +08:00
this.myScore.text= msg.myScore>0 and "积分 "..myOldScore .."+"..msg.myScore or "积分 "..myOldScore .." "..msg.myScore
this.enScore.text= msg.defScore>0 and "积分 "..enOldScore .."+"..msg.defScore or "积分 "..enOldScore .." "..msg.defScore
2021-10-13 19:35:30 +08:00
-- this.myScore.text= msg.myScore>0 and "积分+"..msg.myScore or "积分"..msg.myScore
2021-09-10 15:50:24 +08:00
this.myScore.color = msg.myScore>0 and UIColor.GREEN or UIColor.RED
2021-10-13 19:35:30 +08:00
--this.enScore.text= msg.defScore>0 and "积分+"..msg.defScore or "积分"..msg.defScore
2021-09-10 15:50:24 +08:00
this.enScore.color = msg.defScore>0 and UIColor.GREEN or UIColor.RED
WorldArenaManager.SetNewScore(msg.myNewScore)
2021-09-10 18:21:04 +08:00
WorldArenaManager.SetMyData(msg.myRank,WorldArenaManager.GetchallengeTimes()+1)
2021-09-09 23:01:23 +08:00
--添加奖励 --
if msg.drop then
WorldArenaManager.AddReward(msg.drop)
end
2021-09-10 18:21:04 +08:00
if num>0 then
PrivilegeManager.RefreshPrivilegeUsedTimes(2028, 1)
end
2021-09-09 11:48:09 +08:00
end)
2021-09-07 17:05:46 +08:00
end)
2021-09-09 11:48:09 +08:00
--回放按钮点击事件
for i = 1, #this.playBacks do
2021-09-09 11:48:09 +08:00
Util.AddClick(this.playBacks[i],function()
if state==2 then
return
end
2021-09-13 14:11:48 +08:00
if not leftAllTeam[i] or not rightAllTeam[i] or #leftAllTeam[i]==0 or #rightAllTeam[i]==0 then
PopupTipPanel.ShowTip("本场战斗无法回放!")
return
end
2021-09-09 11:48:09 +08:00
local nameStr = myInfoData.name.."|"..enInfoData.name
2021-09-09 16:27:36 +08:00
local realResult = resultList[i] --(resultList[i] + 1) % 2 -- 服务器返回的是我的结果,转换为真实结果
2021-09-09 11:48:09 +08:00
this.RequestReplayRecord(realResult,fightDataList[i], nameStr,function()
2021-09-11 16:00:39 +08:00
--this:ClosePanel()
2021-09-09 11:48:09 +08:00
--构建显示结果数据(我永远在蓝方)
local arg = {}
2021-09-11 19:47:23 +08:00
arg.panelType=1
2021-09-09 11:48:09 +08:00
arg.result = realResult
arg.blue = {}
arg.blue.uid = myInfoData.uid
2021-10-13 15:45:42 +08:00
arg.blue.name =PracticeManager.SetNameColor(myInfoData.name,myInfoData.practiceLevel) --myInfoData.name
2021-09-09 11:48:09 +08:00
arg.blue.head = myInfoData.head
arg.blue.frame = myInfoData.headFrame
arg.blue.deltaScore = myInfoData.myScoreChange
arg.red= {}
arg.red.uid = enInfoData.uid
2021-10-13 15:45:42 +08:00
arg.red.name =PracticeManager.SetNameColor(enInfoData.name,enInfoData.practiceLevel)--enInfoData.name
2021-09-09 11:48:09 +08:00
arg.red.head = enInfoData.head
arg.red.frame = enInfoData.headFrame
arg.red.deltaScore = enInfoData.myScoreChange
UIManager.OpenPanel(UIName.ArenaResultPopup, arg)
end)
end)
end
end
function this.RequestReplayRecord(isWin, fightData, nameStr, doneFunc,battle_type)
local fightData = BattleManager.GetBattleServerData({fightData = fightData}, 1)
local battlePanel = UIManager.OpenPanel(UIName.BattlePanel, fightData, battle_type and battle_type or BATTLE_TYPE.BACK, doneFunc)
battlePanel:ShowNameShow(isWin, nameStr)
2021-09-07 17:05:46 +08:00
end
2021-09-09 11:48:09 +08:00
2021-09-07 17:05:46 +08:00
--添加事件监听(用于子类重写)
function WorldArenaBattleInfoPanel:AddListener()
-- Game.GlobalEvent:AddEvent(GameEvent.Arena.OnRecordDataChange, this.RefreshRecordList)
end
--移除事件监听(用于子类重写)
function WorldArenaBattleInfoPanel:RemoveListener()
-- Game.GlobalEvent:RemoveEvent(GameEvent.Arena.OnRecordDataChange, this.RefreshRecordList)
end
--界面打开时调用(用于子类重写)
function WorldArenaBattleInfoPanel:OnOpen(msg,_type,closeFunc,list)
2021-09-07 17:05:46 +08:00
-- 请求数据
2021-09-09 11:48:09 +08:00
-- ArenaManager.RequestArenaRecord()
type=_type
_CloseFunc = closeFunc
2021-09-07 17:05:46 +08:00
-- 刷新显示
-- this.RefreshRecordList()
2021-09-10 15:50:24 +08:00
2021-09-09 11:48:09 +08:00
if type==1 then
this.titleTxt.text="挑战"
this.btnText.text="免费挑战"
else
this.titleTxt.text="回放"
this.btnText.text="确定"
end
2021-09-10 15:50:24 +08:00
2021-09-09 20:32:02 +08:00
--如果有结果list
if list then
state=3
resultList=list
2021-09-30 15:12:02 +08:00
else
state=1
2021-09-09 20:32:02 +08:00
end
2021-09-10 15:50:24 +08:00
if state==1 then
for i = 1, 3 do
this.playBacks[i]:SetActive(false)
this.ShowBattleState(i, state)
end
2021-10-13 19:35:30 +08:00
--this.myScore.gameObject:SetActive(false)
--this.enScore.gameObject:SetActive(false)
2021-10-15 15:47:55 +08:00
this.hintTxt.gameObject:SetActive(true)
2021-09-10 15:50:24 +08:00
elseif state==3 then
2021-10-15 15:47:55 +08:00
this.hintTxt.gameObject:SetActive(false)
2021-09-10 15:50:24 +08:00
this.myScore.gameObject:SetActive(true)
this.enScore.gameObject:SetActive(true)
for i = 1, 3 do
this.playBacks[i]:SetActive(true)
this.ShowBattleState(i,3)
end
end
this.ShowInfo(msg)
this.RefreshBattleCastInfo()
2021-09-10 21:34:45 +08:00
self.curFormation = {}
for i = 1, 3 do
local team=FormationManager.GetFormationByID(i+2000)
local cTeam = FormationManager.MakeAEmptyTeam(i+2000)
for j = 1, #team.teamHeroInfos do
table.insert(cTeam.teamHeroInfos, team.teamHeroInfos[j])
end
self.curFormation[i+2000] = cTeam
end
2021-09-07 17:05:46 +08:00
end
2021-09-09 11:48:09 +08:00
function this.ShowInfo(msg)
2021-09-07 17:05:46 +08:00
--我的信息
2021-09-09 11:48:09 +08:00
myInfoData=msg.myTeamInfo
enInfoData=msg.defTeamInfo
2021-09-09 23:01:23 +08:00
if msg.fightData then
fightDataList=msg.fightData
end
2021-09-16 18:10:51 +08:00
this.myName.text= PracticeManager.SetNameColor(msg.myTeamInfo.serverName.." "..PlayerManager.nickName,msg.myTeamInfo.practiceLevel)
2021-09-11 18:53:58 +08:00
this.myServer.gameObject:SetActive(false)
2021-09-07 17:05:46 +08:00
this.myRankImg.sprite=this.spLoader:LoadSprite("y_yuxulundao_xiaobiao_0"..1)
if not myHeadObj then
myHeadObj = SubUIManager.Open(SubUIConfig.PlayerHeadView, this.myHeadPar.transform)
end
myHeadObj:Reset()
2021-09-09 11:48:09 +08:00
myHeadObj:SetScale(Vector3.one * 0.7)
myHeadObj:SetHead(msg.myTeamInfo.head)
myHeadObj:SetFrame(msg.myTeamInfo.headFrame)
myHeadObj:SetLevel(msg.myTeamInfo.level)
2021-09-07 17:05:46 +08:00
myHeadObj:SetLayer(this.sortingOrder)
2021-09-09 11:48:09 +08:00
myHeadObj:SetEffectScale(0.7)
2021-09-07 17:05:46 +08:00
--敌人信息
2021-09-11 18:53:58 +08:00
this.rightName.text= PracticeManager.SetNameColor(msg.defTeamInfo.serverName.." "..msg.defTeamInfo.name,msg.defTeamInfo.practiceLevel)
this.rightServer.gameObject:SetActive(false)
2021-09-09 11:48:09 +08:00
local enRank=WorldArenaManager.GetRankImgByScore(msg.defTeamInfo.crossTeamScore)
this.enRankImg.sprite=this.spLoader:LoadSprite("y_yuxulundao_xiaobiao_0"..enRank)
2021-09-07 17:05:46 +08:00
if not enHeadObj then
enHeadObj = SubUIManager.Open(SubUIConfig.PlayerHeadView, this.enHeadPar.transform)
end
enHeadObj:Reset()
2021-09-09 11:48:09 +08:00
enHeadObj:SetScale(Vector3.one * 0.7)
enHeadObj:SetHead(msg.defTeamInfo.head)
enHeadObj:SetFrame(msg.defTeamInfo.headFrame)
enHeadObj:SetLevel(msg.defTeamInfo.level)
2021-09-07 17:05:46 +08:00
enHeadObj:SetLayer(this.sortingOrder)
2021-09-09 11:48:09 +08:00
enHeadObj:SetEffectScale(0.7)
enemyId=msg.defTeamInfo.uid
2021-09-07 17:05:46 +08:00
for i = 1, 3 do
if state==1 then
this.playBacks[i]:SetActive(false)
elseif state==3 then
this.playBacks[i]:SetActive(true)
end
end
2021-09-10 15:50:24 +08:00
if state==3 then
2021-10-13 19:35:30 +08:00
if type==1 then
2021-10-15 15:47:55 +08:00
this.myScore.text= msg.myScore>0 and "积分 "..msg.myTeamInfo.crossTeamScore .."+"..msg.myScore or "积分 "..msg.myTeamInfo.crossTeamScore .." "..msg.myScore
this.enScore.text= msg.defScore>0 and "积分 "..msg.defTeamInfo.crossTeamScore .."+"..msg.defScore or "积分 "..msg.defTeamInfo.crossTeamScore .." "..msg.defScore
2021-10-13 19:35:30 +08:00
else
this.myScore.text= msg.myScore>0 and "积分+"..msg.myScore or "积分"..msg.myScore
this.enScore.text= msg.defScore>0 and "积分+"..msg.defScore or "积分"..msg.defScore
end
2021-09-10 15:50:24 +08:00
this.myScore.color = msg.myScore>0 and UIColor.GREEN or UIColor.RED
this.enScore.color = msg.defScore>0 and UIColor.GREEN or UIColor.RED
2021-10-13 19:35:30 +08:00
else
myOldScore=msg.myTeamInfo.crossTeamScore
this.myScore.text="积分 "..myOldScore
enOldScore=msg.defTeamInfo.crossTeamScore
this.enScore.text="积分 "..enOldScore
this.myScore.color =Color.New(0.9019,0.76,0.3882,1)
this.enScore.color = Color.New(0.9019,0.76,0.3882,1)
2021-09-10 15:50:24 +08:00
end
2021-09-09 16:27:36 +08:00
this.SetTeamInfo(this.myTeamInfo,msg.myTeamInfo.crossTeam,1)
2021-09-11 15:05:37 +08:00
this.SetTeamInfo(this.enTeamInfo,msg.defTeamInfo.crossTeam,2)
2021-09-09 11:48:09 +08:00
end
2021-09-09 16:27:36 +08:00
function this.ShowBattleState(index,state)
--for i = 1, 3 do
2021-09-14 10:10:57 +08:00
-- Util.GetGameObject(this.leftTeam[index], "Text").gameObject:SetActive(state~=3)
-- Util.GetGameObject(this.rightTeam[index], "Text").gameObject:SetActive(state~=3)
2021-09-09 16:27:36 +08:00
local leftImg=Util.GetGameObject(this.leftTeam[index], "Image"):GetComponent("Image")
local rightImg=Util.GetGameObject(this.rightTeam[index], "Image"):GetComponent("Image")
2021-09-07 17:05:46 +08:00
leftImg.gameObject:SetActive(state==3)
rightImg.gameObject:SetActive(state==3)
if state==3 then
2021-09-09 16:27:36 +08:00
if resultList[index]==1 then
2021-09-07 17:05:46 +08:00
leftImg.sprite=this.spLoader:LoadSprite("UI_effect_JJC_JieSuan_ShengLi_png_zh")
rightImg.sprite=this.spLoader:LoadSprite("UI_effect_JJC_JieSuan_ShiBai_png_zh")
else
leftImg.sprite=this.spLoader:LoadSprite("UI_effect_JJC_JieSuan_ShiBai_png_zh")
rightImg.sprite=this.spLoader:LoadSprite("UI_effect_JJC_JieSuan_ShengLi_png_zh")
end
end
2021-10-16 19:31:03 +08:00
leftImg:GetComponent("PlayFlyAnim"):PlayAnim(true)
rightImg:GetComponent("PlayFlyAnim"):PlayAnim(true)
2021-09-09 16:27:36 +08:00
--end
2021-09-09 11:48:09 +08:00
end
2021-09-07 17:05:46 +08:00
2021-09-09 11:48:09 +08:00
--编队信息
2021-09-09 16:27:36 +08:00
local allTeams={}
function this.SetTeamInfo(_go,teamData,type)
2021-09-09 11:48:09 +08:00
for index = 1, 3 do
local go = Util.GetGameObject(_go,"defendbox"..index)
local data = teamData[index]
2021-10-11 16:30:33 +08:00
local fightTxt=Util.GetGameObject(go,"Demons/WarPower/Text"):GetComponent("Text")
2021-09-28 15:50:09 +08:00
fightTxt.text=tostring(data.totalForce)
2021-09-09 11:48:09 +08:00
local teamList ={}
for i = 1, 6 do
2021-11-04 10:46:25 +08:00
if not teamList[i] then
teamList[i] = {}
teamList[i].go = Util.GetGameObject(go,"Demons/heroPro ("..i..")")
teamList[i].frameBtn = Util.GetGameObject(teamList[i].go, "frame")
teamList[i].frame = teamList[i].frameBtn:GetComponent("Image")
teamList[i].pos = Util.GetGameObject(teamList[i].go, "pos"):GetComponent("Image")
teamList[i].hero = Util.GetGameObject(teamList[i].go, "hero")
teamList[i].starGrid = Util.GetGameObject(teamList[i].hero, "starGrid")
teamList[i].proIcon = Util.GetGameObject(teamList[i].hero, "proIcon"):GetComponent("Image")
teamList[i].levelText = Util.GetGameObject(teamList[i].hero, "lvbg/levelText"):GetComponent("Text")
teamList[i].icon = Util.GetGameObject(teamList[i].hero, "icon"):GetComponent("Image")
end
2021-09-09 11:48:09 +08:00
end
for i, demon in ipairs(teamList) do
2021-11-04 10:46:25 +08:00
demon.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1))
demon.pos:GetComponent("Image").sprite=this.spLoader:LoadSprite("bd_xinkapaifan"..i)
demon.hero:SetActive(false)
2021-09-09 11:48:09 +08:00
end
--队伍阵容
2021-09-09 16:27:36 +08:00
local heroList={}
2021-09-09 11:48:09 +08:00
for i, hero in ipairs(data.team) do
local heroTid = data.team[i].heroTid
if heroTid then
2021-11-04 10:46:25 +08:00
teamList[hero.position].hero:SetActive(true)
teamList[hero.position].starGrid.transform.localScale=Vector3.one*0.7
2021-10-26 16:00:31 +08:00
local star,starType = GetStarOrGodSoulLv(1,hero)
star=endLess[heroTid].Star
2021-10-27 12:50:15 +08:00
local starScale = -15
2021-11-05 17:38:10 +08:00
local starSize = Vector2.New(32,32)
2021-10-27 12:50:15 +08:00
if starType == 3 then
starScale = -16
2021-11-05 17:38:10 +08:00
starSize = Vector2.New(0.8,-15)
elseif starType == 2 then
starSize = Vector2.New(48,48)
2021-10-27 12:50:15 +08:00
end
if type==1 and isSame==false then
isSame=BattleUtil.ChecklistIsContainValue(allMyHeros,hero.heroid)
if isSame==false then
table.insert(allMyHeros,hero.heroid)
end
end
2023-01-13 13:44:12 +08:00
SetHeroStars(this.spLoader, teamList[hero.position].starGrid, star,nil,nil,-10)
2021-11-04 10:46:25 +08:00
Util.SetParticleSortLayer(teamList[hero.position].starGrid,this.sortingOrder + 1)
2021-09-09 11:48:09 +08:00
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroTid)
teamList[hero.position].proIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(hero.propertyId))
teamList[hero.position].levelText.text =endLess[heroTid].Level or hero.level
2021-11-04 10:46:25 +08:00
teamList[hero.position].frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(heroConfig.Quality, hero.star))
SetHeroIcon(this.spLoader, hero,teamList[hero.position].icon,heroConfig)
SetHeroFlyEffect(teamList[hero.position].hero,this.spLoader,star,this.sortingOrder+1,0.6,2)
2021-09-09 16:27:36 +08:00
--local heroData = {}
2021-11-04 10:46:25 +08:00
-- Util.AddOnceClick(teamList[i].frameBtn, function()
2021-09-09 16:27:36 +08:00
-- NetManager.ViewHeroInfoRequest(self.playerId,hero.heroid,1,PLAYER_INFO_VIEW_TYPE.NORMAL,function(msg)
-- if not hero.heroid then
-- return
-- end
-- heroData= GoodFriendManager.GetHeroDatas(msg.hero,msg.force,msg.SpecialEffects,msg.guildSkill)
-- GoodFriendManager.InitEquipData(msg.equip,heroData)
-- UIManager.OpenPanel(UIName.RoleInfoPopup, heroData,true)
-- end)
-- end)
2021-09-13 14:11:48 +08:00
if type then
2021-09-09 16:27:36 +08:00
table.insert(heroList,{heroId=heroTid,position=hero.position})
end
2021-09-09 11:48:09 +08:00
end
end
2021-09-11 15:05:37 +08:00
if type==1 then
2021-09-09 16:27:36 +08:00
allTeams[index]=heroList
2021-09-11 15:05:37 +08:00
leftAllTeam[index]=heroList
2021-09-13 14:11:48 +08:00
myHeroNum=myHeroNum+#heroList
2021-09-11 15:05:37 +08:00
elseif type==2 then
rightAllTeam[index]=heroList
2021-09-09 16:27:36 +08:00
end
2021-09-09 11:48:09 +08:00
end
end
function this:OnClose()
if this.TimeCounter then
this.TimeCounter:Stop()
this.TimeCounter = nil
end
-- 执行关闭方法u
if _CloseFunc then
-- 如果是挑战完成了,返回就刷新挑战列表
if state == 3 then
_CloseFunc()
end
_CloseFunc = nil
end
allMyHeros={}
isSame=false
-- 重置状态
2021-09-16 18:10:51 +08:00
--state = 1
isAnim = false
2021-09-07 17:05:46 +08:00
end
--界面销毁时调用(用于子类重写)
function WorldArenaBattleInfoPanel:OnDestroy()
this.spLoader:Destroy()
2021-09-11 15:05:37 +08:00
leftAllTeam={}
rightAllTeam={}
allMyHeros={}
isSame=false
2021-09-07 17:05:46 +08:00
-- 头像
if myHeadObj then
myHeadObj:Recycle()
myHeadObj = nil
end
2021-09-09 11:48:09 +08:00
if enHeadObj then
enHeadObj:Recycle()
enHeadObj = nil
end
resultList=nil
fightDataList=nil
if this.TimeCounter then
this.TimeCounter:Stop()
this.TimeCounter = nil
end
2021-09-13 14:11:48 +08:00
myHeroNum=0
2021-09-16 18:10:51 +08:00
state=1
2021-09-07 17:05:46 +08:00
end
return WorldArenaBattleInfoPanel