121 lines
3.0 KiB
Lua
121 lines
3.0 KiB
Lua
|
---@class WBP_Unpacking_C:UUserWidget
|
||
|
---@field ShowUnpacking UWidgetAnimation
|
||
|
---@field CanvasPanel_UnpackingItems UCanvasPanel
|
||
|
---@field Image_Alert UImage
|
||
|
---@field TextBlock_CoinPoint UTextBlock
|
||
|
---@field WBP_Unpacking_Item_C_1 UWBP_Unpacking_Item_C
|
||
|
---@field WBP_Unpacking_Item_C_2 UWBP_Unpacking_Item_C
|
||
|
---@field WBP_Unpacking_Item_C_3 UWBP_Unpacking_Item_C
|
||
|
---@field WBP_WidgetHeader UWBP_WidgetHeader_C
|
||
|
--Edit Below--
|
||
|
local WBP_Unpacking = {
|
||
|
bInitDoOnce = false;
|
||
|
UnpackingInsts = nil;
|
||
|
UpdateTipHandle = nil;
|
||
|
|
||
|
-- 当前拥有的 Money
|
||
|
CurrentCoinPoint = 0;
|
||
|
};
|
||
|
|
||
|
-- define a queue class
|
||
|
local Queue = {}
|
||
|
|
||
|
function Queue:new()
|
||
|
local queue = {first = 0, last = -1}
|
||
|
setmetatable(queue, self)
|
||
|
self.__index = self
|
||
|
return queue
|
||
|
end
|
||
|
|
||
|
function Queue:push(value)
|
||
|
local last = self.last + 1
|
||
|
self.last = last
|
||
|
self[last] = value
|
||
|
end
|
||
|
|
||
|
function Queue:pop()
|
||
|
local first = self.first
|
||
|
if first > self.last then
|
||
|
error("queue is empty")
|
||
|
end
|
||
|
local value = self[first]
|
||
|
self[first] = nil
|
||
|
self.first = first + 1
|
||
|
return value
|
||
|
end
|
||
|
|
||
|
function Queue:getCount()
|
||
|
return self.last - self.first
|
||
|
end
|
||
|
|
||
|
function Queue:isEmpty()
|
||
|
return self.first > self.last
|
||
|
end
|
||
|
|
||
|
-- test the queue class
|
||
|
|
||
|
function WBP_Unpacking:Construct()
|
||
|
self.WBP_WidgetHeader.UIType = EUIType.Unpacking
|
||
|
self.WBP_WidgetHeader:Construct()
|
||
|
EventSystem:AddListener(EventType.UnpackingResult, self.UnpackingResult, self)
|
||
|
EventSystem:AddListener(EventType.PlayerCoinPointChanged, self.OnCoinPointChanged, self)
|
||
|
|
||
|
-- 先隐藏
|
||
|
self:SetAlert(false)
|
||
|
end
|
||
|
|
||
|
function WBP_Unpacking:OnShowPanel()
|
||
|
NewPlayerGuideManager:RemoveGuide(11)
|
||
|
end
|
||
|
|
||
|
-- function WBP_Unpacking:Destruct()
|
||
|
|
||
|
-- end
|
||
|
|
||
|
function WBP_Unpacking:SetAlert(IsShow)
|
||
|
if IsShow then
|
||
|
self.Image_Alert:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
-- 关闭警告
|
||
|
EventSystem.SetTimer(self, function()
|
||
|
self:SetAlert(false)
|
||
|
end, 2.5)
|
||
|
else
|
||
|
self.Image_Alert:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WBP_Unpacking:UnpackingResult(PlayerKey, Results)
|
||
|
local PCPlayerKey = UGCPawnAttrSystem.GetPlayerKeyInt64(STExtraGameplayStatics.GetFirstPlayerController(self).Pawn)
|
||
|
if PCPlayerKey == PlayerKey then
|
||
|
if self.UnpackingInsts == nil then
|
||
|
self.UnpackingInsts = Queue:new()
|
||
|
end
|
||
|
for k, v in pairs(Results) do
|
||
|
self.UnpackingInsts:push(v)
|
||
|
print("UnpackingResult_".."UnpackingInsts:push(v):" .. type(v))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if self.UpdateTipHandle == nil then
|
||
|
for i = 1, self.UnpackingInsts:getCount() do
|
||
|
local TargetUnpackingInst = self.UnpackingInsts:pop()
|
||
|
|
||
|
local NoticeData = {
|
||
|
Text = TargetUnpackingInst.Name,
|
||
|
Color = Tables.ItemRarityColor[TargetUnpackingInst.UnpackingLevel - 1].LinearColor,
|
||
|
}
|
||
|
NoticeTipsTools.ClientNoticeTips(ECustomNoticeType.RollingNotice, NoticeData, ERollingNoticeType.Gain)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function WBP_Unpacking:OnCoinPointChanged(InNum)
|
||
|
if InNum ~= nil and type(InNum) == "number" then
|
||
|
if InNum > 0.0 and InNum < 1.0 then
|
||
|
InNum = 0
|
||
|
end
|
||
|
self.TextBlock_CoinPoint:SetText(string.format('%d', InNum))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return WBP_Unpacking;
|