UGCProjects/GZJ/Script/UI/ChildWidgets/WBP_SelectSkillItem.lua
2025-01-08 22:46:12 +08:00

60 lines
1.9 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---@class WBP_SelectSkillItem_C:UUserWidget
---@field Button_Main UButton
---@field IconAndBG UWBP_WeaponItemFitting_C
---@field TextBlock_SkillName UTextBlock
---@field SlotNum int32
--Edit Below--
local WBP_SelectSkillItem = {
bInitDoOnce = false;
SkillItemID = 0;
SkillIdToReplace = 0;
ParentWidget = nil;
};
function WBP_SelectSkillItem:Construct()
self.Button_Main.OnClicked:Add(WBP_SelectSkillItem.ClickSkill, self)
end
-- function WBP_SelectSkillItem:Tick(MyGeometry, InDeltaTime)
-- end
function WBP_SelectSkillItem:SetParentWidget(InWidget)
self.ParentWidget = InWidget
end
function WBP_SelectSkillItem:SetSlotNum(InNum)
self.SlotNum = InNum
end
function WBP_SelectSkillItem:Destruct()
self.Button_Main.OnClicked:Remove(WBP_SelectSkillItem.ClickSkill, self)
end
function WBP_SelectSkillItem:ClickSkill()
if self.SkillIdToReplace ~= 0 then
-- 调用 PlayerController 中的方法进行更换
local PC = GameDataManager.GetLocalPlayerController()
print(string.format('[WBP_SelectSkillItem:ClickSkill] 选择Skill%d', self.SkillIdToReplace))
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_GiveSkill", GameDataManager.GetSkillNameById(self.SkillIdToReplace), self.SlotNum, GameDataManager.GetSkillLevelById(self.SkillIdToReplace))
UIManager:ClosePanel(EUIType.UseSkill)
end
end
function WBP_SelectSkillItem:SetReplaceItemId(InId)
-- 检查当前是否有
self.SkillIdToReplace = InId;
end
function WBP_SelectSkillItem:SetLastItemId(InId)
-- 显示出来对应的
-- 找到对应描述和图标
self.SkillItemID = InId
print(string.format('[WBP_SelectSkillItem:SetLastItemId] ItemId = %d', InId))
local ItemInfo = GameDataManager.GetItemInfoByItemID(InId)
self.IconAndBG:SetItemIcon(ItemInfo.Icon)
self.IconAndBG:SetItemBGColor(GetItemQualityLevel(InId))
self.TextBlock_SkillName:SetText(DropItemMap.SkillItemMap[InId].SkillName)
end
return WBP_SelectSkillItem;