147 lines
6.1 KiB
Lua
147 lines
6.1 KiB
Lua
|
---@class WB_SelectMap_C:UUserWidget
|
||
|
---@field CanvasPanel_Root UCanvasPanel
|
||
|
---@field Image_LogoLeft UImage
|
||
|
---@field Image_LogoRight UImage
|
||
|
---@field Image_TC_Loading_Map UImage
|
||
|
---@field ProgressBar_0 UProgressBar
|
||
|
---@field ScaleBox_IPX UScaleBox
|
||
|
---@field ScrollBox_AttackPoint UScrollBox
|
||
|
---@field ScrollBox_AttackTheBuilding UScrollBox
|
||
|
---@field ScrollBox_ClassicMode UScrollBox
|
||
|
---@field TextBlock_AttackPointName UTextBlock
|
||
|
---@field TextBlock_AttackTheBuildingName UTextBlock
|
||
|
---@field TextBlock_ClassicModeName UTextBlock
|
||
|
---@field TextBlock_Left UTextBlock
|
||
|
---@field TextBlock_MapName UTextBlock
|
||
|
---@field TextBlock_ModeName UTextBlock
|
||
|
---@field TextBlock_Right UTextBlock
|
||
|
---@field TextBlock_Tip UTextBlock
|
||
|
---@field VerticalBox_PlayerSelectedMapInfo UVerticalBox
|
||
|
---@field VerticalBox_TC_Loading_MyTeam UVerticalBox
|
||
|
---@field VerticalBox_TC_Loading_OppoTeam UVerticalBox
|
||
|
---@field WidgetSwitcher_IsLoading UWidgetSwitcher
|
||
|
--Edit Below--
|
||
|
local WB_SelectMap = {
|
||
|
bInitDoOnce = false;
|
||
|
}
|
||
|
function WB_SelectMap:Construct()
|
||
|
self:LuaInit()
|
||
|
end
|
||
|
-- function WB_SelectMap:Tick(MyGeometry, InDeltaTime)
|
||
|
-- end
|
||
|
-- function WB_SelectMap:Destruct()
|
||
|
-- end
|
||
|
function WB_SelectMap:LuaInit()
|
||
|
if self.bInitDoOnce then return end
|
||
|
self.bInitDoOnce = true
|
||
|
-- Bind Event
|
||
|
UGCEventSystem.AddListener(EventEnum.UpdatePlayerSelectedMap, self.UpdatePlayerSelectedMap, self)
|
||
|
UGCEventSystem.AddListener(EventEnum.UpdateMapKey, self.ShowLoading, self)
|
||
|
UGCEventSystem.AddListener(EventEnum.UpdateLockPlayerTeam, self.UpdateTeamPlayers, self)
|
||
|
UGCEventSystem.AddListener(EventEnum.UpdatePlayerInfo, self.UpdatePlayerInfo, self)
|
||
|
-- 初始化一下状态
|
||
|
if UGCGameSystem.GameState:GetMapKey() > 0 then
|
||
|
self.WidgetSwitcher_IsLoading:SetActiveWidgetIndex(1)
|
||
|
else
|
||
|
self.WidgetSwitcher_IsLoading:SetActiveWidgetIndex(0)
|
||
|
end
|
||
|
self.MapGameModeWidgetTable = {
|
||
|
[MapConfig.EModeType.ClassicMode] = {
|
||
|
TextBlock = self.TextBlock_ClassicModeName,
|
||
|
ScrollBox = self.ScrollBox_ClassicMode,
|
||
|
},
|
||
|
[MapConfig.EModeType.AttackPoint] = {
|
||
|
TextBlock = self.TextBlock_AttackPointName,
|
||
|
ScrollBox = self.ScrollBox_AttackPoint,
|
||
|
},
|
||
|
[MapConfig.EModeType.AttackTheBuilding] = {
|
||
|
TextBlock = self.TextBlock_AttackTheBuildingName,
|
||
|
ScrollBox = self.ScrollBox_AttackTheBuilding,
|
||
|
},
|
||
|
}
|
||
|
for i, v in pairs(self.MapGameModeWidgetTable) do
|
||
|
v.TextBlock:SetText(MapConfig.ModeTypeName[i] .. "模式")
|
||
|
end
|
||
|
for i, v in pairs(MapConfig.MapInfo) do
|
||
|
local ModeType = v.ModeType
|
||
|
local Item = UserWidget.NewWidgetObjectBP(UGCSystemLibrary.GetLocalPlayerController(), self:GetMapItemClass());
|
||
|
self.MapGameModeWidgetTable[ModeType].ScrollBox:AddChild(Item)
|
||
|
Item:SetMapIndex(i)
|
||
|
Item:BindClickSelect(self.SelectMap, self)
|
||
|
end
|
||
|
|
||
|
self:UpdatePlayerInfo()
|
||
|
end
|
||
|
function WB_SelectMap:UpdatePlayerInfo()
|
||
|
local AllPlayerKey = table.getKeys(UGCGameSystem.GameState.PlayerPersonalInfos)
|
||
|
UGCLogSystem.LogTree("[WB_SelectMap_UpdatePlayerInfo] AllPlayerKey:", AllPlayerKey)
|
||
|
for i = 1, self.VerticalBox_PlayerSelectedMapInfo:GetChildrenCount() do
|
||
|
local Item = self.VerticalBox_PlayerSelectedMapInfo:GetChildAt(i - 1)
|
||
|
if AllPlayerKey[i] then
|
||
|
Item:SetPlayerKey(AllPlayerKey[i])
|
||
|
Item:SetVisibility(ESlateVisibility.HitTestInvisible)
|
||
|
else
|
||
|
Item:SetVisibility(ESlateVisibility.Collapsed)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
end
|
||
|
function WB_SelectMap:GetMapItemClass()
|
||
|
if not UE.IsValid(self.MapItemClass) then
|
||
|
self.MapItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/StatusUI/GamePreparation/SelectMap/WB_MapItem.WB_MapItem_C'))
|
||
|
end
|
||
|
return self.MapItemClass
|
||
|
end
|
||
|
function WB_SelectMap:SelectMap(MapIndex)
|
||
|
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "PlayerSelectMap", UGCSystemLibrary.GetLocalPlayerKey(), MapIndex)
|
||
|
end
|
||
|
-- 刷新玩家已选的地图
|
||
|
function WB_SelectMap:UpdatePlayerSelectedMap()
|
||
|
local LocalPlayerSelectMap = UGCGameSystem.GameState:GetPlayerSelectedMap(UGCSystemLibrary.GetLocalPlayerKey())
|
||
|
for _, v in pairs(self.MapGameModeWidgetTable) do
|
||
|
for i = 1, v.ScrollBox:GetChildrenCount() do
|
||
|
local Item = v.ScrollBox:GetChildAt(i - 1)
|
||
|
local MapIndex = Item:GetIndex()
|
||
|
Item:SetSelectedPlayer(UGCGameSystem.GameState:GetSelectedMapPlayers(MapIndex))
|
||
|
Item:SetSelect(LocalPlayerSelectMap == MapIndex)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
function WB_SelectMap:ShowLoading(InMapKey)
|
||
|
UGCLogSystem.Log("[WB_SelectMap_ShowLoading] InMapKey:%s", tostring(InMapKey))
|
||
|
if InMapKey <= 0 then return end
|
||
|
self.WidgetSwitcher_IsLoading:SetActiveWidgetIndex(1)
|
||
|
self.ProgressBar_0:SetPercent(0.)
|
||
|
UGCEventSystem.SetTimer(self, function() self.ProgressBar_0:SetPercent(0.25) end, 0.2 * GlobalConfigs.GameSetting.DefaultLoadMapTime)
|
||
|
UGCEventSystem.SetTimer(self, function() self.ProgressBar_0:SetPercent(0.9) end, 0.4 * GlobalConfigs.GameSetting.DefaultLoadMapTime)
|
||
|
UGCEventSystem.SetTimer(self, function() self.ProgressBar_0:SetPercent(1) end, 0.9 * GlobalConfigs.GameSetting.DefaultLoadMapTime)
|
||
|
local MapInfo = MapConfig.MapInfo[InMapKey]
|
||
|
if MapInfo then
|
||
|
self.TextBlock_MapName:SetText(MapInfo.ShowName)
|
||
|
self.TextBlock_ModeName:SetText(MapConfig.ModeTypeName[MapInfo.ModeType] .. "模式")
|
||
|
self.TextBlock_Tip:SetText(MapConfig.ModeTypeTip[MapInfo.ModeType])
|
||
|
end
|
||
|
end
|
||
|
function WB_SelectMap:UpdateTeamPlayers(TeamPlayers)
|
||
|
UGCLogSystem.LogTree("[WB_SelectMap_UpdateTeamPlayers]", TeamPlayers)
|
||
|
local LocalPlayerTeam = (table.hasValue(TeamPlayers[1], UGCSystemLibrary.GetLocalPlayerKey()) and 1 or 2);
|
||
|
local OppoTeamID = ((LocalPlayerTeam == 1) and 2 or 1)
|
||
|
UGCLogSystem.Log("[WB_SelectMap_UpdateTeamPlayers] LocalPlayerTeam:%s, OppoTeamID:%s", tostring(LocalPlayerTeam), tostring(OppoTeamID))
|
||
|
for i = 1, self.VerticalBox_TC_Loading_MyTeam:GetChildrenCount() do
|
||
|
local ItemL = self.VerticalBox_TC_Loading_MyTeam:GetChildAt(i - 1)
|
||
|
local ItemR = self.VerticalBox_TC_Loading_OppoTeam:GetChildAt(i - 1)
|
||
|
if TeamPlayers[LocalPlayerTeam][i] then
|
||
|
ItemL:UpdatePlayerInfo(TeamPlayers[LocalPlayerTeam][i])
|
||
|
ItemL:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
else
|
||
|
ItemL:SetVisibility(ESlateVisibility.Hidden)
|
||
|
end
|
||
|
if TeamPlayers[OppoTeamID][i] then
|
||
|
ItemR:UpdatePlayerInfo(TeamPlayers[OppoTeamID][i])
|
||
|
ItemR:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
||
|
else
|
||
|
ItemR:SetVisibility(ESlateVisibility.Hidden)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return WB_SelectMap
|