2021-04-21 13:12:04 +08:00
|
|
|
|
require("Base/BasePanel")
|
2021-11-10 02:52:51 +08:00
|
|
|
|
local SpiritAnimal = ConfigManager.GetConfig(ConfigName.SpiritAnimal)
|
2020-05-15 16:52:35 +08:00
|
|
|
|
local BattleBestPopup = Inherit(BasePanel)
|
|
|
|
|
local this = BattleBestPopup
|
2020-06-28 17:48:49 +08:00
|
|
|
|
local func2 = nil--此回调目前只有大闹天宫试炼节点用 当有没有事件时 关闭按钮不好使
|
2020-05-09 13:31:21 +08:00
|
|
|
|
function this:InitComponent()
|
2021-04-21 13:12:04 +08:00
|
|
|
|
this.spLoader = SpriteLoader.New()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
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")
|
2020-06-28 17:48:49 +08:00
|
|
|
|
this.MaskBtn = Util.GetGameObject(self.transform, "Mask")
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
-- 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
|
2020-06-28 17:48:49 +08:00
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function BattleBestPopup:BindEvent()
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2020-06-28 17:48:49 +08:00
|
|
|
|
Util.AddClick(this.MaskBtn, function()
|
2020-06-28 17:52:29 +08:00
|
|
|
|
--LogBlue("ssssssssssssss1")
|
|
|
|
|
if func2 then
|
|
|
|
|
--LogBlue("ssssssssssssss2")
|
2020-06-28 17:48:49 +08:00
|
|
|
|
self:ClosePanel()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2021-11-10 02:52:51 +08:00
|
|
|
|
function this:OnOpen(heroTId, skinId, damageValue, allDamage, func,_func2)
|
2020-07-01 18:14:03 +08:00
|
|
|
|
func2 = _func2
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 创建立绘
|
2021-11-10 02:52:51 +08:00
|
|
|
|
local heroTData = {}
|
2021-11-26 16:55:13 +08:00
|
|
|
|
local toward=0
|
2021-11-10 02:52:51 +08:00
|
|
|
|
if heroTId > 0 then
|
|
|
|
|
--如果有皮肤读取皮肤表里面的数据,没有读取hero表
|
|
|
|
|
local data = nil
|
|
|
|
|
if skinId and skinId>0 then
|
|
|
|
|
data = ConfigManager.GetConfigDataByKey(ConfigName.HeroSkin,"Type",skinId)
|
2021-11-29 17:07:28 +08:00
|
|
|
|
local roleConfig= ConfigManager.TryGetConfigData(ConfigName.RoleConfig,skinId)
|
|
|
|
|
if roleConfig then
|
|
|
|
|
toward=roleConfig.Toward
|
|
|
|
|
end
|
2021-11-10 02:52:51 +08:00
|
|
|
|
else
|
|
|
|
|
data= ConfigManager.GetConfigData(ConfigName.HeroConfig,heroTId)
|
2021-11-26 16:55:13 +08:00
|
|
|
|
toward=data.Toward
|
2021-11-10 02:52:51 +08:00
|
|
|
|
end
|
|
|
|
|
heroTData.Live = GetResourcePath(data.Live)
|
2023-07-02 21:52:32 +08:00
|
|
|
|
if heroTId==10016 then
|
2023-06-28 15:58:29 +08:00
|
|
|
|
heroTData.Live=GetResourcePath(data.Painting)
|
|
|
|
|
end
|
2021-11-10 02:52:51 +08:00
|
|
|
|
heroTData.Scale = data.Scale
|
|
|
|
|
heroTData.Position = data.Position
|
|
|
|
|
heroTData.Name = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.HeroConfig,heroTId).ReadingName)
|
2020-11-06 16:52:54 +08:00
|
|
|
|
else
|
2021-11-10 02:52:51 +08:00
|
|
|
|
if NameManager.roleSex == ROLE_SEX.BOY then
|
|
|
|
|
heroTData.Live = "live2d_npc_boy"
|
|
|
|
|
heroTData.Scale = 0.6
|
|
|
|
|
heroTData.Position = {127, -164}
|
|
|
|
|
else
|
|
|
|
|
heroTData.Live = "live2d_npc_girl"
|
|
|
|
|
heroTData.Scale = 0.6
|
|
|
|
|
heroTData.Position = {127, -340}
|
|
|
|
|
end
|
2021-10-26 14:45:28 +08:00
|
|
|
|
heroTData.Name = PracticeManager.SetNameColor(NameManager.roleName, PracticeManager.PracticeLevel)
|
2020-11-06 16:52:54 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-11-10 02:52:51 +08:00
|
|
|
|
this.liveName = heroTData.Live
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.liveNode = poolManager:LoadLive(this.liveName, this.firstRole.transform, Vector3.one * heroTData.Scale, Vector3.New(heroTData.Position[1], heroTData.Position[2]))
|
2021-03-19 17:05:26 +08:00
|
|
|
|
this.liveNode.transform.sizeDelta = Vector2.New(10, 10)
|
2021-11-26 16:55:13 +08:00
|
|
|
|
SetHEeroLiveToward(this.liveNode,toward)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local SkeletonGraphic = this.liveNode:GetComponent("SkeletonGraphic")
|
|
|
|
|
local idle = function()
|
2023-06-28 15:58:29 +08:00
|
|
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, heroTId==10016 and "animation" or"idle", true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2023-06-28 15:58:29 +08:00
|
|
|
|
|
|
|
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, heroTId==10016 and "animation" or"idle", true)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete + idle
|
|
|
|
|
poolManager:SetLiveClearCall(this.liveName, this.liveNode, function()
|
|
|
|
|
SkeletonGraphic.AnimationState.Complete = SkeletonGraphic.AnimationState.Complete - idle
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 名称
|
2021-11-10 02:52:51 +08:00
|
|
|
|
this.firstName.text = heroTData.Name
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 伤害数值
|
|
|
|
|
this.firstDamage.text = damageValue
|
|
|
|
|
-- 伤害占比
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local rateValue = allDamage == 0 and "0%" or string.format("(%s%%)", math.floor(damageValue/allDamage*10000)/100)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
this.firstRate.text = rateValue
|
|
|
|
|
|
|
|
|
|
-- 结束回调
|
|
|
|
|
this._OverFunc = func
|
|
|
|
|
-- 开始播放动画
|
|
|
|
|
Timer.New(function()
|
|
|
|
|
if this._OverFunc then
|
|
|
|
|
this._OverFunc(this)
|
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
-- this.firstRoleMask.enabled = true
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end, 1, 1, true):Start()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
|
|
|
|
|
if this.liveNode then
|
|
|
|
|
poolManager:UnLoadLive(this.liveName, this.liveNode)
|
|
|
|
|
this.liveNode = nil
|
|
|
|
|
end
|
2020-06-28 17:48:49 +08:00
|
|
|
|
if func2 then
|
|
|
|
|
func2()
|
|
|
|
|
func2 = nil
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2020-05-15 16:52:35 +08:00
|
|
|
|
-- this.firstRoleMask.enabled = false
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return this
|