78 lines
2.7 KiB
Lua
78 lines
2.7 KiB
Lua
---@class WB_RandomSelectPlayerVoteMap_C:UUserWidget
|
|
---@field HorizontalBox_MapInfoItems UHorizontalBox
|
|
--Edit Below--
|
|
---@type WB_RandomSelectPlayerVoteMap_C
|
|
local WB_RandomSelectPlayerVoteMap = {
|
|
bInitDoOnce = false;
|
|
CycleNum = 0;
|
|
MaxCycleNum = 1;
|
|
SwitchWaitTime = 0.2;
|
|
-- 已选择时在其停留的闪烁次数
|
|
SelectedLoopNum = 3;
|
|
LastSelectIndex = 0;
|
|
};
|
|
|
|
--[==[ Construct
|
|
function WB_RandomSelectPlayerVoteMap:Construct()
|
|
|
|
end
|
|
-- Construct ]==]
|
|
|
|
-- function WB_RandomSelectPlayerVoteMap:Tick(MyGeometry, InDeltaTime)
|
|
|
|
-- end
|
|
|
|
-- function WB_RandomSelectPlayerVoteMap:Destruct()
|
|
|
|
-- end
|
|
|
|
function WB_RandomSelectPlayerVoteMap:ShowVoteRandomMap(MapList, InTargetIndex, InLifeTime)
|
|
self.SelectMapNum = #MapList
|
|
if self.SelectMapNum <= 1 then
|
|
return
|
|
end
|
|
self.TargetIndex = InTargetIndex
|
|
self.LifeTime = InLifeTime
|
|
for i = 1, self.HorizontalBox_MapInfoItems:GetChildrenCount() do
|
|
local Item = self.HorizontalBox_MapInfoItems:GetChildAt(i - 1)
|
|
if i > #MapList then
|
|
Item:SetVisibility(ESlateVisibility.Collapsed)
|
|
else
|
|
Item:InitSelectItem(MapList[i])
|
|
end
|
|
end
|
|
local TempMaxCycleNum = (self.LifeTime / self.SwitchWaitTime - self.TargetIndex - self.SelectedLoopNum * 2) / self.SelectMapNum
|
|
self.MaxCycleNum = math.floor(TempMaxCycleNum)
|
|
self.StartRollTime = UGCSystemLibrary.GetGameTime()
|
|
UGCLogSystem.Log("[WB_RandomSelectPlayerVoteMap_ShowVoteRandomMap] MaxCycleNum:%s, TargetIndex:%s", tostring(self.MaxCycleNum), tostring(self.TargetIndex))
|
|
self.RollSelectItemHandle = UGCEventSystem.SetTimerLoop(self, self.RollSelectItem, self.SwitchWaitTime)
|
|
end
|
|
|
|
function WB_RandomSelectPlayerVoteMap:RollSelectItem()
|
|
UGCLogSystem.Log("[WB_RandomSelectPlayerVoteMap_RollSelectItem]")
|
|
local LastItem = self.HorizontalBox_MapInfoItems:GetChildAt(self.LastSelectIndex)
|
|
if self.LastSelectIndex == self.TargetIndex - 1 and self.CycleNum == self.MaxCycleNum then
|
|
LastItem:SetSelect(not LastItem:GetIsSelect())
|
|
else
|
|
LastItem:SetSelect(false)
|
|
if self.LastSelectIndex + 1 >= self.SelectMapNum then
|
|
self.CycleNum = self.CycleNum + 1
|
|
end
|
|
self.LastSelectIndex = (self.LastSelectIndex + 1) % self.SelectMapNum
|
|
local Item = self.HorizontalBox_MapInfoItems:GetChildAt(self.LastSelectIndex)
|
|
Item:SetSelect(true)
|
|
end
|
|
|
|
if UGCSystemLibrary.GetGameTime() - self.StartRollTime >= self.LifeTime then
|
|
self:StopLoop()
|
|
end
|
|
end
|
|
|
|
function WB_RandomSelectPlayerVoteMap:StopLoop()
|
|
if self.RollSelectItemHandle then
|
|
UGCEventSystem.StopTimer(self.RollSelectItemHandle)
|
|
self.RollSelectItemHandle = nil
|
|
end
|
|
end
|
|
|
|
return WB_RandomSelectPlayerVoteMap; |