local UIEntityBasePanel = require "View/Battle/BattleEntityUI/UIEntityBasePanel" local UIEntityGeneralPanel = UIViewClass(UIEntityBasePanel) local EntityUIBaseModule = require("View/Battle/BattleEntityUI/EntityUIModule/EntityUIBaseModule") local EventSystem = require("Event/EventSystem") local LuaUpdater = require("Main/LuaUpdater") local LuaBit = require("bit") local EnemyPath = ConstAssetPathConfig.EnemyPath local FriendPath = ConstAssetPathConfig.FriendPath local EffectPath = ConstAssetPathConfig.EffectPath2 function UIEntityGeneralPanel:OnCreated() self.uiElementParams = { UseZoom = true, -- 是否使用头顶大小跟随距离变化 MaxDistSqrModelUI = 35 * 35, ModelUIMinDistance = 5, ModelUIMaxDistance = 50, ModelUIMinScale = 1, ModelUIMaxScale = 1.2, } self.generalHideType = false end function UIEntityGeneralPanel:OnOpened(context) self:RegistSystemEvent(EventID.UIBattle_GeneralElement_Create, self.CreateGeneralElement) -- 创建名字板UI self:RegistSystemEvent(EventID.UIBattle_GeneralElement_BreakAmmor, self.ElementPlayWeakEffect) -- 击破护甲进入虚弱状态 self:RegistSystemEvent(EventID.UIBattle_GeneralElement_UpdateArmor, self.ElementUpdateArmor) -- 修改名字板UI护甲条 end function UIEntityGeneralPanel:CreateGeneralElement(expEntity, name) if expEntity.RenderEntity then local elementData = self:CreateElementData(expEntity) local element = elementData.element EntityUIBaseModule.ElementActive(elementData, false) UIUtils.SetLabel(element.localLab_Name, name) UIUtils.SetActive(element.sprite_HeadImg, elementData.isEnemy) if elementData.isEnemy then UIUtils.SetImageByAssetBundle(element.sprite_HpFg, EnemyPath) else UIUtils.SetImageByAssetBundle(element.sprite_HpFg, FriendPath) end expEntity:CreateHeadUI() else if BattleDataGetter.IsTownLevel() then EventSystem.Dispatch(EventID.UI_AddBattleModelUI) end end end -- 设置隐藏层级(实现基类方法) function UIEntityGeneralPanel:SetHideType(hideLayer, hide) if hide then if LuaBit.band(hideLayer, LuaBit.lshift(1, LuaConst.Layer.Soldier_Friend)) > 0 then self.generalHideType = true end if LuaBit.band(hideLayer, LuaBit.lshift(1, LuaConst.Layer.Soldier_Enemy)) > 0 then self.generalHideType = true end else self.generalHideType = false end end ---------- Start 具体的子项Element操作 Start ---------- -- 改变名字(实现基类方法) function UIEntityGeneralPanel:ElementChangeName(renderEntity, name) local elementData = self.elementDic[renderEntity] if elementData then UIUtils.SetLabel(elementData.element.localLab_Name, name) end end function UIEntityGeneralPanel:ElementPlayWeakEffect(renderEntity) local elementData = self.elementDic[renderEntity] if elementData then EntityUIBaseModule.ElementStartEffect(elementData, EffectPath, 3, elementData.element.sprite_ArmorFg.transform, self.gameObject.layer) end end -- 更新血条(实现基类方法) function UIEntityGeneralPanel:ElementUpdateHP(renderEntity, hp, pc, maxHp, init) if init or hp > 0 then local elementData = self.elementDic[renderEntity] if elementData then local percent = 0 if maxHp > 0 then percent = hp / maxHp end UIUtils.SetAtlasImageFillAmount(elementData.element.sprite_HpFg, percent) end else self:ElementActive(renderEntity, false) end end function UIEntityGeneralPanel:ElementUpdateArmor(renderEntity, am, maxAm, init) local elementData = self.elementDic[renderEntity] if elementData then local percent = 0 if maxAm > 0 then percent = am / maxAm end UIUtils.SetAtlasImageFillAmount(elementData.element.sprite_ArmorFg, percent) end end function UIEntityGeneralPanel:GetElementHide(elementData) return self.generalHideType end --空方法不删,防止执行base function UIEntityGeneralPanel:ElementDestroyAllHeadUI(elementData) end ------------ End 具体的子项Element操作 End ------------ return UIEntityGeneralPanel