local UIHeroMatch3v3InBattleInfo = UIViewClass() local VICTORY_EFFECT_SHOW_TIME = DataSheetManager.ConstData:GetDataByID("HeroMatch3v3Interface3").IntValue function UIHeroMatch3v3InBattleInfo:OnOpened(context) self:RegistSystemEvent(EventID.Battle_HeroMatch3v3_NextRound, self.RefreshBattleInfo) self:RegistSystemEvent(EventID.UI_UIBattleCountDownPanel_CloseEvent, self.ShowBattleRound) self:RegistSystemEvent(EventID.UIBattle_VictoryPopPanelClosed, self.ShowBattleRound) self:RegistSystemEvent(EventID.UI_UpdateBuff_OtherHero, self.UpdateBuffShow) self:RegistSystemEvent(EventID.UI_UpdateBuff_Self, self.UpdateOwnBuffShow) self:RegistSystemEvent(EventID.SDK_OnVoiceRoomStateChange, self.RefreshVoiceUI) --获取语音状态 if not BattleDataGetter.IsInLevelWatchBattle() and not GameAppInfo.IsJapanesePackage() then MDL.VoiceRoom.VoiceCallStateReq(MDL.VoiceRoom.VoiceRoomType.Room_HeroMatch3V3) else UIUtils.SetActive(self.img_VoiceChat, false) end if BattleDataGetter.GetMyCampID() == 1 then self.txt_TeamName1.text = BattleDataGetter.GetCampName1() self.txt_TeamName2.text = BattleDataGetter.GetCampName2() else self.txt_TeamName1.text = BattleDataGetter.GetCampName2() self.txt_TeamName2.text = BattleDataGetter.GetCampName1() end self:StartRepeatFunc(self.RefreshLeftTime, 1, -1) self:InitPlayers() self:UpdateScore() end function UIHeroMatch3v3InBattleInfo:RefreshVoiceUI() UIUtils.SetActive(self.img_VoiceChat, true) self.state_Listen:SetState(CTL.VoiceRoom.IsEnabledListener() and 0 or 1) self.state_Speak:SetState(CTL.VoiceRoom.IsEnabledMicrophone() and 0 or 1) end function UIHeroMatch3v3InBattleInfo:InitPlayers() if self.friendEntityBuffPanel then for i, v in ipairs(self.friendList) do v.buffCanvas:CloseAll() end end self.friendEntityBuffPanel = {} if self.enemyEntityBuffPanel then for i, v in ipairs(self.enemyList) do v.buffCanvas:CloseAll() end end self.enemyEntityBuffPanel = {} self.enemyEntityIndex = {} self.friendEntityIndex = {} self.hasLoadPlayerHeadImg = false local sortList = {} for i, entity in ipairs(BattleDataGetter.GetActiveEntityList()) do if entity:IsPlayerSelf() then table.insert(sortList, 1, entity) else table.insert(sortList, entity) end end for i, entity in ipairs(sortList) do self:RegistSystemEvent(entity.Event_EntityHPChanged, self.RefreshPlayer) self:CreatePlayerHead(entity, entity._logicInitData.EntityCampID) end for i, v in ipairs(self.friendList) do if i > #self.friendEntityIndex then UIUtils.SetActive(v.gameObject, false) else UIUtils.SetActive(v.gameObject, true) end end for i, v in ipairs(self.enemyList) do if i > #self.enemyEntityIndex then UIUtils.SetActive(v.gameObject, false) else UIUtils.SetActive(v.gameObject, true) end end self.hasLoadPlayerHeadImg = true end function UIHeroMatch3v3InBattleInfo:CreatePlayerHead(entity, campId) if campId ~= BattleDataGetter.GetMyCampID() then table.insert(self.enemyEntityIndex, entity:GetEntityID()) self:UpdatePlayer(entity, #self.enemyEntityIndex, true) else table.insert(self.friendEntityIndex, entity:GetEntityID()) self:UpdatePlayer(entity, #self.friendEntityIndex, false) end end function UIHeroMatch3v3InBattleInfo:UpdatePlayer(entity, index, isEnemy) if index > 3 then return -- 3v3正常是6个人 也只有6个头像 超过会报错 但是测试过程中 可能有超过6个人 这么写一下 如果判断celltable 有其它问题可能给检测不到 end local roleId = entity._logicInitData.CharacterID local cellTable = nil if isEnemy then cellTable = self.enemyList[index] else cellTable = self.friendList[index] end --头像只加载一次 if self.hasLoadPlayerHeadImg == false then UTL.Item.SetHeroIconByHeroId(cellTable.texture_HeadImg, roleId, BattleDataGetter.GetHeroIsAwaken(entity:GetPlayerID(), roleId)) local entityId = entity:GetEntityID() if entity:IsPlayerSelf() then self.friendEntityBuffPanel[index] = self.friendList[index].buffCanvas:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISyncTeamBuffPanel), { entityId = entityId, buffType = LuaConst.UIBuffShowType.PlayerSelf }) else if isEnemy then self.enemyEntityBuffPanel[index] = self.enemyList[index].buffCanvas:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISyncTeamBuffPanel), { entityId = entityId, buffType = LuaConst.UIBuffShowType.PlayerOthers }) else self.friendEntityBuffPanel[index] = self.friendList[index].buffCanvas:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISyncTeamBuffPanel), { entityId = entityId, buffType = LuaConst.UIBuffShowType.PlayerOthers }) end end end local hpValue = FP.tonumberV1(entity.components.attr.hp / entity.components.attr:GetAttrValue(LuaConst.AttrType.hplmt)) cellTable.sprite_HpFg_Show.fillAmount = hpValue if hpValue > 0 then UIUtils.SetActive(cellTable.sprite_ReviveMask, false) else UIUtils.SetActive(cellTable.sprite_ReviveMask, true) end end function UIHeroMatch3v3InBattleInfo:RefreshPlayer(entity, delta, value) if CampManager.IsEnemyCamp(entity:GetCampID(), BattleDataGetter.GetMyCampID()) then for i, v in ipairs(self.enemyEntityIndex) do if v == entity:GetEntityID() then self:UpdatePlayer(entity, i, true) return end end else for i, v in ipairs(self.friendEntityIndex) do if v == entity:GetEntityID() then self:UpdatePlayer(entity, i, false) return end end end end function UIHeroMatch3v3InBattleInfo:UpdateBuffShow(entity, buffData, time, layer, sourceEntityId) for i, v in ipairs(self.enemyEntityIndex) do if v == entity:GetEntityID() then if self.enemyList[i] then self.enemyEntityBuffPanel[i]:UpdateBuffShow(buffData, time, layer, sourceEntityId) return end end end for i, v in ipairs(self.friendEntityIndex) do if v == entity:GetEntityID() then if self.friendList[i] then self.friendEntityBuffPanel[i]:UpdateBuffShow(buffData, time, layer, sourceEntityId) return end end end end function UIHeroMatch3v3InBattleInfo:UpdateOwnBuffShow(entity, buffData, time, layer, sourceEntityId) for i, v in ipairs(self.friendEntityIndex) do if v == entity:GetEntityID() then self.friendEntityBuffPanel[i]:UpdateBuffShow(buffData, time, layer, sourceEntityId) return end end end function UIHeroMatch3v3InBattleInfo:ShowBattleRound() CTL.HeroMatch3v3.ShowBattleRoundIcon(self.curRound) end function UIHeroMatch3v3InBattleInfo:RefreshBattleInfo(round, loserCampID) self:InitPlayers() local isWin = loserCampID ~= BattleDataGetter.GetMyCampID() CTL.LevelSelect.ShowCommonSummaryTemplatePanel(isWin, VICTORY_EFFECT_SHOW_TIME, "IDS_HeroMatch3v3_WaitNextBattle") self:UpdateScore() end function UIHeroMatch3v3InBattleInfo:RefreshLeftTime(deltaTime, timeSinceUpdate) local time = BattleDataGetter.GetRoundRemainTime() if time >= 0 then UIUtils.SetLabel(self.txt_Time, UTL.Time.FormatTimeBySeconds(time)) else UIUtils.SetLabel(self.txt_Time, "") end end function UIHeroMatch3v3InBattleInfo:UpdateScore() local scoreList = BattleDataGetter.GetHeroMatch1v1RoundWinners() local myScore, enemyScore = 0, 0 self.curRound = #scoreList + 1 if #scoreList > 0 then for _, winCampID in ipairs(scoreList) do if BattleDataGetter.GetMyCampID() == winCampID then myScore = myScore + 1 else enemyScore = enemyScore + 1 end end end UIUtils.SetLabel(self.txt_Score1, myScore) UIUtils.SetLabel(self.txt_Score3, enemyScore) UIUtils.SetLabel(self.txt_Round, string.FormatByIdsId(Const_IDS["IDS_HeroMatch3v3_Round4"], self.curRound)) end function UIHeroMatch3v3InBattleInfo:OnButtonClicked(comp) if comp == self.img_Listen then --收听 local listen, call = CTL.VoiceRoom.IsEnabledListener(), CTL.VoiceRoom.IsEnabledMicrophone() listen = not listen MDL.VoiceRoom.VoiceCallSetStateReq(MDL.VoiceRoom.VoiceRoomType.Room_HeroMatch3V3, call, listen) if listen then CTL.Tips.AddTipsMsg(Const_IDS["IDS_WarChannel_Listening"]) CTL.Sound.PlayGameSound("UI_voice_system") else CTL.Tips.AddTipsMsg(Const_IDS["IDS_WarChannel_NotListening"]) CTL.Sound.PlayGameSound("UI_invalid") end elseif comp == self.img_Speak then --麦克风 local listen, call = CTL.VoiceRoom.IsEnabledListener(), CTL.VoiceRoom.IsEnabledMicrophone() call = not call MDL.VoiceRoom.VoiceCallSetStateReq(MDL.VoiceRoom.VoiceRoomType.Room_HeroMatch3V3, call, listen) if call then CTL.Tips.AddTipsMsg(Const_IDS["IDS_WarChannel_NotSpeakingBtn"]) CTL.Sound.PlayGameSound("UI_voice_system") else CTL.Tips.AddTipsMsg(Const_IDS["IDS_WarChannel_SpeakingBtn"]) CTL.Sound.PlayGameSound("UI_invalid") end end end return UIHeroMatch3v3InBattleInfo