184 lines
6.8 KiB
Lua
184 lines
6.8 KiB
Lua
|
|
require("Base/BasePanel")
|
|
local ArenaResultPopup = Inherit(BasePanel)
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local artConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
|
local this = ArenaResultPopup
|
|
local orginLayer
|
|
local fun = nil
|
|
--初始化组件(用于子类重写)
|
|
function ArenaResultPopup:InitComponent()
|
|
this.spLoader = SpriteLoader.New()
|
|
orginLayer = 0
|
|
this.mask = Util.GetGameObject(self.transform, "mask")
|
|
this.win = Util.GetGameObject(self.transform, "win")
|
|
this.lose = Util.GetGameObject(self.transform, "lose")
|
|
this.winEffect = Util.GetGameObject(self.transform, "win/Effect")
|
|
this.loseEffect = Util.GetGameObject(self.transform, "lose/Effect (1)")
|
|
this.btnResult = Util.GetGameObject(self.transform, "btnResult")
|
|
this.btnBattleBack = Util.GetGameObject(self.transform, "btnBattleBack")
|
|
this.btnBattleBack:GetComponent("Image").sprite = this.spLoader:LoadSprite("r_zjm_tuo1")
|
|
screenAdapte(this.winEffect)
|
|
screenAdapte(this.loseEffect)
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function ArenaResultPopup:BindEvent()
|
|
Util.AddClick(this.mask, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.btnResult, function()
|
|
UIManager.OpenPanel(UIName.DamageResultPanel, this.realResult)
|
|
end)
|
|
Util.AddClick(this.btnBattleBack, function ()
|
|
BattleManager.BattleBackFun()
|
|
end)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function ArenaResultPopup:AddListener()
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function ArenaResultPopup:RemoveListener()
|
|
end
|
|
|
|
function ArenaResultPopup:OnSortingOrderChange()
|
|
Util.AddParticleSortLayer(this.winEffect, self.sortingOrder - orginLayer)
|
|
Util.AddParticleSortLayer(this.loseEffect, self.sortingOrder - orginLayer)
|
|
orginLayer = self.sortingOrder
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function ArenaResultPopup:OnOpen(_args,_fun)
|
|
SoundManager.PlaySound(SoundConfig.Sound_Arena_Result)
|
|
local args = _args
|
|
fun = _fun
|
|
if not args then return end
|
|
|
|
this.realResult = args.result
|
|
local panelType = args.panelType or 0
|
|
local isWin = args.result == 1
|
|
local blueInfo = args.blue
|
|
local redInfo = args.red
|
|
|
|
local rewardData = {}
|
|
if args.reward then
|
|
rewardData.id = args.reward.itemlist[1].itemId
|
|
rewardData.num = args.reward.itemlist[1].itemNum
|
|
end
|
|
|
|
-- 如果我在防守方,交换数据,我要显示在蓝方
|
|
if redInfo.uid == PlayerManager.uid then
|
|
blueInfo = args.red
|
|
redInfo = args.blue
|
|
-- isWin = not isWin
|
|
end
|
|
|
|
this.win:SetActive(isWin)
|
|
this.winEffect:SetActive(isWin)
|
|
this.lose:SetActive(not isWin)
|
|
this.loseEffect:SetActive(not isWin)
|
|
local _CurPanel = isWin and this.win or this.lose
|
|
|
|
local blueName = Util.GetGameObject(_CurPanel, "Left/Grade/name")
|
|
local blueHeadIcon = Util.GetGameObject(_CurPanel, "Left/Grade/headIcon")
|
|
local blueHeadBg = Util.GetGameObject(_CurPanel, "Left/Grade/headBg")
|
|
local blueScore = Util.GetGameObject(_CurPanel, "Left/Grade/score")
|
|
local blueResult = Util.GetGameObject(_CurPanel, "Left/result")
|
|
|
|
local redName = Util.GetGameObject(_CurPanel, "Right/Grade/name")
|
|
local redHeadIcon = Util.GetGameObject(_CurPanel, "Right/Grade/headIcon")
|
|
local redHeadBg = Util.GetGameObject(_CurPanel, "Right/Grade/headBg")
|
|
local redScore = Util.GetGameObject(_CurPanel, "Right/Grade/score")
|
|
local redResult = Util.GetGameObject(_CurPanel, "Right/result")
|
|
|
|
local bigResult = Util.GetGameObject(_CurPanel, "ShiBai_WenZi"):GetComponent("Image")
|
|
|
|
local reward = Util.GetGameObject(_CurPanel, "Left/reward")
|
|
reward:SetActive(false)
|
|
local rewardIcon = Util.GetGameObject(_CurPanel, "Left/reward/icon"):GetComponent("Image")
|
|
local rewardNum = Util.GetGameObject(_CurPanel, "Left/reward/num"):GetComponent("Text")
|
|
|
|
-- 昵称
|
|
blueName:GetComponent("Text").text = blueInfo.name
|
|
redName:GetComponent("Text").text = redInfo.name
|
|
-- 头像
|
|
blueHeadIcon:GetComponent("Image").sprite = GetPlayerHeadSprite(this.spLoader, blueInfo.head)
|
|
blueHeadBg:GetComponent("Image").sprite = GetPlayerHeadFrameSprite(this.spLoader, blueInfo.frame)
|
|
|
|
redHeadIcon:GetComponent("Image").sprite = GetPlayerHeadSprite(this.spLoader, redInfo.head)
|
|
redHeadBg:GetComponent("Image").sprite = GetPlayerHeadFrameSprite(this.spLoader, redInfo.frame)
|
|
|
|
-- LogYellow("奖励Id:"..args.reward.itemlist[1].itemId.." 奖励数量:"..args.reward.itemlist[1].itemNum)
|
|
if args.reward then
|
|
reward:SetActive(true)
|
|
rewardIcon.sprite = this.spLoader:LoadSprite(artConfig[itemConfig[rewardData.id].ResourceID].Name)
|
|
rewardNum.text = "+"..rewardData.num
|
|
end
|
|
|
|
-- 积分
|
|
local bScore = blueInfo.deltaScore
|
|
if bScore and isWin then
|
|
blueScore:SetActive(true)
|
|
local blueScoreColor = bScore >= 0 and UIColorStr.GREEN or UIColorStr.RED
|
|
local blueScoreStr = bScore >= 0 and "+"..bScore or bScore
|
|
blueScore:GetComponent("Text").text = bScore ~= 0 and string.format(Language[10085], blueScoreColor, blueScoreStr) or ""
|
|
else
|
|
blueScore:SetActive(false)
|
|
end
|
|
|
|
local rScore = redInfo.deltaScore
|
|
if rScore and isWin then
|
|
redScore:SetActive(true)
|
|
local redScoreColor = rScore >= 0 and UIColorStr.GREEN or UIColorStr.RED
|
|
local redScoreStr = rScore >= 0 and "+"..rScore or rScore
|
|
redScore:GetComponent("Text").text = string.format(Language[10085],redScoreColor, redScoreStr)
|
|
else
|
|
redScore:SetActive(false)
|
|
end
|
|
|
|
-- 判断显示类型
|
|
if panelType == 0 then
|
|
blueResult:SetActive(false)
|
|
redResult:SetActive(false)
|
|
bigResult.sprite = this.spLoader:LoadSprite(isWin and "UI_effect_JJC_JieSuan_ShengLi_png_zh" or "UI_effect_JJC_JieSuan_ShiBai_png_zh")
|
|
bigResult:SetNativeSize()
|
|
elseif panelType == 1 then
|
|
blueResult:SetActive(true)
|
|
redResult:SetActive(true)
|
|
bigResult.sprite = this.spLoader:LoadSprite("r_playerrumble_wan_zh")
|
|
bigResult.transform.sizeDelta = Vector2.New(420, 420)
|
|
elseif panelType == 2 then
|
|
blueResult:SetActive(true)
|
|
redResult:SetActive(true)
|
|
bigResult.sprite = this.spLoader:LoadSprite("r_playerrumble_wan_zh")
|
|
bigResult.transform.sizeDelta = Vector2.New(420, 420)
|
|
blueScore:SetActive(false)
|
|
redScore:SetActive(false)
|
|
end
|
|
|
|
|
|
this._IsWin = isWin
|
|
|
|
local isRecord, record = BattleRecordManager.isHaveRecord()
|
|
this.btnResult:SetActive(isRecord)
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function ArenaResultPopup:OnClose()
|
|
if fun then
|
|
-- LogRed("抛弹竞猜结束 打开 ATM_GuessTipView")
|
|
fun()
|
|
fun = nil
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function ArenaResultPopup:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
end
|
|
|
|
return ArenaResultPopup
|
|
|