665 lines
28 KiB
Lua
665 lines
28 KiB
Lua
require("Base/BasePanel")
|
||
local WorldArenaBattleInfoPanel = Inherit(BasePanel)
|
||
local endLess = ConfigManager.GetConfig(ConfigName.EndlessHeroProp)
|
||
local this = WorldArenaBattleInfoPanel
|
||
|
||
local state = 1 -- 1:开战前 2.:开战中 3:开战后
|
||
local myHeadObj = nil
|
||
local enHeadObj = nil
|
||
local resultList = {}
|
||
local fightDataList = {}
|
||
local type = 0
|
||
local enemyId = 0
|
||
local myInfoData = nil
|
||
local enInfoData = nil
|
||
|
||
local targetIndex = 0
|
||
local currIndex = 0
|
||
local myHeroNum = 0
|
||
local isAnim = false
|
||
local _CloseFunc = nil
|
||
local leftAllTeam = {}
|
||
local rightAllTeam = {}
|
||
local myOldScore = 0
|
||
local enOldScore = 0
|
||
local allMyHeros = {}
|
||
local isSame = false
|
||
local function OnBeginDrag(self, Pointgo, data)
|
||
if state ~= 1 then
|
||
return
|
||
end
|
||
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
|
||
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
|
||
local y = pos.y + data.delta.y >= -400 and pos.y + data.delta.y or -400
|
||
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
|
||
|
||
for i = 1, 3 do
|
||
local dis = math.abs(self.tempInfo.transform.localPosition.y - this.leftTeam[i].transform.localPosition.y)
|
||
--LogError(" temp y=="..self.tempInfo.transform.localPosition.y.." leftteam y=="..this.leftTeam[i].transform.localPosition.y)
|
||
if dis <= num then
|
||
num = dis
|
||
obj = this.leftTeam[i]
|
||
targetIndex = i
|
||
end
|
||
end
|
||
--如果滑动距离太短,阵容放回原来的地方
|
||
if num > 100 then
|
||
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")
|
||
if targetInfo then
|
||
targetInfo.transform:SetParent(self.oldGrid.transform)
|
||
targetInfo.transform:SetSiblingIndex(1)
|
||
targetInfo.transform.localPosition = Vector3.New(0, -67, 0)
|
||
else
|
||
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
|
||
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)
|
||
--发送协议保存队伍
|
||
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 = {}
|
||
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(Language[12991])
|
||
return
|
||
else
|
||
table.insert(upHeros, hero.heroId)
|
||
end
|
||
table.insert(heros, { heroId = hero.heroId, position = hero.position })
|
||
end
|
||
FormationManager.SaveFormation(i + 2000, heros,
|
||
FormationManager.formationList[2001].teamPokemonInfos)
|
||
end
|
||
local teampos = {}
|
||
teampos = leftAllTeam[currIndex]
|
||
leftAllTeam[currIndex] = leftAllTeam[targetIndex]
|
||
leftAllTeam[targetIndex] = teampos
|
||
end
|
||
end
|
||
--初始化组件(用于子类重写)
|
||
function WorldArenaBattleInfoPanel:InitComponent()
|
||
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")
|
||
this.myHeadPar = Util.GetGameObject(self.transform, "BG/info/head")
|
||
this.enHeadPar = Util.GetGameObject(self.transform, "BG/rightInfo/head")
|
||
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")
|
||
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")
|
||
this.effect = Util.GetGameObject(self.transform, "BG/Effect")
|
||
this.effect:SetActive(false)
|
||
this.hintTxt = Util.GetGameObject(self.transform, "BG/hintTxt"):GetComponent("Text")
|
||
screenAdapte(this.effect)
|
||
--我方阵营
|
||
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")
|
||
this.btnItemNum = Util.GetGameObject(self.transform, "BG/btn_fight/Image/numText"):GetComponent("Text")
|
||
this.RefreshBattleCastInfo()
|
||
end
|
||
|
||
function this:OnSortingOrderChange()
|
||
if myHeadObj then
|
||
myHeadObj:SetLayer(self.sortingOrder)
|
||
end
|
||
Util.SetParticleSortLayer(this.effect, self.sortingOrder + 10)
|
||
end
|
||
|
||
--刷新战斗消耗信息
|
||
function this.RefreshBattleCastInfo()
|
||
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)
|
||
end
|
||
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()
|
||
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)
|
||
this.effect:SetActive(true)
|
||
rightList[i].transform:DOLocalMoveX(-80, 0.2, false):OnComplete(function()
|
||
rightList[i].transform:DOLocalMoveX(10, 0.3, false)
|
||
end)
|
||
|
||
coroutine.wait(0.5)
|
||
this.effect:SetActive(false)
|
||
end
|
||
end)
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function WorldArenaBattleInfoPanel:BindEvent()
|
||
Util.AddClick(this.btn_close, function()
|
||
if state == 2 then
|
||
return
|
||
end
|
||
if not isAnim then
|
||
self:ClosePanel()
|
||
end
|
||
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
|
||
if myHeroNum == 0 then
|
||
PopupTipPanel.ShowTip(Language[12992])
|
||
return
|
||
end
|
||
|
||
local list = { 2001, 2002, 2003 }
|
||
|
||
local num = PrivilegeManager.GetPrivilegeRemainValue(0)
|
||
local costType = 0
|
||
if num > 0 then
|
||
costType = 0
|
||
else
|
||
costType = 1
|
||
end
|
||
if costType == 1 then
|
||
local itemId, needNum = WorldArenaManager.GetArenaChallengeCost()
|
||
local haveNum = BagManager.GetItemCountById(itemId)
|
||
if haveNum < needNum then
|
||
--UIManager.OpenPanel(UIName.QuickPurchasePanel, { type = UpViewRechargeType.yuxulundaoTicket })
|
||
PopupTipPanel.ShowTip(Language[13000])
|
||
return
|
||
end
|
||
end
|
||
if isSame then
|
||
PopupTipPanel.ShowTip(Language[12993])
|
||
return
|
||
end
|
||
NetManager.CrossYuXuLunDaoChallengeRequest(list, enemyId, costType, function(msg)
|
||
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
|
||
this.btnItem.gameObject:SetActive(false)
|
||
this.btnText.gameObject:SetActive(true)
|
||
this.btnText.text = Language[10686]
|
||
end
|
||
end)
|
||
this.myScore.gameObject:SetActive(true)
|
||
this.enScore.gameObject:SetActive(true)
|
||
this.myScore.text = msg.myScore > 0 and Language[13001] .. myOldScore .. "+" .. msg.myScore or
|
||
Language[13001] .. myOldScore .. " " .. msg.myScore
|
||
this.enScore.text = msg.defScore > 0 and Language[13001] .. enOldScore .. "+" .. msg.defScore or
|
||
Language[13001] .. enOldScore .. " " .. msg.defScore
|
||
-- this.myScore.text= msg.myScore>0 and "积分+"..msg.myScore or "积分"..msg.myScore
|
||
this.myScore.color = msg.myScore > 0 and UIColor.GREEN or UIColor.RED
|
||
--this.enScore.text= msg.defScore>0 and "积分+"..msg.defScore or "积分"..msg.defScore
|
||
this.enScore.color = msg.defScore > 0 and UIColor.GREEN or UIColor.RED
|
||
WorldArenaManager.SetNewScore(msg.myNewScore)
|
||
WorldArenaManager.SetMyData(msg.myRank, WorldArenaManager.GetchallengeTimes() + 1)
|
||
--添加奖励 --
|
||
if msg.drop then
|
||
WorldArenaManager.AddReward(msg.drop)
|
||
end
|
||
if num > 0 then
|
||
PrivilegeManager.RefreshPrivilegeUsedTimes(2028, 1)
|
||
end
|
||
end)
|
||
end)
|
||
|
||
--回放按钮点击事件
|
||
for i = 1, #this.playBacks do
|
||
Util.AddClick(this.playBacks[i], function()
|
||
if state == 2 then
|
||
return
|
||
end
|
||
if not leftAllTeam[i] or not rightAllTeam[i] or #leftAllTeam[i] == 0 or #rightAllTeam[i] == 0 then
|
||
PopupTipPanel.ShowTip(Language[12994])
|
||
return
|
||
end
|
||
local nameStr = myInfoData.name .. "|" .. enInfoData.name
|
||
local realResult = resultList[i] --(resultList[i] + 1) % 2 -- 服务器返回的是我的结果,转换为真实结果
|
||
this.RequestReplayRecord(realResult, fightDataList[i], nameStr, function()
|
||
--this:ClosePanel()
|
||
--构建显示结果数据(我永远在蓝方)
|
||
local arg = {}
|
||
arg.panelType = 1
|
||
arg.result = realResult
|
||
arg.blue = {}
|
||
arg.blue.uid = myInfoData.uid
|
||
arg.blue.name = PracticeManager.SetNameColor(myInfoData.name, myInfoData.practiceLevel) --myInfoData.name
|
||
arg.blue.head = myInfoData.head
|
||
arg.blue.frame = myInfoData.headFrame
|
||
arg.blue.deltaScore = myInfoData.myScoreChange
|
||
arg.red = {}
|
||
arg.red.uid = enInfoData.uid
|
||
arg.red.name = PracticeManager.SetNameColor(enInfoData.name, enInfoData.practiceLevel) --enInfoData.name
|
||
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)
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
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)
|
||
-- 请求数据
|
||
-- ArenaManager.RequestArenaRecord()
|
||
type = _type
|
||
_CloseFunc = closeFunc
|
||
-- 刷新显示
|
||
-- this.RefreshRecordList()
|
||
|
||
if type == 1 then
|
||
this.titleTxt.text = Language[10340]
|
||
this.btnText.text = Language[10115]
|
||
else
|
||
this.titleTxt.text = Language[12995]
|
||
this.btnText.text = Language[10686]
|
||
end
|
||
|
||
--如果有结果list
|
||
if list then
|
||
state = 3
|
||
resultList = list
|
||
else
|
||
state = 1
|
||
end
|
||
if state == 1 then
|
||
for i = 1, 3 do
|
||
this.playBacks[i]:SetActive(false)
|
||
this.ShowBattleState(i, state)
|
||
end
|
||
--this.myScore.gameObject:SetActive(false)
|
||
--this.enScore.gameObject:SetActive(false)
|
||
this.hintTxt.gameObject:SetActive(true)
|
||
elseif state == 3 then
|
||
this.hintTxt.gameObject:SetActive(false)
|
||
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()
|
||
|
||
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
|
||
end
|
||
|
||
function this.ShowInfo(msg)
|
||
--我的信息
|
||
myInfoData = msg.myTeamInfo
|
||
enInfoData = msg.defTeamInfo
|
||
if msg.fightData then
|
||
fightDataList = msg.fightData
|
||
end
|
||
this.myName.text = PracticeManager.SetNameColor(msg.myTeamInfo.serverName .. " " .. PlayerManager.nickName,
|
||
msg.myTeamInfo.practiceLevel)
|
||
this.myServer.gameObject:SetActive(false)
|
||
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()
|
||
myHeadObj:SetScale(Vector3.one * 0.7)
|
||
myHeadObj:SetHead(msg.myTeamInfo.head)
|
||
myHeadObj:SetFrame(msg.myTeamInfo.headFrame)
|
||
myHeadObj:SetLevel(msg.myTeamInfo.level)
|
||
myHeadObj:SetLayer(this.sortingOrder)
|
||
myHeadObj:SetEffectScale(0.7)
|
||
--敌人信息
|
||
this.rightName.text = PracticeManager.SetNameColor(msg.defTeamInfo.serverName .. " " .. msg.defTeamInfo.name,
|
||
msg.defTeamInfo.practiceLevel)
|
||
this.rightServer.gameObject:SetActive(false)
|
||
local enRank = WorldArenaManager.GetRankImgByScore(msg.defTeamInfo.crossTeamScore)
|
||
this.enRankImg.sprite = this.spLoader:LoadSprite("y_yuxulundao_xiaobiao_0" .. enRank)
|
||
if not enHeadObj then
|
||
enHeadObj = SubUIManager.Open(SubUIConfig.PlayerHeadView, this.enHeadPar.transform)
|
||
end
|
||
enHeadObj:Reset()
|
||
enHeadObj:SetScale(Vector3.one * 0.7)
|
||
enHeadObj:SetHead(msg.defTeamInfo.head)
|
||
enHeadObj:SetFrame(msg.defTeamInfo.headFrame)
|
||
enHeadObj:SetLevel(msg.defTeamInfo.level)
|
||
enHeadObj:SetLayer(this.sortingOrder)
|
||
enHeadObj:SetEffectScale(0.7)
|
||
enemyId = msg.defTeamInfo.uid
|
||
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
|
||
if state == 3 then
|
||
if type == 1 then
|
||
this.myScore.text = msg.myScore > 0 and Language[13001] .. msg.myTeamInfo.crossTeamScore .. "+" ..
|
||
msg.myScore or Language[13001] .. msg.myTeamInfo.crossTeamScore .. " " .. msg.myScore
|
||
this.enScore.text = msg.defScore > 0 and Language[13001] ..
|
||
msg.defTeamInfo.crossTeamScore .. "+" .. msg.defScore or
|
||
Language[13001] .. msg.defTeamInfo.crossTeamScore .. " " .. msg.defScore
|
||
else
|
||
this.myScore.text = msg.myScore > 0 and Language[13002] .. msg.myScore or Language[10155] .. msg.myScore
|
||
this.enScore.text = msg.defScore > 0 and Language[13002] .. msg.defScore or Language[10155] .. msg.defScore
|
||
end
|
||
--this.myScore.color = msg.myScore>0 and UIColor.GREEN or UIColor.RED
|
||
--this.enScore.color = msg.defScore>0 and UIColor.GREEN or UIColor.RED
|
||
else
|
||
myOldScore = msg.myTeamInfo.crossTeamScore
|
||
this.myScore.text = Language[13001] .. myOldScore
|
||
enOldScore = msg.defTeamInfo.crossTeamScore
|
||
this.enScore.text = Language[13001] .. 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)
|
||
end
|
||
this.SetTeamInfo(this.myTeamInfo, msg.myTeamInfo.crossTeam, 1)
|
||
this.SetTeamInfo(this.enTeamInfo, msg.defTeamInfo.crossTeam, 2)
|
||
end
|
||
|
||
function this.ShowBattleState(index, state)
|
||
--for i = 1, 3 do
|
||
-- Util.GetGameObject(this.leftTeam[index], "Text").gameObject:SetActive(state~=3)
|
||
-- Util.GetGameObject(this.rightTeam[index], "Text").gameObject:SetActive(state~=3)
|
||
local leftImg = Util.GetGameObject(this.leftTeam[index], "Image"):GetComponent("Image")
|
||
local rightImg = Util.GetGameObject(this.rightTeam[index], "Image"):GetComponent("Image")
|
||
leftImg.gameObject:SetActive(state == 3)
|
||
rightImg.gameObject:SetActive(state == 3)
|
||
if state == 3 then
|
||
if resultList[index] == 1 then
|
||
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
|
||
leftImg:GetComponent("PlayFlyAnim"):PlayAnim(true)
|
||
rightImg:GetComponent("PlayFlyAnim"):PlayAnim(true)
|
||
--end
|
||
end
|
||
|
||
--编队信息
|
||
local allTeams = {}
|
||
function this.SetTeamInfo(_go, teamData, type)
|
||
for index = 1, 3 do
|
||
local go = Util.GetGameObject(_go, "defendbox" .. index)
|
||
local data = teamData[index]
|
||
local fightTxt = Util.GetGameObject(go, "Demons/WarPower/Text"):GetComponent("Text")
|
||
fightTxt.text = tostring(data.totalForce)
|
||
local teamList = {}
|
||
for i = 1, 6 do
|
||
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
|
||
end
|
||
for i, demon in ipairs(teamList) do
|
||
demon.frame.sprite = this.spLoader:LoadSprite(GetQuantityImageByquality(1))
|
||
demon.pos:GetComponent("Image").sprite = this.spLoader:LoadSprite("bd_xinkapaifan" .. i)
|
||
demon.hero:SetActive(false)
|
||
end
|
||
--队伍阵容
|
||
local heroList = {}
|
||
for i, hero in ipairs(data.team) do
|
||
local heroTid = data.team[i].heroTid
|
||
if heroTid then
|
||
teamList[hero.position].hero:SetActive(true)
|
||
teamList[hero.position].starGrid.transform.localScale = Vector3.one * 0.7
|
||
LogError("hero.star=============" .. hero.star .. " hero.level=====" .. hero.level)
|
||
local star, starType = GetStarOrGodSoulLv(1, hero)
|
||
--star=endLess[heroTid].Star
|
||
local starScale = -15
|
||
local starSize = Vector2.New(32, 32)
|
||
if starType == 3 then
|
||
starScale = -16
|
||
starSize = Vector2.New(0.8, -15)
|
||
elseif starType == 2 then
|
||
starSize = Vector2.New(48, 48)
|
||
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
|
||
SetHeroStars(this.spLoader, teamList[hero.position].starGrid, star, nil, nil, -10)
|
||
Util.SetParticleSortLayer(teamList[hero.position].starGrid, this.sortingOrder + 1)
|
||
local heroConfig = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroTid)
|
||
teamList[hero.position].proIcon.sprite = this.spLoader:LoadSprite(GetProStrImageByProNum(hero.propertyId))
|
||
teamList[hero.position].levelText.text = hero.level --endLess[heroTid].Level or hero.level
|
||
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)
|
||
--local heroData = {}
|
||
-- Util.AddOnceClick(teamList[i].frameBtn, function()
|
||
-- 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)
|
||
if type then
|
||
table.insert(heroList, { heroId = heroTid, position = hero.position })
|
||
end
|
||
end
|
||
end
|
||
if type == 1 then
|
||
allTeams[index] = heroList
|
||
leftAllTeam[index] = heroList
|
||
myHeroNum = myHeroNum + #heroList
|
||
elseif type == 2 then
|
||
rightAllTeam[index] = heroList
|
||
end
|
||
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
|
||
-- 重置状态
|
||
--state = 1
|
||
isAnim = false
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function WorldArenaBattleInfoPanel:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
leftAllTeam = {}
|
||
rightAllTeam = {}
|
||
allMyHeros = {}
|
||
isSame = false
|
||
-- 头像
|
||
if myHeadObj then
|
||
myHeadObj:Recycle()
|
||
myHeadObj = nil
|
||
end
|
||
if enHeadObj then
|
||
enHeadObj:Recycle()
|
||
enHeadObj = nil
|
||
end
|
||
resultList = nil
|
||
fightDataList = nil
|
||
if this.TimeCounter then
|
||
this.TimeCounter:Stop()
|
||
this.TimeCounter = nil
|
||
end
|
||
myHeroNum = 0
|
||
state = 1
|
||
end
|
||
|
||
return WorldArenaBattleInfoPanel
|