local UIBattleKillInfoNotice = UIViewClass() local HideTime = 7 local GuildWarSerialKillNum = DataSheetManager.ConstData:GetDataByID("GuildWarSerialKillNum").IntValue function UIBattleKillInfoNotice:OnOpened(content) self.allHide = true self.hideLoopKill = {} self.firstCellPosX, self.firstCellPosY = self.loop_Kill[3].gameObject.transform:GetAnchoredPosition() self:RegistSystemEvent(EventID.SyncBattle_KillInfoNotice, self.OnNewKillMsg) self.compareCamp = content and content.compareCamp end ---击杀表现 function UIBattleKillInfoNotice:OnNewKillMsg(msg) self:ShowKillMsg(msg) self:AddStrongKill(msg) end function UIBattleKillInfoNotice:ShowKillMsg(msg) if self.allHide then local cell = self.loop_Kill[3] self:OnCellInit(cell, msg) UIUtils.SetActive(cell.gameObject, true) --第一次显示 播放最下层信息动画 self.firstId = self:PlayUIAnimation(ConstAssetPathConfig.AssetPath111, self.loop_Kill[3].gameObject.transform, true) self.hideLoopKill[self.loop_Kill[3]] = UTL.Time.GetLocalTimestamp() self.playing = true self.allHide = false self:StartRepeatFunc(self.HideLoopKill, 1, -1) else self.curShowMsgs = self.curShowMsgs or {} table.insert(self.curShowMsgs, msg) if not self.playing then self:PlayNext() end end end function UIBattleKillInfoNotice:HideLoopKill() for k, v in pairs(self.hideLoopKill) do if v then local time = UTL.Time.GetLocalTimestamp() - v if time >= HideTime then self:PlayUIAnimation(ConstAssetPathConfig.AssetPath112, k.gameObject.transform) self.hideLoopKill[k] = nil end end end if not next(self.hideLoopKill) then self.allHide = true end end function UIBattleKillInfoNotice:ShowKillInfo() if #self.strongKillList == 0 then UIUtils.SetActive(self.group_KillTip.gameObject, false) else UIUtils.SetActive(self.group_KillTip.gameObject, true) self.group_KillTip.effect_KillIcon:StopUIEffect() self:StartRepeatFunc(self.ShowKillEffect, 0.3, 1) self.showKillInfoPlaying = true local data = table.remove(self.strongKillList, 1) UIUtils.SetLabelText(self.group_KillTip.txt_KillScore, Const_IDS[data[2]]) UTL.Item.SetHeroIconByHeroId(self.group_KillTip.texture_Head_1, data[1].playerHeroIdA, BattleDataGetter.GetHeroIsAwaken(data[1].playerIdA, data[1].playerHeroIdA)) UTL.Item.SetHeroIconByHeroId(self.group_KillTip.texture_Head_2, data[1].playerHeroIdB, BattleDataGetter.GetHeroIsAwaken(data[1].playerIdB, data[1].playerHeroIdB)) self:StartRepeatFunc(self.ShowDelayKillInfo, 3, 1) self:UpdateKillNameColor(data[1], self.group_KillTip.txt_PlayerName_1, self.group_KillTip.txt_PlayerName_2) CTL.Sound.PlayGameSound("UI_jibai") end end function UIBattleKillInfoNotice:ShowDelayKillInfo() self.showKillInfoPlaying = false self:ShowKillInfo() end function UIBattleKillInfoNotice:ShowKillEffect() self.group_KillTip.effect_KillIcon:PlayUIEffect() end function UIBattleKillInfoNotice:SetKillInfo(msg, dec) if msg.playerHeroIdA > 0 and msg.playerHeroIdB then if not self.strongKillList or (#self.strongKillList == 0 and not self.showKillInfoPlaying) then self.strongKillList = self.strongKillList or {} table.insert(self.strongKillList, { msg, dec }) self:ShowKillInfo() else table.insert(self.strongKillList, { msg, dec }) end end end function UIBattleKillInfoNotice:AddStrongKill(msg) if msg.firstBlood == 1 then self:SetKillInfo(msg, "IDS_GuildWar_KillBroadcast_FirstBlood") -- 第一滴血 else if msg.killNumsB > 3 then self:SetKillInfo(msg, "IDS_GuildWar_KillBroadcast_Shutdown") --终结 end if msg.killNums > MDL.GuildWar.GetKillMaxTitleId() then if (msg.killNums - MDL.GuildWar.GetKillMaxTitleId()) % GuildWarSerialKillNum == 0 then local data = DataSheetManager.GuildWarKillBroadcast:GetDataByID(MDL.GuildWar.GetKillMaxTitleId()) if data then self:SetKillInfo(msg, data.Text) end end else local isSuccess, data = DataSheetManager.GuildWarKillBroadcast:TryGetDataByID(msg.killNums) if isSuccess then self:SetKillInfo(msg, data.Text) end end end end function UIBattleKillInfoNotice:OnUIAnimationStoped(id) if self.killPlayId == id then if self.curShowMsgs and #self.curShowMsgs > 0 then local cell1 = self.loop_Kill[1] local cell2 = self.loop_Kill[2] local cell3 = self.loop_Kill[3] self.loop_Kill[1] = cell2 self.loop_Kill[2] = cell3 self.loop_Kill[3] = cell1 local msg = table.remove(self.curShowMsgs, 1) self:OnCellInit(self.loop_Kill[3], msg) self.loop_Kill[3].gameObject.transform:SetAnchoredPosition(self.firstCellPosX, self.firstCellPosY) self.loop_Kill[3].gameObject:SetActive(true) self.firstId = self:PlayUIAnimation(ConstAssetPathConfig.AssetPath111, self.loop_Kill[3].gameObject.transform, true) self.hideLoopKill[self.loop_Kill[3]] = UTL.Time.GetLocalTimestamp() end elseif self.firstId == id then self:PlayNext() end end function UIBattleKillInfoNotice:PlayNext() if self.curShowMsgs and #self.curShowMsgs > 0 then self.playing = true --击杀动画 已经显示的上移 腾出位置给新的显示动画 if self.hideLoopKill[self.loop_Kill[2]] then self:PlayUIAnimation(ConstAssetPathConfig.Path16, self.loop_Kill[2].gameObject.transform) self.hideLoopKill[self.loop_Kill[2]] = UTL.Time.GetLocalTimestamp() end self.killPlayId = self:PlayUIAnimation(ConstAssetPathConfig.Path16, self.loop_Kill[3].gameObject.transform, true) self.loop_Kill[1].gameObject:SetActive(false) self.hideLoopKill[self.loop_Kill[3]] = UTL.Time.GetLocalTimestamp() else self.playing = false end end function UIBattleKillInfoNotice:OnCellInit(cellTable, data) self:UpdateKillNameColor(data, cellTable.txt_Name01, cellTable.txt_Name02) end function UIBattleKillInfoNotice:UpdateKillNameColor(data, textLeft, textRight) local curEntity = BattleDataGetter.GetCurEntity() if curEntity then local compareParam = self:GetCompareParam() if data.playerNameB == BattleDataGetter.GetPlayerName() then textLeft.text = UTL.Color.FormatTextByColor("e46b71", data.playerNameA) textRight.text = UTL.Color.FormatGreenColor(data.playerNameB) elseif data.playerNameA == BattleDataGetter.GetPlayerName() then textLeft.text = UTL.Color.FormatGreenColor(data.playerNameA) textRight.text = UTL.Color.FormatTextByColor("e46b71", data.playerNameB) else if string.isNilOrEmpty(compareParam) then textLeft.text = UTL.Color.FormatTextByColor("e46b71", data.playerNameA) textRight.text = UTL.Color.FormatTextByColor("e46b71", data.playerNameB) else if data.guildIdB == compareParam then textLeft.text = UTL.Color.FormatTextByColor("e46b71", data.playerNameA) textRight.text = UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, data.playerNameB) elseif data.guildIdA == compareParam then textLeft.text = UTL.Color.FormatTextByColor(UTL.Color.ModelNameColor.Blue, data.playerNameA) textRight.text = UTL.Color.FormatTextByColor("e46b71", data.playerNameB) else textLeft.text = UTL.Color.FormatTextByColor("e46b71", data.playerNameA) textRight.text = UTL.Color.FormatTextByColor("e46b71", data.playerNameB) end end end end end function UIBattleKillInfoNotice:GetCompareParam() if not self.compareParam then local curEntity = BattleDataGetter.GetCurEntity() if self.compareCamp then self.compareParam = curEntity:GetCampID() else self.compareParam = curEntity:GetGuildID() end end return self.compareParam end return UIBattleKillInfoNotice