416 lines
16 KiB
Lua
416 lines
16 KiB
Lua
---@class WBP_MainUI_C:UUserWidget
|
|
---@field Button_Attribute UNewButton
|
|
---@field Button_Guide UNewButton
|
|
---@field Button_Save UNewButton
|
|
---@field Button_WeaponAttribute UNewButton
|
|
---@field CanvasPanel_16 UCanvasPanel
|
|
---@field CanvasPanel_BossInfo UCanvasPanel
|
|
---@field CanvasPanel_Breach UCanvasPanel
|
|
---@field CanvasPanel_InteractButtons UCanvasPanel
|
|
---@field CanvasPanel_RemainTime_ReadyState UCanvasPanel
|
|
---@field InteractButton_Backpack UWBP_InteractButton_C
|
|
---@field InteractButton_BossInfo UWBP_InteractButton_C
|
|
---@field InteractButton_Breach UWBP_InteractButton_C
|
|
---@field InteractButton_Challenge UWBP_InteractButton_C
|
|
---@field InteractButton_Pickup UWBP_InteractButton_C
|
|
---@field InteractButton_SelectBoss UWBP_InteractButton_C
|
|
---@field InteractButton_Technology UWBP_InteractButton_C
|
|
---@field InteractButton_Unpacking UWBP_InteractButton_C
|
|
---@field Panel_Guide UCanvasPanel
|
|
---@field Panel_Team UWBP_TeamPanel_C
|
|
---@field TextBlock_AttackValue UTextBlock
|
|
---@field TextBlock_Difficult UTextBlock
|
|
---@field TextBlock_GameTime UTextBlock
|
|
---@field TextBlock_Level UTextBlock
|
|
---@field TextBlock_ReadyStateRemainTime UTextBlock
|
|
---@field WBP_PlayerInfo UWBP_PlayerInfo_C
|
|
---@field WBP_WeaponInfo UWBP_WeaponInfo_C
|
|
--Edit Below--
|
|
local WBP_MainUI = {
|
|
bInitDoOnce = false,
|
|
};
|
|
|
|
WBP_MainUI.bStartTiming = false;
|
|
WBP_MainUI.Timing = 0.
|
|
|
|
function WBP_MainUI:Construct()
|
|
WBP_MainUI.SuperClass.Construct(self)
|
|
self:InitUI()
|
|
self:BindEvents()
|
|
self:RegisterEvents()
|
|
end
|
|
|
|
function WBP_MainUI:Destruct()
|
|
self:UnRegisterEvents()
|
|
self:UnBindEvents()
|
|
WBP_MainUI.SuperClass.Destruct(self)
|
|
end
|
|
|
|
function WBP_MainUI:InitUI()
|
|
local GameState = UGCGameSystem.GameState
|
|
if not UE.IsValid(GameState) then
|
|
return
|
|
end
|
|
self:OnGameStageChange(GameState.GameStage)
|
|
self:OnWaitPlayerJoinTimeChange(GameState.WaitPlayerJoinTime)
|
|
|
|
local LocalPlayerState = GameDataManager.GetLocalPlayerState()
|
|
self.PlayerKey = LocalPlayerState.PlayerKey
|
|
self:OnToggleBreachButton(LocalPlayerState:GetNeedShowBreachButton(), self.PlayerKey)
|
|
|
|
self:OnPlayerLevelChange(UGCGameSystem.GameState:GetAllPlayerLevel())
|
|
self:SetUserFocus(GameDataManager.GetLocalPlayerController())
|
|
if LocalPlayerState.Attributes[AttributeType.Base] and LocalPlayerState.Attributes[AttributeType.Base].Base_Attack then
|
|
self:OnBaseAttackChanged(self.PlayerKey, LocalPlayerState.Attributes[AttributeType.Base].Base_Attack)
|
|
end
|
|
|
|
self.InteractButton_SelectBoss.Button_Trigger.OnClicked:Add(WBP_MainUI.OnClickSelectBoss, self);
|
|
self.InteractButton_Backpack.Button_Trigger.OnClicked:Add(WBP_MainUI.OnClickBackpack, self);
|
|
self.InteractButton_Pickup.Button_Trigger.OnClicked:Add(WBP_MainUI.OnClickPickup, self);
|
|
self.InteractButton_Technology.Button_Trigger.OnClicked:Add(WBP_MainUI.OnClickTechnology, self);
|
|
self.InteractButton_Unpacking.Button_Trigger.OnClicked:Add(WBP_MainUI.OnClickUnpacking, self);
|
|
self.InteractButton_Challenge.Button_Trigger.OnClicked:Add(WBP_MainUI.OnClickChallenge, self);
|
|
self.InteractButton_BossInfo.Button_Trigger.OnClicked:Add(WBP_MainUI.OnClickBossInfo, self);
|
|
self.InteractButton_Breach.Button_Trigger.OnClicked:Add(WBP_MainUI.OnClickBreach, self);
|
|
self.Button_WeaponAttribute.OnClicked:Add(WBP_MainUI.OnClickWeaponAttribute, self)
|
|
self.Button_Save.OnClicked:Add(WBP_MainUI.OnClickSave, self)
|
|
self.Button_Attribute.OnClicked:Add(WBP_MainUI.OnAttributeClicked, self)
|
|
|
|
self.HasTriggeredGuideChallenge = false
|
|
self.HasTriggeredGuideUnpacking = false
|
|
self.HasTriggeredGuideTechnology = false
|
|
end
|
|
|
|
function WBP_MainUI:RegisterEvents()
|
|
self.Button_Guide.OnClicked:Add(WBP_MainUI.OnGuideClicked, self)
|
|
EventSystem:AddListener(EventType.OnWaitPlayerJoinTimeChanged, WBP_MainUI.OnWaitPlayerJoinTimeChange, self)
|
|
EventSystem:AddListener(EventType.OnGameStageChanged, WBP_MainUI.OnGameStageChange, self)
|
|
EventSystem:AddListener(EventType.ToggleBreachButton, WBP_MainUI.OnToggleBreachButton, self)
|
|
EventSystem:AddListener(EventType.OnPlayerBaseAttackValueChanged, WBP_MainUI.OnBaseAttackChanged, self)
|
|
EventSystem:AddListener(EventType.PlayerCoinPointChanged, WBP_MainUI.OnPlayerCoinPointChanged, self)
|
|
EventSystem:AddListener(EventType.PlayerKillPointChanged, WBP_MainUI.OnPlayerKillPointChanged, self)
|
|
EventSystem:AddListener(EventType.OnPlayerLevelChanged, WBP_MainUI.OnPlayerLevelChange, self)
|
|
EventSystem:AddListener(EventType.OnPlayerCombatPointChanged, WBP_MainUI.OnPlayerCombatPointChanged, self)
|
|
EventSystem:AddListener(EventType.OnGameDurationChanged, WBP_MainUI.OnGameDurationChanged, self)
|
|
end
|
|
|
|
function WBP_MainUI:UnRegisterEvents()
|
|
self.Button_Guide.OnClicked:Remove(WBP_MainUI.OnGuideClicked, self)
|
|
EventSystem:RemoveListener(EventType.OnWaitPlayerJoinTimeChanged, WBP_MainUI.OnWaitPlayerJoinTimeChange, self)
|
|
EventSystem:RemoveListener(EventType.OnGameStageChanged, WBP_MainUI.OnGameStageChange, self)
|
|
EventSystem:RemoveListener(EventType.ToggleBreachButton, WBP_MainUI.OnToggleBreachButton, self)
|
|
EventSystem:RemoveListener(EventType.OnPlayerBaseAttackValueChanged, WBP_MainUI.OnBaseAttackChanged, self)
|
|
EventSystem:RemoveListener(EventType.PlayerCoinPointChanged, WBP_MainUI.OnPlayerCoinPointChanged, self)
|
|
EventSystem:RemoveListener(EventType.PlayerKillPointChanged, WBP_MainUI.OnPlayerKillPointChanged, self)
|
|
EventSystem:RemoveListener(EventType.OnPlayerLevelChanged, WBP_MainUI.OnPlayerLevelChange, self)
|
|
EventSystem:RemoveListener(EventType.OnPlayerCombatPointChanged, WBP_MainUI.OnPlayerCombatPointChanged, self)
|
|
EventSystem:RemoveListener(EventType.OnGameDurationChanged, WBP_MainUI.OnGameDurationChanged, self)
|
|
end
|
|
|
|
function WBP_MainUI:BindEvents()
|
|
end
|
|
|
|
function WBP_MainUI:UnBindEvents()
|
|
end
|
|
|
|
function WBP_MainUI:OnWaitPlayerJoinTimeChange(RemainTime)
|
|
if RemainTime > 0 and UGCGameSystem.GameState.GameStage == EGameStage.WaitForPlayer then
|
|
self.CanvasPanel_RemainTime_ReadyState:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
self.TextBlock_ReadyStateRemainTime:SetText(tostring(RemainTime))
|
|
else
|
|
self.CanvasPanel_RemainTime_ReadyState:SetVisibility(ESlateVisibility.Collapsed)
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnGameDurationChanged(GameDuration)
|
|
if self.bStartTiming then
|
|
local Minute = math.floor(GameDuration) // 60
|
|
local Second = math.floor(GameDuration) % 60
|
|
self.TextBlock_GameTime:SetText(string.format('游戏时长:%02d:%02d', Minute, Second))
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnGameStageChange(InGameStage)
|
|
-- 表示启动练功房
|
|
if InGameStage == EGameStage.GameFight then
|
|
-- UIManager:ShowPanel(EUIType.GM)
|
|
|
|
UIManager:ClosePanel(EUIType.SelectDifficulty)
|
|
UIManager:ClosePanel(EUIType.SelectSkill)
|
|
local GameDifficulty = UGCGameSystem.GameState.GameDifficulty
|
|
self.TextBlock_Difficult:SetText(string.format('难度:难%d', GameDifficulty))
|
|
self.CanvasPanel_InteractButtons:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
|
|
-- 设置强引导时的外观
|
|
self:SetupForceGuideOutfit()
|
|
|
|
-- 启动游戏时长
|
|
self.bStartTiming = true;
|
|
self:OnGameDurationChanged(UGCGameSystem.GameState.GameDuration)
|
|
else
|
|
self.CanvasPanel_InteractButtons:SetVisibility(ESlateVisibility.Collapsed)
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnAttributeClicked()
|
|
if UIManager:IsVisiblePanel(EUIType.Attribute) then
|
|
UIManager:ClosePanel(EUIType.Attribute)
|
|
else
|
|
UIManager:ShowPanel(EUIType.Attribute)
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnGuideClicked()
|
|
if UIManager:IsVisiblePanel(EUIType.GeneralGuide) then
|
|
UIManager:ClosePanel(EUIType.GeneralGuide)
|
|
else
|
|
UIManager:ShowPanel(EUIType.GeneralGuide)
|
|
end
|
|
end
|
|
|
|
local ButtonTriggerColor = {
|
|
Normal = {R = 1.0, G = 1.0, B = 1.0, A = 1.0},
|
|
Triggered = {R = 1, G = 0.12, B = 0.0, A = 1.0},
|
|
}
|
|
|
|
function WBP_MainUI:SetSelectBossIcon(IsAttackNearestMonster)
|
|
if IsAttackNearestMonster then
|
|
self.InteractButton_SelectBoss.Image_Icon:SetColorAndOpacity(ButtonTriggerColor.Normal)
|
|
else
|
|
self.InteractButton_SelectBoss.Image_Icon:SetColorAndOpacity(ButtonTriggerColor.Triggered)
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnClickSelectBoss()
|
|
local Pawn = GameDataManager.GetLocalPlayerPawn()
|
|
if Pawn and UE.IsValid(Pawn) then
|
|
local WeaponComp = Pawn:GetWeaponComponent()
|
|
if WeaponComp and UE.IsValid(WeaponComp) then
|
|
WeaponComp.IsAttackNearestMonster = not WeaponComp.IsAttackNearestMonster
|
|
self:SetSelectBossIcon(WeaponComp.IsAttackNearestMonster)
|
|
end
|
|
end
|
|
NewPlayerGuideManager:RemoveGuide(29)
|
|
end
|
|
|
|
function WBP_MainUI:OnClickBackpack()
|
|
if UIManager:IsVisiblePanel(EUIType.Backpack) then
|
|
UIManager:HidePanel(EUIType.UseSkill)
|
|
UIManager:HidePanel(EUIType.Backpack)
|
|
else
|
|
EventSystem:SendEvent(EventType.UpdateItemList, true)
|
|
UIManager:ShowPanel(EUIType.Backpack)
|
|
|
|
NewPlayerGuideManager:RemoveGuide(20)
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnClickPickup()
|
|
local PC = GameDataManager.GetLocalPlayerController()
|
|
if not UE.IsValid(PC) then
|
|
return
|
|
end
|
|
PC:RequestPickupNearbyItems(true)
|
|
NewPlayerGuideManager:RemoveGuide(19)
|
|
NewPlayerGuideManager:TriggerGuide(20)
|
|
end
|
|
|
|
function WBP_MainUI:OnClickTechnology()
|
|
self:OpenPanel(EUIType.Tech)
|
|
end
|
|
|
|
function WBP_MainUI:OnClickUnpacking()
|
|
self:OpenPanel(EUIType.Unpacking)
|
|
end
|
|
|
|
function WBP_MainUI:OnClickChallenge()
|
|
self:OpenPanel(EUIType.Challenge)
|
|
end
|
|
|
|
function WBP_MainUI:OnClickBossInfo()
|
|
self:OpenPanel(EUIType.BossInfo)
|
|
end
|
|
|
|
function WBP_MainUI:OnClickWeaponAttribute()
|
|
self:OpenPanel(EUIType.WeaponAttribute)
|
|
end
|
|
|
|
function WBP_MainUI:OnClickSave()
|
|
self:OpenPanel(EUIType.SaveGame)
|
|
end
|
|
|
|
function WBP_MainUI:OnClickBreach()
|
|
local PC = GameDataManager.GetLocalPlayerController()
|
|
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_OnBreach", PC.PlayerKey)
|
|
end
|
|
|
|
function WBP_MainUI:OnToggleBreachButton(Toggle, InPlayerKey)
|
|
if self.PlayerKey ~= InPlayerKey then
|
|
return
|
|
end
|
|
if Toggle then
|
|
self.CanvasPanel_Breach:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
NewPlayerGuideManager:TriggerGuide(4)
|
|
else
|
|
self.CanvasPanel_Breach:SetVisibility(ESlateVisibility.Collapsed)
|
|
UIManager:HidePanel(EUIType.SelectWeapon)
|
|
NewPlayerGuideManager:RemoveGuide(4)
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnBaseAttackChanged(InPlayerKey, BaseAttack)
|
|
if self.PlayerKey == InPlayerKey then
|
|
BaseAttack = math.ceil(BaseAttack)
|
|
self.TextBlock_AttackValue:SetText(string.format("威力值:%d", BaseAttack))
|
|
end
|
|
end
|
|
|
|
|
|
function WBP_MainUI:TryTriggerInteractGuide(ConfigID, TriggerName)
|
|
if NewPlayerGuideManager:IsGuideExisted(ConfigID) then
|
|
return false
|
|
end
|
|
|
|
local ButtonIndex = -1
|
|
local GuideHandleName = ""
|
|
local ToggleHandleName = ""
|
|
|
|
if ConfigID <= 11 then
|
|
ButtonIndex = 1
|
|
GuideHandleName = "InteractExpandHandle1"
|
|
ToggleHandleName = "ToggleHandle1"
|
|
else
|
|
ButtonIndex = 2
|
|
GuideHandleName = "InteractExpandHandle2"
|
|
ToggleHandleName = "ToggleHandle2"
|
|
end
|
|
|
|
if self.InteractExpandHandle1 ~= nil then
|
|
EventSystem.StopTimer(self.InteractExpandHandle1)
|
|
self.InteractExpandHandle1 = nil
|
|
end
|
|
if self.InteractExpandHandle2 ~= nil then
|
|
EventSystem.StopTimer(self.InteractExpandHandle2)
|
|
self.InteractExpandHandle2 = nil
|
|
end
|
|
|
|
self[GuideHandleName] = EventSystem.SetTimer(self, function()
|
|
NewPlayerGuideManager:TriggerGuide(ConfigID)
|
|
self[GuideHandleName] = nil
|
|
end, 0.26)
|
|
|
|
local Duration = NewPlayerGuideManager:GetGuideDuration(ConfigID)
|
|
if Duration > 0.1 then
|
|
self[ToggleHandleName] = EventSystem.SetTimer(self, function()
|
|
self[TriggerName] = false
|
|
self[ToggleHandleName] = nil
|
|
end, Duration)
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
function WBP_MainUI:OnPlayerCoinPointChanged(CoinPoint)
|
|
if CoinPoint > 3500 and NewPlayerGuideManager:HasGuideMaxTriggered(11) == false then
|
|
NewPlayerGuideManager:TriggerGuide(11)
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnPlayerKillPointChanged(KillPoint)
|
|
if self.MaxKillPoint == nil then
|
|
self.MaxKillPoint = 0
|
|
end
|
|
|
|
KillPoint = math.ceil(KillPoint)
|
|
if KillPoint >= self.MaxKillPoint then
|
|
self.MaxKillPoint = KillPoint
|
|
else
|
|
return
|
|
end
|
|
|
|
if self.MaxKillPoint >= 10 then
|
|
if self.MaxKillPoint % 10 < 10 and self.HasTriggeredGuideTechnology == false and NewPlayerGuideManager:HasGuideMaxTriggered(10) == false then
|
|
self.HasTriggeredGuideTechnology = self:TryTriggerInteractGuide(10, "HasTriggeredGuideTechnology")
|
|
end
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnPlayerLevelChange(InAllPlayerLevel)
|
|
for PlayerKey, Level in pairs(InAllPlayerLevel) do
|
|
if self.PlayerKey == PlayerKey then
|
|
self.TextBlock_Level:SetText(string.format("Lv.%d", Level))
|
|
break
|
|
end
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OnPlayerCombatPointChanged(InAllCombatPoint)
|
|
for PlayerKey, CombatPoint in pairs(InAllCombatPoint) do
|
|
if PlayerKey == self.PlayerKey then
|
|
local Val = CombatPoint - 7082
|
|
CombatPoint = math.clamp(Val, 0, CombatPoint)
|
|
|
|
if CombatPoint > 205 and self.HasTriggeredGuideChallenge == false and NewPlayerGuideManager:HasGuideMaxTriggered(13) == false then
|
|
self.HasTriggeredGuideChallenge = self:TryTriggerInteractGuide(13, "HasTriggeredGuideChallenge")
|
|
end
|
|
return
|
|
end
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:OpenPanel(InUIType)
|
|
if UIManager:IsVisiblePanel(InUIType) then
|
|
UIManager:ClosePanel(InUIType)
|
|
else
|
|
UIManager:ShowPanel(InUIType)
|
|
end
|
|
end
|
|
|
|
function WBP_MainUI:SetupForceGuideOutfit()
|
|
local PS = GameDataManager.GetLocalPlayerState()
|
|
if PS and PS:GetNeedTriggerForceGuide() then
|
|
local ValidStepIndex = PS.ForceGuideInfo.ValidStepIndex
|
|
if ValidStepIndex == nil then
|
|
return
|
|
end
|
|
|
|
self.InteractButton_Technology:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.CanvasPanel_BossInfo:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.InteractButton_Unpacking:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.CanvasPanel_Breach:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.InteractButton_SelectBoss:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.InteractButton_Pickup:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.InteractButton_Backpack:SetVisibility(ESlateVisibility.Collapsed)
|
|
self.InteractButton_Challenge:SetVisibility(ESlateVisibility.Collapsed)
|
|
|
|
if ValidStepIndex >= 1 then
|
|
self.InteractButton_Technology:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
if ValidStepIndex >= 2 then
|
|
self.CanvasPanel_BossInfo:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
if ValidStepIndex >= 3 then
|
|
self.InteractButton_Unpacking:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
if ValidStepIndex >= 4 then
|
|
local PS = GameDataManager.GetLocalPlayerState()
|
|
if PS then
|
|
self:OnToggleBreachButton(PS:GetNeedShowBreachButton(), PS.PlayerKey)
|
|
end
|
|
end
|
|
if ValidStepIndex >= 5 then
|
|
self.InteractButton_SelectBoss:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
if ValidStepIndex >= 6 then
|
|
self.InteractButton_Pickup:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
if ValidStepIndex >= 7 then
|
|
self.InteractButton_Backpack:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
if ValidStepIndex >= 8 then
|
|
self.InteractButton_Challenge:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|
end
|
|
end
|
|
end
|
|
|
|
return WBP_MainUI; |