167 lines
7.4 KiB
Lua
167 lines
7.4 KiB
Lua
---@class W_GamePreparation_AtheticMasters_C:UUserWidget
|
|
---@field TextBlock_WaitTime UTextBlock
|
|
--Edit Below--
|
|
---@type W_GamePreparation_AtheticMasters_C
|
|
local W_GamePreparation_AtheticMasters = {
|
|
bInitDoOnce = false;
|
|
bSelected = false;
|
|
SelectMapType = -1;
|
|
bLoading = false;
|
|
};
|
|
|
|
|
|
function W_GamePreparation_AtheticMasters:Construct()
|
|
self.TextBlock_WaitTime:BindingProperty("Text", self.TextBlock_WaitTime_Text, self)
|
|
--UGCEventSystem.AddListener(EventEnum.GameWillBegin, self.GameWillBegin, self)
|
|
--UGCEventSystem.AddListener(EventEnum.LoadMap, self.LoadingMap, self)
|
|
UGCEventSystem.AddListener(EventEnum.GameStateChange, self.RemoveSelf, self)
|
|
--UGCEventSystem.AddListener(EventEnum.RandomSelectVoteMap, self.RandomSelectVoteMap, self)
|
|
--
|
|
--WidgetLibrary.BindButtonClicked(self.Button_Select, self.ClickSelectMap, self)
|
|
--self:AddMapSelectItem()
|
|
--self:AddWeaponSelectItem()
|
|
--self:SelectMapCallBack(MapConfig.MapType.Level1)
|
|
--local LoadMapType = UGCGameSystem.GameState:GetMapSelectionResult(false)
|
|
--if LoadMapType ~= nil then
|
|
-- self:LoadingMap(LoadMapType)
|
|
--end
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:OnClosePanel()
|
|
UGCLogSystem.Log("[W_GamePreparation_AtheticMasters_OnClosePanel]")
|
|
self.bLoading = false
|
|
WidgetManager:DestroyPanel(WidgetConfig.EUIType.WaitingTime)
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:RemoveSelf(NewGameState)
|
|
if NewGameState ~= CustomEnum.EGameState.Waiting and UE.IsValid(self) then
|
|
-- UGCEventSystem.SetTimer(self, self.OnClosePanel, GlobalConfigs.GameSetting.ClientLoadMapTime)
|
|
self:OnClosePanel()
|
|
UGCLogSystem.Log("[W_GamePreparation_AtheticMasters_RemoveSelf]")
|
|
end
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:TextBlock_WaitTime_Text(ReturnValue)
|
|
return tostring(UGCGameSystem.GameState.WaitPlayerJoinTime)
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:GameWillBegin()
|
|
UGCLogSystem.Log("[W_GamePreparation_AtheticMasters_GameWillBegin]")
|
|
UGCEventSystem.SendEvent(EventEnum.AddTip, TipConfig.TipType.GameWillStart)
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:AddWeaponSelectItem()
|
|
for i, TempWeaponID in pairs(WeaponGradientTable.DefaultWeapon) do
|
|
local WeaponSelectItem = UserWidget.NewWidgetObjectBP(UGCSystemLibrary.GetLocalPlayerController(), self:GetWeaponItemClass())
|
|
self.ScrollBox_DefaultWeapon:AddChild(WeaponSelectItem)
|
|
WeaponSelectItem:InitDefaultWeapon(TempWeaponID, self, self.SelectWeaponCallBack)
|
|
if i == 1 then
|
|
self.WeaponID = TempWeaponID
|
|
WeaponSelectItem:SetSelect(true)
|
|
else
|
|
WeaponSelectItem:SetSelect(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:AddMapSelectItem()
|
|
for i, v in pairs(MapConfig.GetMultiModeMapInfo()) do
|
|
local MapSelectItem = UserWidget.NewWidgetObjectBP(UGCSystemLibrary.GetLocalPlayerController(), self:GetMapItemClass())
|
|
self.ScrollBox_SelectMapBox:AddChild(MapSelectItem)
|
|
MapSelectItem:InitSelectItem(i, self, self.SelectMapCallBack)
|
|
--local ItemHorizontalBoxSlot = WidgetLayoutLibrary.SlotAsHorizontalBoxSlot(MapSelectItem)
|
|
--ItemHorizontalBoxSlot:SetSize({Value = 1.0, SizeRule = ESlateSizeRule.Fill})
|
|
|
|
if v.Icon then
|
|
UGCSystemLibrary.LoadAsset(v.Icon, true)
|
|
end
|
|
if v.IconSelect then
|
|
UGCSystemLibrary.LoadAsset(v.IconSelect, true)
|
|
end
|
|
end
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:GetMapItemClass()
|
|
if self.ItemClass == nil then
|
|
self.ItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/StatusUI/GamePreparation/W_SelectMapItem.W_SelectMapItem_C'))
|
|
end
|
|
return self.ItemClass
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:GetWeaponItemClass()
|
|
if self.WeaponItemClass == nil then
|
|
self.WeaponItemClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/StatusUI/GamePreparation/WB_SelectDefaultWeapon.WB_SelectDefaultWeapon_C'))
|
|
end
|
|
return self.WeaponItemClass
|
|
end
|
|
|
|
|
|
function W_GamePreparation_AtheticMasters:SelectMapCallBack(InSelectMapType)
|
|
self.SelectMapType = InSelectMapType
|
|
for i = 0, self.ScrollBox_SelectMapBox:GetChildrenCount() - 1 do
|
|
local SelectMapItem = self.ScrollBox_SelectMapBox:GetChildAt(i)
|
|
SelectMapItem:SetSelect(self.SelectMapType == SelectMapItem:GetSelectMapType())
|
|
end
|
|
self:SetMapSelect(self.SelectMapType)
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:SelectWeaponCallBack(InWeaponID)
|
|
self.WeaponID = InWeaponID
|
|
UGCLogSystem.Log("[W_GamePreparation_AtheticMasters_SelectWeaponCallBack] InWeaponID:%s", tostring(InWeaponID))
|
|
for i = 0, self.ScrollBox_DefaultWeapon:GetChildrenCount() - 1 do
|
|
local SelectWeaponItem = self.ScrollBox_DefaultWeapon:GetChildAt(i)
|
|
SelectWeaponItem:SetSelect(self.WeaponID == SelectWeaponItem:GetWeaponID())
|
|
end
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:ClickSelectMap()
|
|
if (not self.bSelected) and table.hasValue(MapConfig.MapType, self.SelectMapType) and MapConfig.GetMultiModeMapEnable()[self.SelectMapType] then
|
|
-- self.TextBlock_MapShowName:SetText(MapConfig.GetMultiModeMapInfo()[self.SelectMapType].ShowName)
|
|
self.bSelected = true
|
|
self.WidgetSwitcher_SelectFinish:SetActiveWidgetIndex(1)
|
|
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "PlayerSelectMap", UGCSystemLibrary.GetLocalPlayerKey(), self.SelectMapType)
|
|
UGCSendRPCSystem.ActorRPCNotify(nil, UGCGameSystem.GameState, "PlayerSelectDefaultWeapon", UGCSystemLibrary.GetLocalPlayerKey(), self.WeaponID)
|
|
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
|
|
UGCLogSystem.Log("[W_GamePreparation_AtheticMasters_ClickSelectMap] Finish")
|
|
end
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:LoadingMap(LoadMapType)
|
|
self.WB_RandomSelectPlayerVoteMap:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.CanvasPanel_Select:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.VerticalBox_Loading:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
self.bLoading = true
|
|
self:SetMapSelect(LoadMapType)
|
|
UGCGameSystem.GameState:LoadNowMiniMap()
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:SetMapSelect(SelectMapType)
|
|
UGCLogSystem.Log("[W_GamePreparation_AtheticMasters_SetMapSelect] SelectMapType:%s", tostring(SelectMapType))
|
|
if SelectMapType == MapConfig.MapType.Random then
|
|
self.WidgetSwitcher_MapBG:SetActiveWidgetIndex(1)
|
|
else
|
|
self.WidgetSwitcher_MapBG:SetActiveWidgetIndex(0)
|
|
self.Image_MapBG:SetBrushFromTexture(UGCSystemLibrary.LoadAsset(MapConfig.GetMultiModeMapInfo()[SelectMapType].Icon, true))
|
|
end
|
|
self:SetShowName(SelectMapType)
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:SetShowName(SelectMapType)
|
|
local MapName = MapConfig.GetMultiModeMapInfo()[SelectMapType].ShowName
|
|
local ModeName = MapConfig.SpecialModeName[MapConfig.GetMultiModeMapInfo()[SelectMapType].SpecialModeType]
|
|
if ModeName and ModeName ~= "" then
|
|
MapName = string.format("%s - ( %s )", MapName, ModeName)
|
|
end
|
|
self.TextBlock_MapShowName:SetText(MapName)
|
|
end
|
|
|
|
function W_GamePreparation_AtheticMasters:RandomSelectVoteMap(MapList, InTargetIndex)
|
|
self.WB_RandomSelectPlayerVoteMap:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
self.WB_RandomSelectPlayerVoteMap:ShowVoteRandomMap(MapList, InTargetIndex, GlobalConfigs.GameSetting.RollMapTime)
|
|
end
|
|
|
|
-- function W_GamePreparation_AtheticMasters:Destruct()
|
|
|
|
-- end
|
|
|
|
return W_GamePreparation_AtheticMasters; |