miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/View/BattleBestPopup.lua

124 lines
4.7 KiB
Lua
Raw Normal View History

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 = {}
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)
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)
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
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)
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
heroTData.Name = PracticeManager.SetNameColor(NameManager.roleName, PracticeManager.PracticeLevel)
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]))
this.liveNode.transform.sizeDelta = Vector2.New(10, 10)
SetHEeroLiveToward(this.liveNode,toward)
2020-05-09 13:31:21 +08:00
local SkeletonGraphic = this.liveNode:GetComponent("SkeletonGraphic")
local idle = function()
SkeletonGraphic.AnimationState:SetAnimation(0, heroTId==10016 and "animation" or"idle", true)
2020-05-09 13:31:21 +08:00
end
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