2025-01-04 23:00:19 +08:00

117 lines
4.6 KiB
Lua

---@class WB_KillInfo_C:UUserWidget
---@field ShowKill UWidgetAnimation
---@field Image_Fist UImage
---@field Image_Frag UImage
---@field Image_Head UImage
---@field Image_Knife UImage
---@field Image_Mechanism UImage
---@field Image_SweepAwayThoroughly UImage
---@field Image_Weapon UImage
---@field TextBlock_AddGrade UTextBlock
---@field TextBlock_Desc UTextBlock
---@field TextBlock_Weapon UTextBlock
---@field WidgetSwitcher_Icon UWidgetSwitcher
---@field Tex_BGWrite UTexture2D
--Edit Below--
---@type WB_KillInfo_C
local WB_KillInfo = {
bInitDoOnce = false;
-- 扫光信息
BeginSweepValue = 1.4;
FinishSweepValue = -1.;
SweepSpeed = 1.5;
SweepTime = 0.;
};
function WB_KillInfo:Construct()
-- self:LuaInit();
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.AddKillInfo, self)
end
function WB_KillInfo:AddKillInfo(VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue)
local LocalPlayerKey = UGCSystemLibrary.GetLocalPlayerKey()
if CauserKey ~= LocalPlayerKey or VictimKey == LocalPlayerKey then
return
end
local WeaponName = (ItemTable.AllItem[WeaponID] and ItemTable.AllItem[WeaponID].Name or "")
local Desc = "弹药伤害"
local DescColor = {SpecifiedColor = {R = 1.000000, G = 1.000000, B = 1.000000, A = 1.000000}, ColorUseRule = 0}
self.WidgetSwitcher_Icon:SetActiveWidgetIndex(0)
if IsHeadShotDamage then
Desc = "精准打击"
DescColor = {SpecifiedColor = {R = 1.000000, G = 0.046875, B = 0.046875, A = 1.000000}, ColorUseRule = 0}
self.WidgetSwitcher_Icon:SetActiveWidgetIndex(4)
elseif UGCSystemLibrary.GetItemTypeID(WeaponID) == 108 then
Desc = "近战打击"
DescColor = {SpecifiedColor={R = 1.000000, G = 0.609327, B = 0.000000, A = 1.000000}, ColorUseRule = 0}
self.WidgetSwitcher_Icon:SetActiveWidgetIndex(5)
elseif UGCSystemLibrary.GetItemTypeID(WeaponID) == 602 then
Desc = "精准预判"
DescColor = {SpecifiedColor = {R = 0.056156, G = 0.334334, B = 1.000000, A = 1.000000}, ColorUseRule = 0}
self.WidgetSwitcher_Icon:SetActiveWidgetIndex(3)
elseif WeaponID < 0 and DamageType == EDamageType.UGCPointDamage then
Desc = "操控专家"
DescColor = {SpecifiedColor = {R = 0.233076, G = 0.000000, B = 1.000000, A = 1.000000}, ColorUseRule = 0}
WeaponName = "机关"
self.WidgetSwitcher_Icon:SetActiveWidgetIndex(1)
elseif WeaponID < 0 then
Desc = "无所畏惧"
DescColor = {SpecifiedColor={R = 1.000000, G = 0.609327, B = 0.000000, A = 1.000000}, ColorUseRule = 0}
WeaponName = "拳击"
self.WidgetSwitcher_Icon:SetActiveWidgetIndex(2)
end
self.TextBlock_Weapon:SetText(WeaponName)
self.TextBlock_Desc:SetText(Desc)
self.TextBlock_Desc:SetColorAndOpacity(DescColor)
self.TextBlock_AddGrade:SetText(string.format("+%d", GlobalConfigs.GetAddScore(WeaponID)))
self.SweepTime = 0.
self:PlayAnimation(self.ShowKill, 0, 1, EUMGSequencePlayMode.Forward, 1);
if self.TickHandle == nil then
self.TickDeltaTime = UGCSystemLibrary.GetGameTime()
self.TickHandle = UGCEventSystem.SetTimerLoop(self, self.CustomTick, 0.02)
end
--- 为自己所杀
if CauserKey == UGCSystemLibrary.GetLocalPlayerKey() then
-- 判断近战击杀
if UGCSystemLibrary.GetItemTypeID(WeaponID) == 108 then
SoundSystem.PlaySound(SoundSystem.ESound.Kill2);
elseif DamageType == EDamageType.UGCPointDamage then
SoundSystem.PlaySound(SoundSystem.ESound.MechanismKill);
else
SoundSystem.PlaySound(SoundSystem.ESound.Kill3);
end
end
end
function WB_KillInfo:CustomTick()
--UGCLogSystem.Log("[WB_KillInfo_CustomTick]")
local DeltaTime = UGCSystemLibrary.GetGameTime() - self.TickDeltaTime
self.TickDeltaTime = UGCSystemLibrary.GetGameTime()
-- UGCLogSystem.Log("[WB_KillInfo_Tick]")
if self.SweepTime < 1 then
local Material = self.Image_SweepAwayThoroughly:GetDynamicMaterial()
---@field SetVectorParameterValue:fun(ParameterName:FName,Value:FLinearColor)
Material:SetVectorParameterValue("Tilling", {R = 1, G = 1, B = 1, A = KismetMathLibrary.Lerp(self.BeginSweepValue, self.FinishSweepValue, self.SweepTime)})
self.SweepTime = self.SweepTime + DeltaTime * self.SweepSpeed
--UGCLogSystem.Log("[WB_KillInfo_CustomTick] TickDeltaTime:%s", tostring(self.TickDeltaTime))
else
UGCEventSystem.StopTimer(self.TickHandle)
self.TickHandle = nil
--UGCLogSystem.Log("[WB_KillInfo_CustomTick] Finish TickDeltaTime:%s", tostring(self.TickDeltaTime))
end
end
-- function WB_KillInfo:Destruct()
-- end
return WB_KillInfo;