169 lines
6.2 KiB
Lua
Raw Permalink Normal View History

2025-01-04 23:00:19 +08:00
---@class WB_FightPanel_C:UUserWidget
---@field ShowKey UWidgetAnimation
---@field Button_Dash UButton
---@field Button_DiscardsKey UButton
---@field Button_EnableHookNum UButton
---@field Button_Hook UButton
---@field Button_KeyMapSetting UButton
---@field Button_Shop UButton
---@field Button_ShowGuide UButton
---@field Button_ShowSetting UButton
---@field HorizontalBox_DashCooling UHorizontalBox
---@field Image_Cooling UImage
---@field Overlay_GameDesc UOverlay
---@field W_TeamScore_Key UW_TeamScore_Key_C
---@field WB_Broadcast UWB_Broadcast_C
---@field WB_KillInfo UWB_KillInfo_C
---@field WidgetSwitcher_HookNum UWidgetSwitcher
--Edit Below--
---@type WB_FightPanel_C
local WB_FightPanel = { bInitDoOnce = false; };
function WB_FightPanel:Construct()
self:LuaInit();
PlayerDeadHideWidget = {};
end
function WB_FightPanel:LuaInit()
if self.bInitDoOnce then
return;
end
self.bInitDoOnce = true;
WidgetLibrary.ButtonOnClickShowPanel(self.Button_ShowSetting, WidgetConfig.EUIType.ButtonSetting);
WidgetLibrary.ButtonOnClickShowPanel(self.Button_ShowGuide, WidgetConfig.EUIType.Guide);
WidgetLibrary.ButtonOnClickShowPanel(self.Button_Shop, WidgetConfig.EUIType.Shop);
WidgetLibrary.BindButtonClicked(self.Button_Dash, self.NotifyPlayerDash, self)
WidgetLibrary.BindButtonPressed(self.Button_Hook, self.NotifyPlayerHook, self)
WidgetLibrary.BindButtonReleased(self.Button_Hook, self.NotifyPlayerStopHook, self)
WidgetLibrary.BindButtonClicked(self.Button_EnableHookNum, self.ChangeHookNum, self)
WidgetLibrary.ButtonOnClickShowPanel(self.Button_KeyMapSetting, WidgetConfig.EUIType.KeyMapSetting)
WidgetLibrary.BindButtonClicked(self.Button_DiscardsKey, self.DiscardsKey, self)
--UGCEventSystem.AddListener(EventEnum.HookNumChange, self.UpdateHookNumText, self)
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.HidePlayerDeadWidget, self)
UGCEventSystem.AddListener(EventEnum.PlayerPossessed, self.ShowReSpawnWidget, self)
UGCEventSystem.AddListener(EventEnum.KeyOwnerChange, self.KeyOwnerChange, self)
-- 玩家死亡时隐藏的组件
self.PlayerDeadHideWidget = {
self.Button_Shop,
self.Button_Hook,
self.Button_Dash,
self.Button_EnableHookNum,
}
self:UpdateHookNum()
UGCEventSystem.SetTimerLoop(self, self.UpdateDashCooling, 0.1)
end
function WB_FightPanel:NotifyPlayerDash()
local LocalPawn = UGCSystemLibrary.GetLocalPlayerPawn()
if LocalPawn then
UGCSendRPCSystem.ActorRPCNotify(nil, LocalPawn, "DashImpulse")
-- UGCSendRPCSystem.ActorRPCNotify(nil, LocalPawn, "DashImpulse2")
end
end
function WB_FightPanel:UpdateDashCooling()
local LocalPawn = UGCSystemLibrary.GetLocalPlayerPawn()
if UE.IsValid(LocalPawn) then
local Energy = LocalPawn.DashImpulseEnergy
local EnergyCost = LocalPawn.DashImpulseEnergyCost
local CanActiveCount = Energy // EnergyCost
local ShowTime = (Energy % EnergyCost) / EnergyCost
if ShowTime == 0 then
ShowTime = 1.
end
local Material = self.Image_Cooling:GetDynamicMaterial();
Material:SetScalarParameterValue("Mask_Percent", ShowTime);
for i = 1, self.HorizontalBox_DashCooling:GetChildrenCount() do
local Item = self.HorizontalBox_DashCooling:GetChildAt(i - 1)
if i <= CanActiveCount then
Item:SetVisibility(ESlateVisibility.Visible)
else
Item:SetVisibility(ESlateVisibility.Collapsed)
end
end
end
end
function WB_FightPanel:NotifyPlayerHook()
local LocalPawn = UGCSystemLibrary.GetLocalPlayerPawn()
if LocalPawn then
local ForwardVector = UGCSystemLibrary.GetLocalPlayerController().PlayerCameraManager:GetActorForwardVector()
UGCSendRPCSystem.ActorRPCNotify(nil, LocalPawn, "HookSkill", VectorHelper.ToLuaTable(ForwardVector), GlobalConfigs.GameSetting.bIsTwoHook)
end
end
function WB_FightPanel:NotifyPlayerStopHook()
local LocalPawn = UGCSystemLibrary.GetLocalPlayerPawn()
if LocalPawn then
UGCSendRPCSystem.ActorRPCNotify(nil, LocalPawn, "StopHookSkill")
end
end
function WB_FightPanel:ChangeHookNum()
GlobalConfigs.GameSetting.bIsTwoHook = not GlobalConfigs.GameSetting.bIsTwoHook
self:UpdateHookNum()
end
function WB_FightPanel:UpdateHookNum()
if GlobalConfigs.GameSetting.bIsTwoHook then
self.WidgetSwitcher_HookNum:SetActiveWidgetIndex(0)
WidgetManager:ShowPanel(WidgetConfig.EUIType.HookTrace, false)
else
self.WidgetSwitcher_HookNum:SetActiveWidgetIndex(1)
WidgetManager:ClosePanel(WidgetConfig.EUIType.HookTrace)
end
end
--function WB_FightPanel:UpdateHookNumText(bIsTwo)
-- if bIsTwo then
-- self.TextBlock_HookNumText:SetText("正启用双钩")
-- else
-- self.TextBlock_HookNumText:SetText("正启用单钩")
-- end
--end
function WB_FightPanel:HidePlayerDeadWidget(DeadPlayer)
if DeadPlayer == UGCSystemLibrary.GetLocalPlayerKey() then
self:SetDeadWidegtVis(false)
end
end
function WB_FightPanel:ShowReSpawnWidget()
self:SetDeadWidegtVis(true)
UGCEventSystem.SetTimer(self, function()
WidgetManager:ShowPanel(WidgetConfig.EUIType.Shop, false)
end, 2.)
end
function WB_FightPanel:SetDeadWidegtVis(bIsShow)
local ShowHide = bIsShow and ESlateVisibility.Visible or ESlateVisibility.Collapsed
for i, v in pairs(self.PlayerDeadHideWidget) do
v:SetVisibility(ShowHide)
end
end
function WB_FightPanel:KeyOwnerChange(OwnerPlayer)
if OwnerPlayer == UGCSystemLibrary.GetLocalPlayerKey() then
self.Button_DiscardsKey:SetVisibility(ESlateVisibility.Visible)
self:PlayAnimation(self.ShowKey, 0, 1, EUMGSequencePlayMode.Forward, 1)
else
self.Button_DiscardsKey:SetVisibility(ESlateVisibility.Collapsed)
end
end
function WB_FightPanel:DiscardsKey()
if self.LastDiscardsKeyTime == nil or UGCSystemLibrary.GetGameTime() - self.LastDiscardsKeyTime > 0.3 then
UGCLogSystem.Log("[WB_FightPanel_DiscardsKey]")
self.LastDiscardsKeyTime = UGCSystemLibrary.GetGameTime()
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "PlayerDiscardsKey", UGCSystemLibrary.GetLocalPlayerKey())
end
end
return WB_FightPanel;