111 lines
3.7 KiB
Lua
111 lines
3.7 KiB
Lua
---@class WBP_SelectSkill_C:UUserWidget
|
|
---@field CanvasPanel_Skill UCanvasPanel
|
|
---@field CanvasPanel_SkillBox UCanvasPanel
|
|
---@field HorizontalBox_RemainTime UHorizontalBox
|
|
---@field Panel_BG UWBP_WidgetHeader_C
|
|
---@field ScrollBox_Items UScrollBox
|
|
---@field Skill_Category_1 UWBP_SelectSkillButton_C
|
|
---@field Skill_Category_2 UWBP_SelectSkillButton_C
|
|
---@field Skill_Category_3 UWBP_SelectSkillButton_C
|
|
---@field TextBlock_RemainTime UTextBlock
|
|
---@field TextBlock_SelectSkillTip UTextBlock
|
|
--Edit Below--
|
|
local WBP_SelectSkill = {
|
|
bInitDoOnce = false,
|
|
SkillItemPanelSizeX = 120,
|
|
SkillItemClass = nil,
|
|
SkillItems = {},
|
|
WidgetPool = {}; --容器池
|
|
HadShow = false; -- 是否显示过
|
|
}
|
|
|
|
function WBP_SelectSkill:Construct()
|
|
self.Panel_BG:Construct()
|
|
WBP_SelectSkill.SuperClass.Construct(self)
|
|
|
|
self.SkillCategoryButtons = {
|
|
[GlobalConfigs.ETalentType.Damage] = self.Skill_Category_1,
|
|
[GlobalConfigs.ETalentType.Function] = self.Skill_Category_2,
|
|
[GlobalConfigs.ETalentType.Survival] = self.Skill_Category_3,
|
|
}
|
|
|
|
-- 初始化容器池
|
|
self:InitPool(5)
|
|
self:SelectSkillType('伤害')
|
|
|
|
self:OnGameReadyStageRemainTimeChange(UGCGameSystem.GameState.GameReadyStageRemainTime)
|
|
EventSystem:AddListener(EventType.OnGameReadyStageRemainTimeChanged, WBP_SelectSkill.OnGameReadyStageRemainTimeChange, self)
|
|
|
|
self.ScrollBox_Items:SetScrollBarVisibility(ESlateVisibility.Collapsed)
|
|
end
|
|
|
|
function WBP_SelectSkill:Destruct()
|
|
EventSystem:RemoveListener(EventType.OnGameReadyStageRemainTimeChanged, WBP_SelectSkill.OnGameReadyStageRemainTimeChange, self)
|
|
WBP_SelectSkill.SuperClass.Destruct(self)
|
|
end
|
|
|
|
function WBP_SelectSkill:OnShowPanel(...)
|
|
self.HadShow = true;
|
|
end
|
|
|
|
function WBP_SelectSkill:InitPool(InSize)
|
|
local ItemWidgetClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/WBP_Skill_Item.WBP_Skill_Item_C'))
|
|
self.WidgetPool = {}
|
|
for i = 1, InSize do
|
|
local Widget = UserWidget.NewWidgetObjectBP(UGCGameSystem.GameState, ItemWidgetClass)
|
|
local ItemData = {
|
|
IsUsed = false,
|
|
Widget = Widget,
|
|
}
|
|
table.insert(self.WidgetPool, ItemData)
|
|
end
|
|
end
|
|
|
|
function WBP_SelectSkill:OnGameReadyStageRemainTimeChange(RemainTime)
|
|
if RemainTime <= 0 then
|
|
self.HorizontalBox_RemainTime:SetVisibility(ESlateVisibility.Collapsed)
|
|
else
|
|
self.HorizontalBox_RemainTime:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
self.TextBlock_RemainTime:SetText(tostring(RemainTime))
|
|
end
|
|
end
|
|
|
|
function WBP_SelectSkill:OnSelectionChanged()
|
|
self.TextBlock_SelectSkillTip:SetText("请等待其他玩家选择")
|
|
self.CanvasPanel_Skill:SetVisibility(ESlateVisibility.Collapsed)
|
|
|
|
NewPlayerGuideManager:RemoveGuide(3)
|
|
end
|
|
|
|
function WBP_SelectSkill:SelectSkillType(InText)
|
|
for Name, Btn in pairs(self.SkillCategoryButtons) do
|
|
if Name == InText then
|
|
Btn:SetIsSelected(true)
|
|
else
|
|
Btn:SetIsSelected(false)
|
|
end
|
|
end
|
|
-- 找到
|
|
local ItemNames = {}
|
|
self.ScrollBox_Items:ClearChildren()
|
|
for k, v in pairs(GlobalConfigs.SkillTalent) do
|
|
if v.Talent == InText then
|
|
table.insert(ItemNames, k)
|
|
end
|
|
end
|
|
|
|
for i = 1, #ItemNames do
|
|
-- 从池中取出一个
|
|
local Item = self.WidgetPool[i]
|
|
Item.IsUsed = true
|
|
self.ScrollBox_Items:AddChild(Item.Widget)
|
|
Item.Widget:Init(ESkillAccessType.Talented, ItemNames[i])
|
|
end
|
|
end
|
|
|
|
function WBP_SelectSkill:SetSelectItem(InName)
|
|
self.CanvasPanel_Skill:SetVisibility(ESlateVisibility.Collapsed)
|
|
UIManager:ShowGeneralNotice(string.format('已选择 '.. GlobalConfigs.SkillInfo[InName].Name))
|
|
end
|
|
|
|
return WBP_SelectSkill; |