local UIInBattleView = require "View/Battle/UIInBattleView" local UISyncSoloEnemyPlayerView = UIViewClass(UIInBattleView) local SelfEntityMaxCount = 3 local HpImgPath = ConstAssetPathConfig.HpImgPath function UISyncSoloEnemyPlayerView:OnOpened(context) self.InitMaterial = false self:RegistSystemEvent(EventID.UIBattle_Level_CreateEntityByData, self.SetPlayerSelfData) self:RegistSystemEvent(EventID.UI_UpdateBuff_OtherHero, self.UpdateBuffShow) self.PlayerSelf[1].img_MainHeroMask.useRealTimeUpdate = false self.PlayerSelf[1].img_SubHeroCDMask.useRealTimeUpdate = false UIUtils.SetActive(self.PlayerSelf[3].img_ExpelMonsterMask, false) if context then self.buffType = context.buffType self.playerUIType = context.playerUIType self.playerId = context.playerId end self:InitView() self:SetPlayerSelfData() end ----Buff更新 function UISyncSoloEnemyPlayerView:UpdateBuffShow(entity, buffData, time, layer, sourceEntityId) if not BattleDataGetter.CheckEntityBelongsToPlayer(entity.EntityID, self.playerId) then return end self.buffPanel:UpdateBuffShow(buffData, time, layer, sourceEntityId) end function UISyncSoloEnemyPlayerView:OpenInit() end function UISyncSoloEnemyPlayerView:InitView() self.buffPanel = self.PlayerSelf[1].buffItem_Root:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleBuffPanel), {type = self.buffType, entityId = BattleDataGetter.GetPlayerActiveEntity(self.playerId):GetEntityID()}, "Battle/UIBattleBuffOppositePanel") end function UISyncSoloEnemyPlayerView:UpdateAdjutantCD(entity, cdTime) if BattleDataGetter.CheckEntityBelongsToPlayer(entity.EntityID, self.playerId) then local playerView = self.selfEntityView[entity.EntityID] if playerView == nil then return end if cdTime then playerView.img_SubHeroCDMask:ResetAndBeginTimer(false, cdTime / 1000) UIUtils.SetActive(playerView.img_Active, false) else playerView.img_SubHeroCDMask:EndTimer() UIUtils.SetActive(playerView.img_Active, true) end end end function UISyncSoloEnemyPlayerView:SetPlayerSelfData() table.clearArray(self.selfEntityView) local entityList = BattleDataGetter.GetHeroEntityTable(self.playerId) local count = self:IsCanSwitchHeroLevel() and #entityList or 1 for i = 1, count do UIUtils.SetActive(self.PlayerSelf[i].gameObject, true) self.selfEntityView[entityList[i].EntityID] = self.PlayerSelf[i] self.PlayerSelf[i].img_MainHeroMask.useRealTimeUpdate = false self.PlayerSelf[i].img_SubHeroCDMask.useRealTimeUpdate = false if i > 1 then UIUtils.SetActive(self.PlayerSelf[i].txt_PlayerName.gameObject, false) --self.PlayerSelf[i].img_HeroHpBg:SetState(2) self.PlayerSelf[i].state_SubHero:SetState(0) if not self.InitMaterial then self.PlayerSelf[i].img_HeroHp.material = UTL.Material.GetCircleHpMaterial() end UIUtils.SetImageByAssetBundle(self.PlayerSelf[i].img_HeroHp, HpImgPath) end self:SetOnePlayerData(false, entityList[i]) end self.InitMaterial = true for i = count+1, SelfEntityMaxCount do if self.PlayerSelf[i] then UIUtils.SetActive(self.PlayerSelf[i].gameObject, false) end end end function UISyncSoloEnemyPlayerView:SetTeamPlayerData() end --换将 function UISyncSoloEnemyPlayerView:OnSwitchHero(type, entity) if self.playerId and BattleDataGetter.CheckEntityBelongsToPlayer(entity.EntityID, self.playerId) then self:SwitchHeroByType(type, true) self.buffPanel:OnEntityChange(entity.EntityID) end end function UISyncSoloEnemyPlayerView:SwitchHero(index) end --死亡换将的CD function UISyncSoloEnemyPlayerView:UpdateSwitchCDByDeath() local entityList = BattleDataGetter.GetHeroEntityTable(self.playerId) for index=2, SelfEntityMaxCount do if entityList[index] and not entityList[index]:IsAlive() then self.PlayerSelf[index].img_MainHeroMask:EndTimer() self.PlayerSelf[index].img_MainHeroMask:SetSpriteMaskFillAmount(1) else self.PlayerSelf[index].img_MainHeroMask:ResetAndBeginTimer(false, self.SwitchHeroCD) end end end --手动换将后的CD function UISyncSoloEnemyPlayerView:UpdateSwitchCDByManual() local entityList = BattleDataGetter.GetHeroEntityTable(self.playerId) for index=2, SelfEntityMaxCount do if entityList[index] and entityList[index]:IsAlive() then self.PlayerSelf[index].img_MainHeroMask:ResetAndBeginTimer(false, self.SwitchHeroCD) else self.PlayerSelf[index].img_MainHeroMask:SetSpriteMaskFillAmount(1) end end end function UISyncSoloEnemyPlayerView:OnClosed() UTL.Material.ResetHpMaterialPoolCount() end return UISyncSoloEnemyPlayerView