UGCProjects/GZJ/Script/UI/ChildWidgets/WBP_SkillSelectButton.lua

40 lines
1.2 KiB
Lua
Raw Normal View History

2025-01-08 22:46:12 +08:00
---@class WBP_SkillSelectButton_C:UUserWidget
---@field Button_UseSkill UButton
---@field Image_0 UImage
--Edit Below--
local WBP_SkillSelectButton = {
bInitDoOnce = false;
SkillId = 0;
};
function WBP_SkillSelectButton:Construct()
self.Button_UseSkill.OnClicked:Add(WBP_SkillSelectButton.OnClickUseSkill, self)
end
-- function WBP_SkillSelectButton:Tick(MyGeometry, InDeltaTime)
-- end
function WBP_SkillSelectButton:Destruct()
self.Button_UseSkill.OnClicked:Remove(WBP_SkillSelectButton.OnClickUseSkill, self)
end
-- 直接在空插槽处应用技能
function WBP_SkillSelectButton:OnClickUseSkill()
print(string.format('[WBP_SkillSelectButton:OnClickUseSkill] 使用技能:%d', self.SkillId))
local PC = GameDataManager.GetLocalPlayerController()
local SkillName = GameDataManager.GetSkillNameById(self.SkillId)
local SkillLevel = GameDataManager.GetSkillLevelById(self.SkillId)
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_GiveSkill", SkillName, PC:GetNearEmptySlot(), SkillLevel)
-- 关闭 UI
UIManager:ClosePanel(EUIType.UseSkill)
end
function WBP_SkillSelectButton:SetSkillId(InId)
print(string.format('[WBP_SkillSelectButton:SetSkillId] 设置技能ID = %d', InId))
self.SkillId = InId
end
return WBP_SkillSelectButton;