require("Base/BasePanel") local SpiritAnimal = ConfigManager.GetConfig(ConfigName.SpiritAnimal) local BattleBestPopup = Inherit(BasePanel) local this = BattleBestPopup local func2 = nil--此回调目前只有大闹天宫试炼节点用 当有没有事件时 关闭按钮不好使 function this:InitComponent() this.spLoader = SpriteLoader.New() 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, skinId, damageValue, allDamage, func,_func2) func2 = _func2 -- 创建立绘 local heroTData = {} local toward=0 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 else data= ConfigManager.GetConfigData(ConfigName.HeroConfig,heroTId) toward=data.Toward end heroTData.Live = GetResourcePath(data.Live) if heroTId==10016 then heroTData.Live=GetResourcePath(data.Painting) end heroTData.Scale = data.Scale heroTData.Position = data.Position heroTData.Name = GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.HeroConfig,heroTId).ReadingName) else 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 this.liveName = 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(10, 10) SetHEeroLiveToward(this.liveNode,toward) local SkeletonGraphic = this.liveNode:GetComponent("SkeletonGraphic") local idle = function() SkeletonGraphic.AnimationState:SetAnimation(0, heroTId==10016 and "animation" or"idle", true) end SkeletonGraphic.AnimationState:SetAnimation(0, heroTId==10016 and "animation" or"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.Name -- 伤害数值 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