731 lines
29 KiB
Lua
731 lines
29 KiB
Lua
|
---@class WBP_InteractPanel_C:UUserWidget
|
|||
|
---@field Button_FadeIn_2 UWidgetAnimation
|
|||
|
---@field Button_FadeIn_1 UWidgetAnimation
|
|||
|
---@field Button_AttributeUpgrade UNewButton
|
|||
|
---@field Button_Backpack UNewButton
|
|||
|
---@field Button_BossInfo UNewButton
|
|||
|
---@field Button_Breach UNewButton
|
|||
|
---@field Button_Challenge UNewButton
|
|||
|
---@field Button_ChooseWeapon_Left UButton
|
|||
|
---@field Button_ChooseWeapon_Right UButton
|
|||
|
---@field Button_Inherit UNewButton
|
|||
|
---@field Button_Pickup UNewButton
|
|||
|
---@field Button_ResourceGrade UNewButton
|
|||
|
---@field Button_ResourceUpgrade UNewButton
|
|||
|
---@field Button_Save UNewButton
|
|||
|
---@field Button_Seal UNewButton
|
|||
|
---@field Button_SelectBoss UNewButton
|
|||
|
---@field Button_ShowAttribute UNewButton
|
|||
|
---@field Button_SkillInfo UNewButton
|
|||
|
---@field Button_Technology UNewButton
|
|||
|
---@field Button_Unpacking UNewButton
|
|||
|
---@field Button_WeaponAttribute UNewButton
|
|||
|
---@field Image_SelectBoss UImage
|
|||
|
---@field Image_Weapon UImage
|
|||
|
---@field Overlay_AttributeButton UOverlay
|
|||
|
---@field Overlay_SaveButton UOverlay
|
|||
|
---@field Panel_Button1 UCanvasPanel
|
|||
|
---@field Panel_Button2 UCanvasPanel
|
|||
|
---@field Panel_Button3 UCanvasPanel
|
|||
|
---@field Panel_Button4 UCanvasPanel
|
|||
|
---@field Panel_Button5 UCanvasPanel
|
|||
|
---@field Panel_Button_AttributeUpgrade UCanvasPanel
|
|||
|
---@field Panel_Button_Backpack UCanvasPanel
|
|||
|
---@field Panel_Button_BossInfo UCanvasPanel
|
|||
|
---@field Panel_Button_Breach UCanvasPanel
|
|||
|
---@field Panel_Button_Pickup UCanvasPanel
|
|||
|
---@field Panel_Button_ResourceUpgrade UCanvasPanel
|
|||
|
---@field Panel_Button_Seal UCanvasPanel
|
|||
|
---@field Panel_PlayerInfo UCanvasPanel
|
|||
|
---@field Panel_SelectBoss UCanvasPanel
|
|||
|
---@field Panel_WeaponInfo UCanvasPanel
|
|||
|
---@field ProgressBar_Energy UProgressBar
|
|||
|
---@field ProgressBar_Exp UProgressBar
|
|||
|
---@field ProgressBar_Health UProgressBar
|
|||
|
---@field TextBlock_AttackValue UTextBlock
|
|||
|
---@field TextBlock_Health UTextBlock
|
|||
|
---@field TextBlock_Level UTextBlock
|
|||
|
---@field TextBlock_WeaponName UTextBlock
|
|||
|
--Edit Below--
|
|||
|
local WBP_InteractPanel = {
|
|||
|
bInitDoOnce = false,
|
|||
|
WeaponComponent = nil,
|
|||
|
|
|||
|
bHasShowAttributeUpgrade = false,
|
|||
|
bHasShowResourceUpgrade = false,
|
|||
|
};
|
|||
|
|
|||
|
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_InteractPanel:Construct()
|
|||
|
WBP_InteractPanel.SuperClass.Construct(self)
|
|||
|
|
|||
|
self:OnToggleBreachButton(false)
|
|||
|
self:OnToggleSealButton(false)
|
|||
|
|
|||
|
for i = 2, 5 do
|
|||
|
--self[string.format("Panel_Button%d", i)]:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
end
|
|||
|
|
|||
|
self:Init()
|
|||
|
|
|||
|
self:BindEvents()
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:Destruct()
|
|||
|
self:UnBindEvents()
|
|||
|
WBP_InteractPanel.SuperClass.Destruct(self)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:Init()
|
|||
|
local OwningPawn = GameDataManager.GetLocalPlayerController():GetPlayerCharacterSafety()
|
|||
|
local LocalPlayerState = GameDataManager.GetLocalPlayerState()
|
|||
|
self.PlayerKey = LocalPlayerState.PlayerKey
|
|||
|
|
|||
|
self:OnExpChanged(UGCGameSystem.GameState:GetAllPlayerExp())
|
|||
|
self:OnPlayerLevelChange(UGCGameSystem.GameState:GetAllPlayerLevel())
|
|||
|
|
|||
|
self:OnHealthChanged(self.PlayerKey, UGCPawnAttrSystem.GetHealth(OwningPawn), UGCPawnAttrSystem.GetHealth(OwningPawn), 0)
|
|||
|
self:OnEnergyChanged(self.PlayerKey, OwningPawn.EnergyData.Cur, OwningPawn.EnergyData.Max)
|
|||
|
if LocalPlayerState.Attributes[AttributeType.Base] and LocalPlayerState.Attributes[AttributeType.Base].Base_Attack then
|
|||
|
self:OnBaseAttackChanged(self.PlayerKey, LocalPlayerState.Attributes[AttributeType.Base].Base_Attack)
|
|||
|
end
|
|||
|
|
|||
|
local Pawn = GameDataManager.GetLocalPlayerPawn()
|
|||
|
if Pawn and UE.IsValid(Pawn) then
|
|||
|
local WeaponComp = Pawn:GetWeaponComponent()
|
|||
|
if WeaponComp and UE.IsValid(WeaponComp) then
|
|||
|
if WeaponComp.IsAttackNearestMonster then
|
|||
|
self.Image_SelectBoss:SetColorAndOpacity(ButtonTriggerColor.Normal)
|
|||
|
else
|
|||
|
self.Image_SelectBoss:SetColorAndOpacity(ButtonTriggerColor.Triggered)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
self.HasTriggeredGuideChallenge = false
|
|||
|
self.HasTriggeredGuideResourceGrade = false
|
|||
|
self.HasTriggeredGuideUnpacking = false
|
|||
|
self.HasTriggeredGuideTechnology = false
|
|||
|
self.HasTriggeredGuideIherit = false
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:BindEvents()
|
|||
|
EventSystem:AddListener(EventType.ToggleBreachButton, WBP_InteractPanel.OnToggleBreachButton, self)
|
|||
|
EventSystem:AddListener(EventType.ShowSealButton, WBP_InteractPanel.OnToggleSealButton, self)
|
|||
|
EventSystem:AddListener(EventType.ClientUpdateWeapon, WBP_InteractPanel.OnUpdateWeapon, self)
|
|||
|
EventSystem:AddListener(EventType.OnPlayerExpChanged, WBP_InteractPanel.OnExpChanged, self)
|
|||
|
EventSystem:AddListener(EventType.OnPlayerHPChanged, WBP_InteractPanel.OnHealthChanged, self)
|
|||
|
EventSystem:AddListener(EventType.OnPlayerEnergyChanged, WBP_InteractPanel.OnEnergyChanged, self)
|
|||
|
EventSystem:AddListener(EventType.OnPlayerBaseAttackValueChanged, WBP_InteractPanel.OnBaseAttackChanged, self)
|
|||
|
EventSystem:AddListener(EventType.PlayerCoinPointChanged, WBP_InteractPanel.OnPlayerCoinPointChanged, self)
|
|||
|
EventSystem:AddListener(EventType.PlayerKillPointChanged, WBP_InteractPanel.OnPlayerKillPointChanged, self)
|
|||
|
EventSystem:AddListener(EventType.PlayerInheritItemsChanged, WBP_InteractPanel.OnPlayerInheritItemsChanged, self)
|
|||
|
EventSystem:AddListener(EventType.OnPlayerLevelChanged, WBP_InteractPanel.OnPlayerLevelChange, self)
|
|||
|
|
|||
|
self.Button_Pickup.OnClicked:Add(WBP_InteractPanel.OnPickupButtonClicked, self)
|
|||
|
self.Button_ShowAttribute.OnClicked:Add(WBP_InteractPanel.OnShowAttributeButtonClicked, self)
|
|||
|
self.Button_Backpack.OnClicked:Add(WBP_InteractPanel.ClickBackpackButton, self)
|
|||
|
self.Button_Breach.OnClicked:Add(WBP_InteractPanel.OnBreach, self)
|
|||
|
self.Button_ChooseWeapon_Left.OnClicked:Add(WBP_InteractPanel.OnMinusWeapon, self)
|
|||
|
self.Button_ChooseWeapon_Right.OnClicked:Add(WBP_InteractPanel.OnAddWeapon, self)
|
|||
|
self.Button_BossInfo.OnClicked:Add(WBP_InteractPanel.OnBossInfoPanel, self)
|
|||
|
|
|||
|
self.Button_Technology.OnClicked:Add(WBP_InteractPanel.OnTechnologyPanel, self)
|
|||
|
self.Button_Unpacking.OnClicked:Add(WBP_InteractPanel.OnUnpackingPanel, self)
|
|||
|
self.Button_Challenge.OnClicked:Add(WBP_InteractPanel.OnChallenge, self)
|
|||
|
self.Button_Inherit.OnClicked:Add(WBP_InteractPanel.OnInherit, self)
|
|||
|
self.Button_ResourceGrade.OnClicked:Add(WBP_InteractPanel.OnResourceGradePanel, self)
|
|||
|
|
|||
|
self.Button_WeaponAttribute.OnClicked:Add(WBP_InteractPanel.OnClickWeaponAttribute, self)
|
|||
|
self.Button_SkillInfo.OnClicked:Add(WBP_InteractPanel.OnClickSkillInfo, self)
|
|||
|
self.Button_Seal.OnClicked:Add(WBP_InteractPanel.OnClickSeal, self)
|
|||
|
self.Button_Save.OnClicked:Add(WBP_InteractPanel.OnClickSaveGame, self)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:UnBindEvents()
|
|||
|
EventSystem:RemoveListener(EventType.ToggleBreachButton, WBP_InteractPanel.OnToggleBreachButton, self)
|
|||
|
EventSystem:RemoveListener(EventType.ClientUpdateWeapon, WBP_InteractPanel.OnUpdateWeapon, self)
|
|||
|
EventSystem:RemoveListener(EventType.ShowSealButton, WBP_InteractPanel.OnToggleSealButton, self)
|
|||
|
EventSystem:RemoveListener(EventType.OnPlayerEnergyChanged, WBP_InteractPanel.OnEnergyChanged, self)
|
|||
|
EventSystem:RemoveListener(EventType.OnPlayerHPChanged, WBP_InteractPanel.OnHealthChanged, self)
|
|||
|
EventSystem:RemoveListener(EventType.OnPlayerExpChanged, WBP_InteractPanel.OnExpChanged, self)
|
|||
|
EventSystem:RemoveListener(EventType.OnPlayerBaseAttackValueChanged, WBP_InteractPanel.OnBaseAttackChanged, self)
|
|||
|
EventSystem:RemoveListener(EventType.PlayerCoinPointChanged, WBP_InteractPanel.OnPlayerCoinPointChanged, self)
|
|||
|
EventSystem:RemoveListener(EventType.PlayerKillPointChanged, WBP_InteractPanel.OnPlayerKillPointChanged, self)
|
|||
|
EventSystem:RemoveListener(EventType.PlayerInheritItemsChanged, WBP_InteractPanel.OnPlayerInheritItemsChanged, self)
|
|||
|
EventSystem:RemoveListener(EventType.OnPlayerLevelChanged, WBP_InteractPanel.OnPlayerLevelChange, self)
|
|||
|
|
|||
|
self.Button_Pickup.OnClicked:Remove(WBP_InteractPanel.OnPickupButtonClicked, self)
|
|||
|
self.Button_ShowAttribute.OnClicked:Remove(WBP_InteractPanel.OnShowAttributeButtonClicked, self)
|
|||
|
self.Button_Backpack.OnClicked:Remove(WBP_InteractPanel.ClickBackpackButton, self)
|
|||
|
self.Button_Breach.OnClicked:Remove(WBP_InteractPanel.OnBreach, self)
|
|||
|
self.Button_ChooseWeapon_Left.OnClicked:Remove(WBP_InteractPanel.OnMinusWeapon, self)
|
|||
|
self.Button_ChooseWeapon_Right.OnClicked:Remove(WBP_InteractPanel.OnAddWeapon, self)
|
|||
|
self.Button_BossInfo.OnClicked:Remove(WBP_InteractPanel.OnBossInfoPanel, self)
|
|||
|
|
|||
|
self.Button_Technology.OnClicked:Remove(WBP_InteractPanel.OnTechnologyPanel, self)
|
|||
|
self.Button_Unpacking.OnClicked:Remove(WBP_InteractPanel.OnUnpackingPanel, self)
|
|||
|
self.Button_Challenge.OnClicked:Remove(WBP_InteractPanel.OnChallenge, self)
|
|||
|
self.Button_Inherit.OnClicked:Remove(WBP_InteractPanel.OnInherit, self)
|
|||
|
self.Button_ResourceGrade.OnClicked:Remove(WBP_InteractPanel.OnResourceGradePanel, self)
|
|||
|
|
|||
|
self.Button_WeaponAttribute.OnClicked:Remove(WBP_InteractPanel.OnClickWeaponAttribute, self)
|
|||
|
self.Button_SkillInfo.OnClicked:Remove(WBP_InteractPanel.OnClickSkillInfo, self)
|
|||
|
self.Button_Seal.OnClicked:Remove(WBP_InteractPanel.OnClickSeal, self)
|
|||
|
self.Button_Save.OnClicked:Remove(WBP_InteractPanel.OnClickSaveGame, self)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnShowAttributeButtonClicked()
|
|||
|
if UIManager:IsVisiblePanel(EUIType.Attribute) then
|
|||
|
UIManager:ClosePanel(EUIType.Attribute)
|
|||
|
else
|
|||
|
UIManager:ShowPanel(EUIType.Attribute)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnPickupButtonClicked()
|
|||
|
local PC = GameDataManager.GetLocalPlayerController()
|
|||
|
if not UE.IsValid(PC) then
|
|||
|
return
|
|||
|
end
|
|||
|
PC:RequestPickupNearbyItems(true)
|
|||
|
NewPlayerGuideManager:RemoveGuide(19)
|
|||
|
NewPlayerGuideManager:TriggerGuide(20)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnToggleBreachButton(Toggle)
|
|||
|
if Toggle then
|
|||
|
self.Panel_Button_Breach:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|||
|
NewPlayerGuideManager:TriggerGuide(4)
|
|||
|
else
|
|||
|
self.Panel_Button_Breach:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
UIManager:HidePanel(EUIType.SelectWeapon)
|
|||
|
NewPlayerGuideManager:RemoveGuide(4)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnToggleSealButton(IsShow)
|
|||
|
if IsShow then
|
|||
|
self.Panel_Button_Seal:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|||
|
self.CanClickSeal = true
|
|||
|
--NewPlayerGuideManager:TriggerGuide(14)
|
|||
|
else
|
|||
|
self.CanClickSeal = false
|
|||
|
self.Panel_Button_Seal:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
--NewPlayerGuideManager:RemoveGuide(14)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:ClickBackpackButton()
|
|||
|
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_InteractPanel:OnBreach()
|
|||
|
print(string.format('[WBP_InteractPanel:OnBreach] 执行'))
|
|||
|
if UIManager:IsVisiblePanel(EUIType.SelectWeapon) then
|
|||
|
UIManager:HidePanel(EUIType.SelectWeapon)
|
|||
|
else
|
|||
|
-- 直接生成一个怪物,再给玩家赋予能力即可
|
|||
|
print(string.format('[WBP_InteractPanel:OnBreach] 可以执行'))
|
|||
|
local PC = GameDataManager.GetLocalPlayerController()
|
|||
|
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_OnBreach", PC.PlayerKey)
|
|||
|
|
|||
|
self.Panel_Button_Breach:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
NewPlayerGuideManager:RemoveGuide(4)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:SetWeaponComponent()
|
|||
|
local PlayerController = STExtraGameplayStatics.GetFirstPlayerController(self)
|
|||
|
if PlayerController then
|
|||
|
local OwningPawn = PlayerController:GetPlayerCharacterSafety()
|
|||
|
if OwningPawn then
|
|||
|
local WC = OwningPawn:GetWeaponComponent()
|
|||
|
if WC ~= nil and UE.IsValid(WC) then
|
|||
|
self.WeaponComponent = WC
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:SetWeaponIcon(InIcon)
|
|||
|
local IconSlot = WidgetLayoutLibrary.SlotAsCanvasSlot(self.Image_Weapon)
|
|||
|
local NewIconX = 40 / 80 * InIcon:Blueprint_GetSizeX()
|
|||
|
IconSlot:SetSize({X = NewIconX, Y = 40})
|
|||
|
self.Image_Weapon:SetBrushFromTexture(InIcon)
|
|||
|
self.Image_Weapon:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnMinusWeapon()
|
|||
|
-- 找到当前的 Id
|
|||
|
if self.WeaponComponent == nil then
|
|||
|
self:SetWeaponComponent()
|
|||
|
end
|
|||
|
|
|||
|
local CurrentIndex = self.WeaponComponent:GetCurrentWeaponIndex()
|
|||
|
local TotalWeaponCount = self.WeaponComponent:GetWeaponCount()
|
|||
|
print(string.format("[WBP_InteractPanel:OnMinusWeapon] Total Weapon Count = %d", TotalWeaponCount))
|
|||
|
local NextIndex = (CurrentIndex + TotalWeaponCount - 1) % TotalWeaponCount
|
|||
|
if NextIndex == 0 then
|
|||
|
NextIndex = TotalWeaponCount
|
|||
|
end
|
|||
|
print(string.format("[WBP_InteractPanel:OnMinusWeapon] Next Index = %d", NextIndex))
|
|||
|
local NextWeaponId = self.WeaponComponent:FindWeaponIdByIndex(NextIndex)
|
|||
|
local PlayerController = GameDataManager.GetLocalPlayerController()
|
|||
|
print(string.format("[WBP_InteractPanel:OnMinusWeapon] NextWeapon Id = %d" , NextWeaponId))
|
|||
|
UnrealNetwork.CallUnrealRPC(PlayerController, PlayerController, "ServerRPC_ChangeCurrentWeaponId", NextWeaponId)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnAddWeapon()
|
|||
|
if self.WeaponComponent == nil then
|
|||
|
self:SetWeaponComponent()
|
|||
|
end
|
|||
|
local CurrentIndex = self.WeaponComponent:GetCurrentWeaponIndex()
|
|||
|
local TotalWeaponCount = self.WeaponComponent:GetWeaponCount()
|
|||
|
print(string.format("[WBP_InteractPanel:OnAddWeapon] Total Weapon Count = %d", TotalWeaponCount))
|
|||
|
local NextIndex = (CurrentIndex + TotalWeaponCount + 1) % TotalWeaponCount
|
|||
|
if NextIndex == 0 then
|
|||
|
NextIndex = TotalWeaponCount
|
|||
|
end
|
|||
|
print(string.format("[WBP_InteractPanel:OnAddWeapon] Next Index = %d", NextIndex))
|
|||
|
local NextWeaponId = self.WeaponComponent:FindWeaponIdByIndex(NextIndex)
|
|||
|
local PlayerController = GameDataManager.GetLocalPlayerController()
|
|||
|
print(string.format("[WBP_InteractPanel:OnAddWeapon] NextWeapon Id = %d" , NextWeaponId))
|
|||
|
UnrealNetwork.CallUnrealRPC(PlayerController, PlayerController, "ServerRPC_ChangeCurrentWeaponId", NextWeaponId)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnUpdateWeapon(InNewId, InPlayerKey)
|
|||
|
if InPlayerKey ~= GameDataManager.GetLocalPlayerController().PlayerKey then
|
|||
|
return
|
|||
|
end
|
|||
|
|
|||
|
-- 找到对应 图标
|
|||
|
local Data = GameDataManager.GetWeaponConstructDataByID(InNewId)
|
|||
|
if Data == nil then
|
|||
|
UE.Log("[WBP_InteractPanel:OnUpdateWeapon] Data is nil")
|
|||
|
return
|
|||
|
end
|
|||
|
local Val = DropItemMap.WeaponTable[Data.WeaponType]
|
|||
|
if Val ~= nil then
|
|||
|
if Val.Icon == nil then
|
|||
|
self.Image_Weapon:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
else
|
|||
|
local Icon = UE.LoadObject(Val.Icon)
|
|||
|
if Icon == nil then
|
|||
|
self.Image_Weapon:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
else
|
|||
|
self:SetWeaponIcon(Icon)
|
|||
|
self.TextBlock_WeaponName:SetText(Val.ChineseName)
|
|||
|
self.TextBlock_WeaponName:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnExpChanged(PlayerAllExp)
|
|||
|
for PlayerKey, ExpInfo in pairs(PlayerAllExp) do
|
|||
|
if self.PlayerKey == PlayerKey then
|
|||
|
self.ProgressBar_Exp:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|||
|
self.ProgressBar_Exp:SetPercent(ExpInfo.CurExp / ExpInfo.TotalExp)
|
|||
|
return
|
|||
|
end
|
|||
|
end
|
|||
|
self.ProgressBar_Exp:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnHealthChanged(InPlayerKey, CurHP, MaxHP, PrevHP)
|
|||
|
if self.PlayerKey == InPlayerKey then
|
|||
|
self.ProgressBar_Health:SetPercent(CurHP / MaxHP)
|
|||
|
self.TextBlock_Health:SetText(string.format('%d / %d', math.floor(CurHP), math.floor(MaxHP)))
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnEnergyChanged(InPlayerKey, CurEnergy, MaxEnergy)
|
|||
|
if self.PlayerKey == InPlayerKey then
|
|||
|
self.ProgressBar_Energy:SetPercent(CurEnergy / MaxEnergy)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnPlayerInheritItemsChanged(InheritItems)
|
|||
|
if InheritItems['盔'] // 10 % 10 >= 3 or InheritItems['甲'] // 10 % 10 >= 3 then
|
|||
|
self.CanClickUnpacking = true
|
|||
|
if self.HasTriggeredGuideUnpacking == false and NewPlayerGuideManager:HasGuideMaxTriggered(11) == false then
|
|||
|
self.HasTriggeredGuideUnpacking = self:TryTriggerInteractGuide(11, "HasTriggeredGuideUnpacking")
|
|||
|
end
|
|||
|
else
|
|||
|
self.CanClickUnpacking = false
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnBaseAttackChanged(InPlayerKey, BaseAttack)
|
|||
|
if self.PlayerKey == InPlayerKey then
|
|||
|
BaseAttack = math.ceil(BaseAttack)
|
|||
|
self.TextBlock_AttackValue:SetText(string.format("威力值:%d", BaseAttack))
|
|||
|
|
|||
|
if BaseAttack > 0 then
|
|||
|
if (BaseAttack % 500 < 20 or BaseAttack % 700 < 20) and self.HasTriggeredGuideChallenge == false and NewPlayerGuideManager:HasGuideMaxTriggered(13) == false then
|
|||
|
self.HasTriggeredGuideChallenge = self:TryTriggerInteractGuide(13, "HasTriggeredGuideChallenge")
|
|||
|
end
|
|||
|
if BaseAttack % 2000 < 20 and self.HasTriggeredGuideResourceGrade == false and NewPlayerGuideManager:HasGuideMaxTriggered(12) == false then
|
|||
|
self.HasTriggeredGuideResourceGrade = self:TryTriggerInteractGuide(12, "HasTriggeredGuideResourceGrade")
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnPlayerCoinPointChanged(CoinPoint)
|
|||
|
CoinPoint = math.ceil(CoinPoint)
|
|||
|
if CoinPoint > 0 then
|
|||
|
if CoinPoint >= 3500 then
|
|||
|
self.CanClickInherit = true
|
|||
|
if CoinPoint % 3500 < 20 and self.HasTriggeredGuideIherit == false and NewPlayerGuideManager:HasGuideMaxTriggered(9) == false then
|
|||
|
self.HasTriggeredGuideIherit = self:TryTriggerInteractGuide(9, "HasTriggeredGuideIherit")
|
|||
|
end
|
|||
|
else
|
|||
|
self.CanClickInherit = false
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel: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_InteractPanel:TryTriggerInteractGuide(ConfigID, TriggerName)
|
|||
|
if NewPlayerGuideManager:IsGuideExisted(ConfigID) then
|
|||
|
return false
|
|||
|
end
|
|||
|
|
|||
|
local ButtonIndex = -1
|
|||
|
local ButtonToggleName = ""
|
|||
|
local GuideHandleName = ""
|
|||
|
local ToggleHandleName = ""
|
|||
|
|
|||
|
if ConfigID <= 11 then
|
|||
|
ButtonIndex = 1
|
|||
|
ButtonToggleName = "bHasShowAttributeUpgrade"
|
|||
|
GuideHandleName = "InteractExpandHandle1"
|
|||
|
ToggleHandleName = "ToggleHandle1"
|
|||
|
else
|
|||
|
ButtonIndex = 2
|
|||
|
ButtonToggleName = "bHasShowResourceUpgrade"
|
|||
|
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
|
|||
|
|
|||
|
if self[ButtonToggleName] == false then
|
|||
|
self:OnForceExpandUpgradeRelatedButtonByIndex(ButtonIndex)
|
|||
|
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_InteractPanel: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_InteractPanel:OnTechnologyPanel()
|
|||
|
if UIManager:IsVisiblePanel(EUIType.Tech) then
|
|||
|
UIManager:ClosePanel(EUIType.Tech)
|
|||
|
else
|
|||
|
UIManager:ShowPanel(EUIType.Tech)
|
|||
|
end
|
|||
|
self:OnUpgradeRelatedButtonClicked()
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnBossInfoPanel()
|
|||
|
if UIManager:IsVisiblePanel(EUIType.BossInfo) then
|
|||
|
UIManager:ClosePanel(EUIType.BossInfo)
|
|||
|
else
|
|||
|
UIManager:ShowPanel(EUIType.BossInfo)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnUnpackingPanel()
|
|||
|
if UIManager:IsVisiblePanel(EUIType.Unpacking) then
|
|||
|
UIManager:ClosePanel(EUIType.Unpacking)
|
|||
|
self:OnUpgradeRelatedButtonClicked()
|
|||
|
else
|
|||
|
self.CanClickUnpacking = true
|
|||
|
if self.CanClickUnpacking then
|
|||
|
UIManager:ShowPanel(EUIType.Unpacking)
|
|||
|
self:OnUpgradeRelatedButtonClicked()
|
|||
|
else
|
|||
|
UIManager:ShowGeneralNotice("需要将购买中的盔或者甲升级到高级才能开启")
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnChallenge()
|
|||
|
if UIManager:IsVisiblePanel(EUIType.Challenge) then
|
|||
|
UIManager:ClosePanel(EUIType.Challenge)
|
|||
|
else
|
|||
|
UIManager:ShowPanel(EUIType.Challenge)
|
|||
|
end
|
|||
|
self:OnUpgradeRelatedButtonClicked()
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnClickWeaponAttribute()
|
|||
|
-- 显示界面
|
|||
|
if UIManager:IsVisiblePanel(EUIType.WeaponAttribute) then
|
|||
|
UIManager:ClosePanel(EUIType.WeaponAttribute)
|
|||
|
else
|
|||
|
UIManager:ShowPanel(EUIType.WeaponAttribute)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnClickSkillInfo()
|
|||
|
local Pawn = GameDataManager.GetLocalPlayerPawn()
|
|||
|
local WeaponType = GameDataManager.GetWeaponType(Pawn.WeaponActor.CurrentWeaponId)
|
|||
|
if WeaponType == nil or WeaponType == EWeaponClassType.WT_Pistol then
|
|||
|
return
|
|||
|
end
|
|||
|
-- UIManager:ShowPanel(EUIType.WeaponDetailsDesc)
|
|||
|
if UIManager:IsVisiblePanel(EUIType.WeaponDetailsDesc) then
|
|||
|
UIManager:ClosePanel(EUIType.WeaponDetailsDesc)
|
|||
|
else
|
|||
|
UIManager:ShowPanel(EUIType.WeaponDetailsDesc)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnClickSeal()
|
|||
|
-- 召唤一个
|
|||
|
if self.CanClickSeal then
|
|||
|
self.CanClickSeal = false
|
|||
|
local PlayerController = GameDataManager.GetLocalPlayerController()
|
|||
|
UnrealNetwork.CallUnrealRPC(PlayerController, PlayerController, "ServerRPC_StartSpawnSealMonster")
|
|||
|
self.Panel_Button_Seal:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
NewPlayerGuideManager:RemoveGuide(14)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnInherit()
|
|||
|
if UIManager:IsVisiblePanel(EUIType.Inherit) then
|
|||
|
UIManager:ClosePanel(EUIType.Inherit)
|
|||
|
self:OnUpgradeRelatedButtonClicked()
|
|||
|
else
|
|||
|
if self.CanClickInherit then
|
|||
|
UIManager:ShowPanel(EUIType.Inherit)
|
|||
|
self:OnUpgradeRelatedButtonClicked()
|
|||
|
else
|
|||
|
-- 提示一下当前金钱不够
|
|||
|
UIManager:ShowGeneralNotice(string.format('金币不足3500,请收集足够金币再尝试。'))
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnResourceGradePanel()
|
|||
|
if UIManager:IsVisiblePanel(EUIType.ResourceGrade) then
|
|||
|
UIManager:ClosePanel(EUIType.ResourceGrade)
|
|||
|
else
|
|||
|
UIManager:ShowPanel(EUIType.ResourceGrade)
|
|||
|
end
|
|||
|
self:OnUpgradeRelatedButtonClicked()
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnClickSaveGame()
|
|||
|
if UIManager:IsVisiblePanel(EUIType.SaveGame) then
|
|||
|
UIManager:ClosePanel(EUIType.SaveGame)
|
|||
|
else
|
|||
|
UIManager:ShowPanel(EUIType.SaveGame)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnUpgradeRelatedButtonClicked() --关闭所有打开的提升按钮
|
|||
|
if self.bHasShowAttributeUpgrade then
|
|||
|
self:PlayUpgradeButtonAnimationByIndex(1, false)
|
|||
|
end
|
|||
|
if self.bHasShowResourceUpgrade then
|
|||
|
self:PlayUpgradeButtonAnimationByIndex(2, false)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnForceExpandUpgradeRelatedButtonByIndex(Index) --强行展开提升按钮
|
|||
|
if Index == 1 then
|
|||
|
self:OnAttributeUpgradeClicked()
|
|||
|
else
|
|||
|
self:OnResourceUpgradeClicked()
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnAttributeUpgradeClicked()
|
|||
|
for i = 2, 3 do
|
|||
|
--self[string.format("Panel_Button%d", i)]:SetVisibility(ESlateVisibility.HitTestInvisible)
|
|||
|
end
|
|||
|
--self:SetupUpgradeButtonStateByIndex(1)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnResourceUpgradeClicked()
|
|||
|
for i = 4, 5 do
|
|||
|
--self[string.format("Panel_Button%d", i)]:SetVisibility(ESlateVisibility.HitTestInvisible)
|
|||
|
end
|
|||
|
--self:SetupUpgradeButtonStateByIndex(2)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnForwardFadeIn1AnimationFinished()
|
|||
|
self.bHasShowAttributeUpgrade = true
|
|||
|
for i = 2, 3 do
|
|||
|
--self[string.format("Panel_Button%d", i)]:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnReverseFadeIn1AnimationFinished()
|
|||
|
self.bHasShowAttributeUpgrade = false
|
|||
|
for i = 2, 3 do
|
|||
|
--self[string.format("Panel_Button%d", i)]:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnForwardFadeIn2AnimationFinished()
|
|||
|
self.bHasShowResourceUpgrade = true
|
|||
|
for i = 4, 5 do
|
|||
|
--self[string.format("Panel_Button%d", i)]:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnReverseFadeIn2AnimationFinished()
|
|||
|
self.bHasShowResourceUpgrade = false
|
|||
|
for i = 4, 5 do
|
|||
|
--self[string.format("Panel_Button%d", i)]:SetVisibility(ESlateVisibility.Collapsed)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:SetupUpgradeButtonStateByIndex(Index)
|
|||
|
local CurToggle = Index == 1 and "bHasShowAttributeUpgrade" or "bHasShowResourceUpgrade"
|
|||
|
local CurFadeInAnim = Index == 1 and self.Button_FadeIn_1 or self.Button_FadeIn_2
|
|||
|
|
|||
|
if self[CurToggle] == true then
|
|||
|
if self:IsAnimationPlaying(CurFadeInAnim) and (not self:IsAnimationPlayingForward(CurFadeInAnim)) then
|
|||
|
self:CheckOtherUpgradeButtonStateByIndex(Index)
|
|||
|
self:ReversePlayingAnimationByIndex(Index, false)
|
|||
|
else
|
|||
|
self:PlayUpgradeButtonAnimationByIndex(Index, false)
|
|||
|
end
|
|||
|
else
|
|||
|
if self:IsAnimationPlaying(CurFadeInAnim) and self:IsAnimationPlayingForward(CurFadeInAnim) then
|
|||
|
self:ReversePlayingAnimationByIndex(Index, true)
|
|||
|
else
|
|||
|
self:CheckOtherUpgradeButtonStateByIndex(Index)
|
|||
|
self:PlayUpgradeButtonAnimationByIndex(Index, true)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
if Index == 1 then
|
|||
|
--NewPlayerGuideManager:RemoveGuide(9)
|
|||
|
NewPlayerGuideManager:RemoveGuide(10)
|
|||
|
NewPlayerGuideManager:RemoveGuide(11)
|
|||
|
else
|
|||
|
NewPlayerGuideManager:RemoveGuide(12)
|
|||
|
NewPlayerGuideManager:RemoveGuide(13)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:CheckOtherUpgradeButtonStateByIndex(Index)
|
|||
|
local OtherToggle = Index == 1 and "bHasShowResourceUpgrade" or "bHasShowAttributeUpgrade"
|
|||
|
local OtherFadeInAnim = Index == 1 and self.Button_FadeIn_2 or self.Button_FadeIn_1
|
|||
|
|
|||
|
if self[OtherToggle] == true then
|
|||
|
if self:IsAnimationPlaying(OtherFadeInAnim) and (not self:IsAnimationPlayingForward(OtherFadeInAnim)) then
|
|||
|
else
|
|||
|
self:PlayUpgradeButtonAnimationByIndex(Index == 1 and 2 or 1, false)
|
|||
|
end
|
|||
|
else
|
|||
|
if self:IsAnimationPlaying(OtherFadeInAnim) and self:IsAnimationPlayingForward(OtherFadeInAnim) then
|
|||
|
self:ReversePlayingAnimationByIndex(Index == 1 and 2 or 1, true)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:PlayUpgradeButtonAnimationByIndex(Index, bIsForward)
|
|||
|
local CurFadeInAnim, CurForwardFinishEvent, CurReverseFinishEvent = self:GetAnimationAndEventsByIndex(Index)
|
|||
|
|
|||
|
CurFadeInAnim.OnAnimationFinished:Remove(bIsForward and CurReverseFinishEvent or CurForwardFinishEvent, self)
|
|||
|
self:PlayAnimation(CurFadeInAnim, 0.0, 1, bIsForward and EUMGSequencePlayMode.Forward or EUMGSequencePlayMode.Reverse, 1)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:ReversePlayingAnimationByIndex(Index, bIsForwardPlaying)
|
|||
|
local CurFadeInAnim, CurForwardFinishEvent, CurReverseFinishEvent = self:GetAnimationAndEventsByIndex(Index)
|
|||
|
|
|||
|
CurFadeInAnim.OnAnimationFinished:Remove(bIsForwardPlaying and CurForwardFinishEvent or CurReverseFinishEvent, self)
|
|||
|
self:ReverseAnimation(CurFadeInAnim)
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:GetAnimationAndEventsByIndex(Index)
|
|||
|
local FadeInAnim = Index == 1 and self.Button_FadeIn_1 or self.Button_FadeIn_2
|
|||
|
local ForwardFinishEvent = Index == 1 and self.OnForwardFadeIn1AnimationFinished or self.OnForwardFadeIn2AnimationFinished
|
|||
|
local ReverseFinishEvent = Index == 1 and self.OnReverseFadeIn1AnimationFinished or self.OnReverseFadeIn2AnimationFinished
|
|||
|
|
|||
|
return FadeInAnim, ForwardFinishEvent, ReverseFinishEvent
|
|||
|
end
|
|||
|
|
|||
|
function WBP_InteractPanel:OnSelectBossClicked()
|
|||
|
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
|
|||
|
if WeaponComp.IsAttackNearestMonster then
|
|||
|
self.Image_SelectBoss:SetColorAndOpacity(ButtonTriggerColor.Normal)
|
|||
|
else
|
|||
|
self.Image_SelectBoss:SetColorAndOpacity(ButtonTriggerColor.Triggered)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
NewPlayerGuideManager:RemoveGuide(29)
|
|||
|
end
|
|||
|
|
|||
|
return WBP_InteractPanel;
|