---@class WBP_ForceGuidePanel_C:UUserWidget ---@field Button_Backpack UNewButton ---@field Button_BossInfo UNewButton ---@field Button_Breach UNewButton ---@field Button_Challenge UNewButton ---@field Button_Pickup UNewButton ---@field Button_SelectBoss UNewButton ---@field Button_Tech UNewButton ---@field Button_Unpacking UNewButton ---@field GuidePanel_Backpack UWBP_ForceGuide_Backpack_C ---@field GuidePanel_BossInfo UWBP_ForceGuide_BossInfo_C ---@field GuidePanel_Challenge UWBP_ForceGuide_Challenge_C ---@field GuidePanel_Tech UWBP_ForceGuide_Tech_C ---@field GuidePanel_Unpacking UWBP_ForceGuide_Unpacking_C ---@field Image_SelectBossIcon UImage ---@field Overlay_GuideRoot UOverlay ---@field Panel_Backpack UCanvasPanel ---@field Panel_BossInfo UCanvasPanel ---@field Panel_Breach UCanvasPanel ---@field Panel_Challenge UCanvasPanel ---@field Panel_CoinPoint UCanvasPanel ---@field Panel_CoinTip UCanvasPanel ---@field Panel_Pickup UCanvasPanel ---@field Panel_SelectBoss UCanvasPanel ---@field Panel_Tech UCanvasPanel ---@field Panel_TechPoint UCanvasPanel ---@field Panel_TechTip UCanvasPanel ---@field Panel_Unpacking UCanvasPanel ---@field TextBlock_CoinPoint UTextBlock ---@field TextBlock_KillPoint UTextBlock --Edit Below-- local WBP_ForceGuidePanel = { bInitDoOnce = false, bHasTriggeredAllForceGuide = false, CurValidStepIndex = 1, CurStepIndex = -1, bIsInStepProgress = false, StepPendingList = {}, }; function WBP_ForceGuidePanel:Construct() if self.bInitDoOnce then return end self.bInitDoOnce = true self.CurValidStepIndex = 1 self.CurStepIndex = -1 self.bIsInStepProgress = false self.StepPendingList = {} self.AllPanels = { ["Tech"] = self.Panel_Tech, ["Backpack"] = self.Panel_Backpack, ["BossInfo"] = self.Panel_BossInfo, ["Breach"] = self.Panel_Breach, ["Challenge"] = self.Panel_Challenge, ["Pickup"] = self.Panel_Pickup, ["SelectBoss"] = self.Panel_SelectBoss, ["Unpacking"] = self.Panel_Unpacking, ["CoinPoint"] = self.Panel_CoinPoint, ["TechPoint"] = self.Panel_TechPoint, ["CoinTip"] = self.Panel_CoinTip, ["TechTip"] = self.Panel_TechTip, } self.AllButtons = { ["Tech"] = self.Button_Tech, ["Backpack"] = self.Button_Backpack, ["BossInfo"] = self.Button_BossInfo, ["Breach"] = self.Button_Breach, ["Challenge"] = self.Button_Challenge, ["Pickup"] = self.Button_Pickup, ["SelectBoss"] = self.Button_SelectBoss, ["Unpacking"] = self.Button_Unpacking, } for Name, Button in pairs(self.AllButtons) do Button.OnClicked:Add(self[string.format("OnButton_%sClicked", Name)], self) end self.GuidePanel_Tech:SetVisibility(ESlateVisibility.Collapsed) self.GuidePanel_Backpack:SetVisibility(ESlateVisibility.Collapsed) self.GuidePanel_BossInfo:SetVisibility(ESlateVisibility.Collapsed) self.GuidePanel_Unpacking:SetVisibility(ESlateVisibility.Collapsed) self.GuidePanel_Challenge:SetVisibility(ESlateVisibility.Collapsed) self:OnPlayerCoinPointChanged(GameDataManager.GetLocalPlayerState().CoinPoint.Current) self:OnPlayerKillPointChanged(GameDataManager.GetLocalPlayerState().KillPoint.Current) EventSystem:AddListener(EventType.PlayerCoinPointChanged, WBP_ForceGuidePanel.OnPlayerCoinPointChanged, self) EventSystem:AddListener(EventType.PlayerKillPointChanged, WBP_ForceGuidePanel.OnPlayerKillPointChanged, self) EventSystem:AddListener(EventType.ForceGuide_OnGuideTriggered, WBP_ForceGuidePanel.OnGuideTriggered, self) EventSystem:AddListener(EventType.ForceGuide_OnGuideFinished, WBP_ForceGuidePanel.OnGuideFinished, self) end function WBP_ForceGuidePanel:OnPlayerCoinPointChanged(InCoinPoint) self.TextBlock_CoinPoint:SetText(tostring(math.ceil(InCoinPoint).." ")) end function WBP_ForceGuidePanel:OnPlayerKillPointChanged(InKillPoint) self.TextBlock_KillPoint:SetText(tostring(math.ceil(InKillPoint).." ")) end function WBP_ForceGuidePanel:InitByRecordedInfo(ForceGuideInfo) local RecordedCurStepIndex = ForceGuideInfo.CurStepIndex self.CurStepIndex = (RecordedCurStepIndex and RecordedCurStepIndex > 0) and RecordedCurStepIndex or -1 local RecordedValidStepIndex = ForceGuideInfo.ValidStepIndex self.CurValidStepIndex = (RecordedValidStepIndex and RecordedValidStepIndex > 0) and RecordedValidStepIndex or 1 if self.CurValidStepIndex > 8 then self.bHasTriggeredAllForceGuide = true return end local RecordedStepPendingList = ForceGuideInfo.StepPendingList self.StepPendingList = (RecordedStepPendingList and not table.isEmpty(RecordedStepPendingList)) and RecordedStepPendingList or {} local PSIsInProgress = ForceGuideInfo.bIsInStepProgress if PSIsInProgress ~= nil and PSIsInProgress then self:TryTriggerForceGuide(self.CurStepIndex) end end function WBP_ForceGuidePanel:TryTriggerForceGuide(StepIndex) if self.bHasTriggeredAllForceGuide == true or self.CurValidStepIndex > StepIndex then return false end if not table.hasValue(self.StepPendingList, StepIndex) then table.insert(self.StepPendingList, StepIndex) table.sort(self.StepPendingList, function(a, b) return a < b end) end if not self.bIsInStepProgress and self.CurValidStepIndex == StepIndex then UE.Log("[WBP_ForceGuidePanel] TryTriggerForceGuide: %d", StepIndex) self:SetupStepIndex(StepIndex) end return true end function WBP_ForceGuidePanel:SetupStepIndex(StepIndex) if self.CurValidStepIndex ~= StepIndex then return end self:SetVisibility(ESlateVisibility.SelfHitTestInvisible) UIManager:CloseWidgetByRoot(UIRoot.MiddleRoot) self.bIsInStepProgress = true self.CurStepIndex = StepIndex UE.Log("[WBP_ForceGuidePanel] Guide Index Triggered: %d", StepIndex) local MainUI = UIManager:GetPanel(EUIType.Main) if self.CurStepIndex == 1 then --兑换 self:ShowGuidePanelByName("Tech") MainUI.InteractButton_Technology:SetVisibility(ESlateVisibility.SelfHitTestInvisible) elseif self.CurStepIndex == 2 then self:ShowGuidePanelByName("BossInfo") MainUI.CanvasPanel_BossInfo:SetVisibility(ESlateVisibility.SelfHitTestInvisible) elseif self.CurStepIndex == 3 then self:ShowGuidePanelByName("Unpacking") MainUI.InteractButton_Unpacking:SetVisibility(ESlateVisibility.SelfHitTestInvisible) elseif self.CurStepIndex == 4 then self:ShowGuidePanelByName("Breach") MainUI.CanvasPanel_Breach:SetVisibility(ESlateVisibility.SelfHitTestInvisible) elseif self.CurStepIndex == 5 then self:ShowGuidePanelByName('SelectBoss') MainUI.InteractButton_SelectBoss:SetVisibility(ESlateVisibility.SelfHitTestInvisible) elseif self.CurStepIndex == 6 then self:ShowGuidePanelByName('Pickup') MainUI.InteractButton_Pickup:SetVisibility(ESlateVisibility.SelfHitTestInvisible) elseif self.CurStepIndex == 7 then self:ShowGuidePanelByName("Backpack") MainUI.InteractButton_Backpack:SetVisibility(ESlateVisibility.SelfHitTestInvisible) elseif self.CurStepIndex == 8 then self:ShowGuidePanelByName("Challenge") MainUI.InteractButton_Challenge:SetVisibility(ESlateVisibility.SelfHitTestInvisible) end end function WBP_ForceGuidePanel:ShowGuidePanelByName(...) if select("#", ...) <= 0 then return end local PanelNames = {...} for PanelName, Panel in pairs(self.AllPanels) do if table.hasValue(PanelNames, PanelName) then Panel:SetVisibility(ESlateVisibility.SelfHitTestInvisible) else Panel:SetVisibility(ESlateVisibility.Collapsed) end end end function WBP_ForceGuidePanel:HideGuidePanelByName(...) if select("#", ...) <= 0 then return end local PanelNames = {...} for _, PanelName in pairs(PanelNames) do self.AllPanels[PanelName]:SetVisibility(ESlateVisibility.Collapsed) end end function WBP_ForceGuidePanel:OnButton_TechClicked() self.GuidePanel_Tech:OnStartGuideProgress() end function WBP_ForceGuidePanel:OnButton_BackpackClicked() self.GuidePanel_Backpack:OnStartGuideProgress() end function WBP_ForceGuidePanel:OnButton_BossInfoClicked() self.GuidePanel_BossInfo:OnStartGuideProgress() end function WBP_ForceGuidePanel:OnButton_ChallengeClicked() self.GuidePanel_Challenge:OnStartGuideProgress() end function WBP_ForceGuidePanel:OnButton_UnpackingClicked() self.GuidePanel_Unpacking:OnStartGuideProgress() end function WBP_ForceGuidePanel:OnButton_BreachClicked() EventSystem:SendEvent(EventType.ForceGuide_OnGuideFinished, 4) EventSystem:SendEvent(EventType.ToggleBreachButton, false) end function WBP_ForceGuidePanel:OnButton_SelectBossClicked() 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 local MainUI = UIManager:GetPanel(EUIType.Main) if MainUI then MainUI:SetSelectBossIcon(WeaponComp.IsAttackNearestMonster) end end end local PC = GameDataManager.GetLocalPlayerController() UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_OnBreach", PC.PlayerKey) EventSystem:SendEvent(EventType.ForceGuide_OnGuideFinished, 5) end function WBP_ForceGuidePanel:OnButton_PickupClicked() local PC = GameDataManager.GetLocalPlayerController() PC:RequestPickupNearbyItems(true) self:HideGuidePanelByName('Pickup') EventSystem.SetTimer(self, function() EventSystem:SendEvent(EventType.ForceGuide_OnGuideFinished, 6) end, 0.5) end function WBP_ForceGuidePanel:OnGuideTriggered(StepIndex) if StepIndex == 1 then self:ShowGuidePanelByName('TechPoint', 'TechTip') elseif StepIndex == 2 then self:HideGuidePanelByName('BossInfo') elseif StepIndex == 3 then self:ShowGuidePanelByName('CoinPoint', 'CoinTip') elseif StepIndex == 7 then self:HideGuidePanelByName('Backpack') elseif StepIndex == 8 then self:HideGuidePanelByName('Challenge') end end function WBP_ForceGuidePanel:OnGuideFinished(StepIndex) if self.CurStepIndex == StepIndex and self.CurValidStepIndex == StepIndex then UE.Log("[WBP_ForceGuidePanel] Guide Index Finished: %d", StepIndex) self.CurValidStepIndex = self.CurValidStepIndex + 1 table.remove(self.StepPendingList, 1) self.bIsInStepProgress = false if StepIndex == 1 then if not table.hasValue(self.StepPendingList, 2) then table.insert(self.StepPendingList, 1, 2) end elseif StepIndex == 4 then if not table.hasValue(self.StepPendingList, 5) then table.insert(self.StepPendingList, 1, 5) end elseif StepIndex == 6 then if not table.hasValue(self.StepPendingList, 7) then table.insert(self.StepPendingList, 1, 7) end end local NextIndex, NextStepIndex = next(self.StepPendingList) if NextIndex ~= nil and NextStepIndex ~= nil then if NextStepIndex == self.CurValidStepIndex then self:SetupStepIndex(NextStepIndex) else self:SetVisibility(ESlateVisibility.Collapsed) end else self:SetVisibility(ESlateVisibility.Collapsed) end if StepIndex == 8 then self.bHasTriggeredAllForceGuide = true UE.Log("[WBP_ForceGuidePanel] All Force Guide Triggered") end end end return WBP_ForceGuidePanel;