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

144 lines
4.3 KiB
Lua
Raw Permalink 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_DifficultInfo_C:UUserWidget
---@field Button_Close UButton
---@field Button_Select UButton
---@field ScrollBox_Texts UScrollBox
---@field TextBlock_Credit UTextBlock
---@field TextBlock_Difficult UTextBlock
---@field TextBlock_Drop1 UTextBlock
---@field TextBlock_Drop2 UTextBlock
---@field TextBlock_Drop3 UTextBlock
---@field TextBlock_Drop4 UTextBlock
---@field TextBlock_Drop5 UTextBlock
---@field TextBlock_GameClearance1 UTextBlock
---@field TextBlock_GameClearance3 UTextBlock
---@field TextBlock_GameClearance5 UTextBlock
---@field WBP_WidgetHeader UWBP_WidgetHeader_C
--Edit Below--
local WBP_DifficultInfo = {
bInitDoOnce = false;
SelectDifficult = 0; -- 选择的难度
SelectWidget = nil;
};
function WBP_DifficultInfo:Construct()
self.WBP_WidgetHeader:Construct()
self.ScrollBox_Texts:SetScrollBarVisibility(ESlateVisibility.Hidden)
--self.WBP_CloseWidget:SetWidgetToClose(self)
self.Button_Select.OnClicked:Add(WBP_DifficultInfo.OnClickSelect, self)
self.Button_Close.OnClicked:Add(WBP_DifficultInfo.OnClickClose, self)
end
-- function WBP_DifficultInfo:Tick(MyGeometry, InDeltaTime)
-- end
function WBP_DifficultInfo:Destruct()
self.Button_Select.OnClicked:Remove(WBP_DifficultInfo.OnClickSelect, self)
self.Button_Close.OnClicked:Remove(WBP_DifficultInfo.OnClickClose, self)
end
function WBP_DifficultInfo:InitFromParam(InNum, InWidget)
self:SetDifficult(InNum, InWidget)
end
function WBP_DifficultInfo:OnClickClose()
UIManager:ClosePanel(EUIType.DifficultInfo)
end
function WBP_DifficultInfo:OnClosePanel()
end
function WBP_DifficultInfo:SetDifficult(InNum, InWidget)
print(string.format('[WBP_DifficultInfo:SetDifficult] 执行设置难度'))
self.SelectDifficult = InNum
self.SelectWidget = InWidget
-- 设置 难度
local Credit = InNum + 10
local GameClearance = ArchiveTable.GameClearanceRewards[InNum]
local TheText = '难度说明 \
奖励:(所有奖励均可在游戏内存档中查询) \
积分:%d \
通关成就:\
1次%s\
3次%s\
5次%s\
掉落:\
属性套装:(以下属性随机获得一条)\
%s\
%s\
%s\
%s\
%s\
随机装备:\
掉落本剧首领的其中一件装备\
武器,盔甲,腿铠,足屐\
\
难度系数:%.02f'
local Func = function(InStr, InVal)
local PercentIndex = string.find(InStr, '%%')
if PercentIndex ~= nil then
InStr = string.gsub(InStr, '%%', '')
end
if math.type(InVal) == 'float' then
return string.format('%s+%.02f%%', InStr, InVal * 100)
else
return InStr .. tostring(InVal)
end
end
local Func1 = function(InVal, InNo)
return Func(InVal[InNo].Type, InVal[InNo].Value)
end
local Func2 = function(InNo)
return Func(ArchiveTable.DropGameItems[ArchiveTable.DropGameItemIndex[InNo]].Type, ArchiveTable.DropGameItems[ArchiveTable.DropGameItemIndex[InNo]].Value)
end
local Val = string.format(
TheText,
Credit,
Func1(GameClearance, 1),
Func1(GameClearance, 3),
Func1(GameClearance, 5),
Func2(1),
Func2(2),
Func2(3),
Func2(4),
Func2(5),
GlobalConfigs.DifficultyMultiplier["Attack"][InNum] + 0.0
)
print(string.format('[WBP_DifficultInfo:SetDifficult] 设置成功'))
--self.TextBlock_Info:SetText(Val)
self.TextBlock_Credit:SetText(string.format('%d', Credit))
self.TextBlock_GameClearance1:SetText(string.format('%s', Func1(GameClearance, 1)))
self.TextBlock_GameClearance3:SetText(string.format('%s', Func1(GameClearance, 3)))
self.TextBlock_GameClearance5:SetText(string.format('%s', Func1(GameClearance, 5)))
self.TextBlock_Drop1:SetText(string.format(' %s', Func2(1)))
self.TextBlock_Drop2:SetText(string.format(' %s', Func2(2)))
self.TextBlock_Drop3:SetText(string.format(' %s', Func2(3)))
self.TextBlock_Drop4:SetText(string.format(' %s', Func2(4)))
self.TextBlock_Drop5:SetText(string.format(' %s', Func2(5)))
self.TextBlock_Difficult:SetText(string.format('%.02f', GlobalConfigs.DifficultyMultiplier["Attack"][InNum] + 0.0))
end
function WBP_DifficultInfo:OnClickSelect()
-- 直接发送过去
-- 先将 Item 设置为 2
print(string.format('[WBP_DifficultInfo:OnClickSelect] 执行'))
if self.SelectWidget ~= nil then
self.SelectWidget:SetVisualType(2)
end
-- 设置 Click
UIManager:GetPanel(EUIType.SelectDifficulty):SetCurrentDifficulty(self.SelectDifficult)
UIManager:HidePanel(EUIType.DifficultInfo)
end
return WBP_DifficultInfo;