---@class WBP_BossNarration_C:UUserWidget ---@field TextBlock_Narration UTextBlock --Edit Below-- local WBP_BossNarration = { bInitDoOnce = false, VisibilityTimerHandle = nil, }; local KillPlayerNarrationTxt = { [0] = "蝼蚁们,来迎接世界末日,体验地狱的味道吧!", [1] = "小喽啰,不堪一击。", [2] = "以卵击石?", [3] = "就跟宰小鸡仔一样,无趣的很啊。", [4] = "换一批吧,这批太弱了。", } local HealthPercentNarrationTxt = { {value = 0.8, txt = "哟,居然还有点疼,再用点力哦!"}, {value = 0.5, txt = "好吧,你们有资格让我重视,小心了。"}, {value = 0.3, txt = "啊,居然受伤了!你们惹怒我了!"}, {value = 0.1, txt = "停停停,不要得寸进尺!我们可以坐下来谈!"}, {value = 0.0, txt = "等着!我还会再来的!"}, } function WBP_BossNarration:Construct() self:SetVisibility(ESlateVisibility.Collapsed) end function WBP_BossNarration:UpdateKilledPlayerNum(KilledPlayerNum) if self.VisibilityTimerHandle ~= nil then EventSystem.StopTimer(self.VisibilityTimerHandle) end KilledPlayerNum = math.clamp(KilledPlayerNum, 0, 4) self:UpdateNarrationText(KillPlayerNarrationTxt[KilledPlayerNum]) end function WBP_BossNarration:UpdateOwnerHealth(CurrentHP, MaxHP) local NarrationText = "" for i, v in pairs(HealthPercentNarrationTxt) do local Percent = CurrentHP / MaxHP if math.isNearlyEqual(Percent, v.value, 0.01) then NarrationText = v.txt self:UpdateNarrationText(v.txt) break end end end function WBP_BossNarration:UpdateNarrationText(InText) self:SetVisibility(ESlateVisibility.HitTestInvisible) self.TextBlock_Narration:SetText(InText) if self.VisibilityTimerHandle ~= nil then EventSystem.StopTimer(self.VisibilityTimerHandle) end self:SetupTimer() end function WBP_BossNarration:SetupTimer() self.VisibilityTimerHandle = EventSystem.SetTimer(self, function() self:SetVisibility(ESlateVisibility.Collapsed) end, 3) end return WBP_BossNarration;