local UIThreeTeamFightBattle = UIViewClass() local EventSystem = require('Event/EventSystem') local INTERVAL_TIME = 5 local curRoundIDS = { [1] = "IDS_OfflineSoloFight_First", [2] = "IDS_OfflineSoloFight_Second", [3] = "IDS_OfflineSoloFight_Third" } function UIThreeTeamFightBattle:OnOpened(context) self:SetPushStyle(LuaConst.PushStyleEnum.HIDE) UIUtils.SetActive(self.group_Start, false) self:RegistSystemEvent(EventID.NineVsNine_RoundOver, self.OnRoundOver) self:RegistSystemEvent(EventID.NineVsNine_RoundStart, self.OnRoundStart) self:RegistSystemEvent(EventID.UI_UpdateBuff_OtherHero, self.UpdateBuffShow) self:RegistSystemEvent(EventID.UI_UpdateBuff_Self, self.UpdateOwnBuffShow) self.winCount = 0 self.lab_LeftRoleName.text = BattleDataGetter.GetPlayerName() self.lab_RightRoleName.text = BattleDataGetter.GetEnemyPlayerName() self:OnUpdateFun() self:StartRepeatFunc(self.OnUpdateFun, 1) self.txt_Score.text = "0:0" self.curRound = 1 self:InitPlayers() self:CountDown() end function UIThreeTeamFightBattle:OnRoundOver(round, isWin) if isWin then CTL.Sound.PlayGameSound("UI_victory_v1") self.winCount = self.winCount + 1 else CTL.Sound.PlayGameSound("UI_failed_v1") end self.summaryTemplateEffectHandle1, self.summaryTemplateEffectHandle2 = CTL.LevelSelect.ShowCommonSummaryTemplate(self, isWin) local failCount = round - self.winCount self.txt_Score.text = self.winCount .. ":" .. failCount self.resultShow = true self.resultShowTime = INTERVAL_TIME self.lab_Tips.text = nil self.curRound = self.curRound + 1 UIUtils.SetActive(self.group_Result, true) end function UIThreeTeamFightBattle:CountDown() UIUtils.SetActive(self.group_Result, false) self.resultShow = false self.countDownNum = 3 CTL.LevelSelect.CloseCommonSummaryTemplate(self) UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleCountDownFormalPanel) EventSystem.Dispatch(EventID.UI_UIBattleCountDownPanel_SetNumber, self.countDownNum) end function UIThreeTeamFightBattle:OnUpdateFun() if self.resultShow then self.resultShowTime = self.resultShowTime - 1 if self.resultShowTime <= 3 then self.lab_Tips.text = string.FormatByIdsId(Const_IDS.IDS_OfflineSoloFight_UIshowBetweenTwoBattles, self.resultShowTime) end if self.resultShowTime <= 0 then LuaInputManager.EnqueueSpecialCommand(LuaConst.SpecialCommandType.SoloFightNextRound) logging.crit(LTAG.CRIT, "GWS : 9v9发送进入下一局指令") self.resultShow = false CTL.LevelSelect.CloseCommonSummaryTemplate(self) end elseif self.countDownNum then self.countDownNum = self.countDownNum - 1 EventSystem.Dispatch(EventID.UI_UIBattleCountDownPanel_SetNumber, self.countDownNum) if self.countDownNum <= 0 then UIManager.CloseView(Const_UI_Lua.UIEnum.UIBattleCountDownFormalPanel) self:RoundBegin() self.countDownNum = nil end end local curTimer = BattleDataGetter.GetRemainTime() UIUtils.SetLabel(self.txt_Time, UTL.Time.FormatTimeBySeconds(curTimer)) end function UIThreeTeamFightBattle:OnRoundStart(round) self:InitPlayers() UIUtils.SetActive(self.group_Result, false) self:RoundBegin() end function UIThreeTeamFightBattle:RoundBegin() UIUtils.SetActive(self.group_Start, true) self.txt_Num.text = string.format(UIUtils.GetLocalizedTxt(Const_IDS[curRoundIDS[self.curRound]])) self:PlayUIAnimation("enterMap") CTL.Sound.PlayGameSound("UI_begin") end function UIThreeTeamFightBattle:OnButtonClicked(comp) if comp == self.btn_close then if self.resultShow then if self.resultShowTime <= 3 then self.resultShow = false CTL.LevelSelect.CloseCommonSummaryTemplate(self) LuaInputManager.EnqueueSpecialCommand(LuaConst.SpecialCommandType.SoloFightNextRound) logging.crit(LTAG.CRIT, "GWS : 9v9发送进入下一局指令") end end elseif comp == self.btn_Setting then UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingMainPanel) elseif comp == self.btn_Exit then CTL.Setting.BackToTown() end end function UIThreeTeamFightBattle:OnClosed() CTL.LevelSelect.RemoveSummaryTemplateEffect(self) end function UIThreeTeamFightBattle: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 UIThreeTeamFightBattle: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 UIThreeTeamFightBattle: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 ownEntityList = BattleDataGetter.GetHeroEntityTable(LuaConst.STANDALONE_PLAYER_PlayID) local enemyEntityList = BattleDataGetter.GetHeroEntityTable(LuaConst.STANDALONE_ENEMYPLAYER1_PLAYID) for i, entity in ipairs(ownEntityList) do self:RegistSystemEvent(entity.Event_EntityHPChanged, self.RefreshPlayer) self:CreatePlayerHead(entity, true) end for i, entity in ipairs(enemyEntityList) do self:RegistSystemEvent(entity.Event_EntityHPChanged, self.RefreshPlayer) self:CreatePlayerHead(entity, false) 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 UIThreeTeamFightBattle: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 UIThreeTeamFightBattle:CreatePlayerHead(entity, isPlayerSelf) if isPlayerSelf then table.insert(self.friendEntityIndex, entity:GetEntityID()) self:UpdatePlayer(entity, #self.friendEntityIndex, false) else table.insert(self.enemyEntityIndex, entity:GetEntityID()) self:UpdatePlayer(entity, #self.enemyEntityIndex, true) end end function UIThreeTeamFightBattle:UpdatePlayer(entity, index, isEnemy) if index > 3 then return 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 return UIThreeTeamFightBattle