86 lines
3.2 KiB
Lua
86 lines
3.2 KiB
Lua
require("Base/BasePanel")
|
|
local BattleBestPopup = Inherit(BasePanel)
|
|
local this = BattleBestPopup
|
|
local func2 = nil--此回调目前只有大闹天宫试炼节点用 当有没有事件时 关闭按钮不好使
|
|
function this:InitComponent()
|
|
this.firstPanel = Util.GetGameObject(self.transform, "first")
|
|
this.firstRoleMask = Util.GetGameObject(this.firstPanel, "bg/role/mask"):GetComponent("RectMask2D")
|
|
this.firstRole = Util.GetGameObject(this.firstPanel, "bg/role/mask/root")
|
|
this.firstName = Util.GetGameObject(this.firstPanel, "Image/name"):GetComponent("Text")
|
|
this.firstDamage = Util.GetGameObject(this.firstPanel, "Image/damage"):GetComponent("Text")
|
|
this.firstRate = Util.GetGameObject(this.firstPanel, "Image/rate"):GetComponent("Text")
|
|
this.MaskBtn = Util.GetGameObject(self.transform, "Mask")
|
|
|
|
-- this.secondPanel = Util.GetGameObject(self.transform, "second")
|
|
-- this.secondRole = Util.GetGameObject(this.secondPanel, "role")
|
|
-- 初始位置
|
|
-- this.aniCom = self.gameObject:GetComponent("Animator")
|
|
-- this.aniCom.enabled = false
|
|
-- this.firstRole.transform.localPosition = Vector3.New(-30, -195, 0)
|
|
end
|
|
--绑定事件(用于子类重写)
|
|
function BattleBestPopup:BindEvent()
|
|
|
|
Util.AddClick(this.MaskBtn, function()
|
|
--LogBlue("ssssssssssssss1")
|
|
if func2 then
|
|
--LogBlue("ssssssssssssss2")
|
|
self:ClosePanel()
|
|
end
|
|
end)
|
|
end
|
|
|
|
function this:OnOpen(heroTId, damageValue, allDamage, func,_func2)
|
|
func2 = _func2
|
|
-- 创建立绘
|
|
local heroTData = ConfigManager.GetConfigData(ConfigName.HeroConfig, heroTId)
|
|
this.liveName = GetResourcePath(heroTData.Live)
|
|
this.liveNode = poolManager:LoadLive(this.liveName, this.firstRole.transform, Vector3.one * heroTData.Scale, Vector3.New(heroTData.Position[1], heroTData.Position[2]))
|
|
this.liveNode.transform.sizeDelta = Vector2.New(1000, 1000)
|
|
local SkeletonGraphic = this.liveNode:GetComponent("SkeletonGraphic")
|
|
local idle = function()
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
end
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idle
|
|
poolManager:SetLiveClearCall(this.liveName, this.liveNode, function()
|
|
SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete - idle
|
|
end)
|
|
|
|
|
|
|
|
-- 名称
|
|
this.firstName.text = heroTData.ReadingName
|
|
-- 伤害数值
|
|
this.firstDamage.text = damageValue
|
|
-- 伤害占比
|
|
local rateValue = allDamage == 0 and "0%" or string.format("(%s%%)", math.floor(damageValue/allDamage*10000)/100)
|
|
this.firstRate.text = rateValue
|
|
|
|
-- 结束回调
|
|
this._OverFunc = func
|
|
-- 开始播放动画
|
|
Timer.New(function()
|
|
if this._OverFunc then
|
|
this._OverFunc(this)
|
|
end
|
|
-- this.firstRoleMask.enabled = true
|
|
end, 1, 1, true):Start()
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function this:OnClose()
|
|
|
|
if this.liveNode then
|
|
poolManager:UnLoadLive(this.liveName, this.liveNode)
|
|
this.liveNode = nil
|
|
end
|
|
if func2 then
|
|
func2()
|
|
func2 = nil
|
|
end
|
|
|
|
-- this.firstRoleMask.enabled = false
|
|
end
|
|
|
|
return this |