local UIBattlePlayerHeadBase = require("View/Battle/UIBattlePlayerHeadBase") local UIHeadCircleCommon = UIViewClass(UIBattlePlayerHeadBase) function UIHeadCircleCommon:OnOpened(context) self.headInfo = BattleDataGetter.GetHeadInfoByPlayerID_SelectOneRevive(context.playerID) self.isSelf = BattleDataGetter.GetCurPlayerID() == context.playerID UTL.Item.SetHeroIconByHeroId(self.head.img_HeroHead, self.headInfo[1].heroID, BattleDataGetter.GetHeroIsAwaken(context.playerID, self.headInfo[1].heroID)) self.head.txt_PlayerName.text = BattleDataGetter.GetPlayerNameByPlayerID(context.playerID) self:RegistEvent() end function UIHeadCircleCommon:SetPlayerHp(hpPercent) self.head.img_HeroHp.fillAmount = hpPercent or 1 end function UIHeadCircleCommon:OnHeroDead(playerID) if playerID == self.context.playerID then self.headInfo = BattleDataGetter.GetHeadInfoByPlayerID_SelectOneRevive(self.context.playerID) UIUtils.SetGray(self.head.img_HeroHead, true) end end function UIHeadCircleCommon:OnSwitchHero(switchHeroType, entity) if entity:GetPlayerID() == self.context.playerID then self.headInfo = BattleDataGetter.GetHeadInfoByPlayerID_SelectOneRevive(self.context.playerID) UTL.Item.SetHeroIconByHeroId(self.head.img_HeroHead, self.headInfo[1].heroID, BattleDataGetter.GetHeroIsAwaken(self.context.playerID, self.headInfo[1].heroID)) UIUtils.SetGray(self.head.img_HeroHead, false) end end function UIHeadCircleCommon:OnHPMessageChanged(entity) if entity:GetPlayerID() == self.context.playerID then local comp_Attr = entity.components.attr local hplmt = comp_Attr:GetAttrValueNum(LuaConst.AttrType.hplmt) if hplmt <= 0 then return end local hp = FP.tonumberV1(comp_Attr.hp) local pc = FP.tonumberV1(comp_Attr.pc) local totalValue = pc + hp >= hplmt and pc + hp or hplmt self:SetPlayerHp(hp/totalValue) end end function UIHeadCircleCommon:OnPlayerRevive(entity) if entity:GetPlayerID() == self.context.playerID then self.headInfo = BattleDataGetter.GetHeadInfoByPlayerID_SelectOneRevive(self.context.playerID) UTL.Item.SetHeroIconByHeroId(self.head.img_HeroHead, self.headInfo[1].heroID, BattleDataGetter.GetHeroIsAwaken(self.context.playerID, self.headInfo[1].heroID)) UIUtils.SetGray(self.head.img_HeroHead, false) end end function UIHeadCircleCommon:OnPlayerOffLine(playerID) if playerID == self.context.playerID then UIUtils.SetActive(self.head.group_Offline, true) end end function UIHeadCircleCommon:OnPlayerQuit(playerID) if playerID == self.context.playerID then self:CloseView() end end function UIHeadCircleCommon:OnPlayerReconnected(playerID) if playerID == self.context.playerID then UIUtils.SetActive(self.head.group_Offline, false) end end return UIHeadCircleCommon