UGCProjects/GZJ/Script/UI/GM/WBP_GM.lua
2025-01-08 22:46:12 +08:00

169 lines
6.0 KiB
Lua

---@class WBP_GM_C:UUserWidget
---@field Button_AddCoin UButton
---@field Button_AddSkill UButton
---@field Button_AddTech UButton
---@field Button_ChangeTimeScale UButton
---@field Button_DecreaseCoin UButton
---@field Button_DecreaseTech UButton
---@field Button_DecreaseTimeScale UButton
---@field Button_GM UButton
---@field Button_IncreaseCoin UButton
---@field Button_IncreaseTech UButton
---@field Button_IncreaseTimeScale UButton
---@field ComboBox_SkillLevel UComboBoxString
---@field ComboBox_SkillName UComboBoxString
---@field Panel_GM UCanvasPanel
---@field TextBlock_CoinPoint UTextBlock
---@field TextBlock_TechPoint UTextBlock
---@field TextBlock_TimeScale UTextBlock
--Edit Below--
local WBP_GM = {
bInitDoOnce = false,
SelectedSkillName = "",
SelectedSkillLevel = 1,
SelectedCoinPoint = 10000,
SelectedTechPoint = 100,
SelectedTimeScale = 1.0
};
function WBP_GM:Construct()
self:LuaInit();
self.Panel_GM:SetVisibility(ESlateVisibility.Collapsed)
self.SelectedSkillLevel = "1"
self.SelectedSkillName = "Null"
self.ComboBox_SkillName:ClearOptions()
for i = ESkillName.Counter, ESkillName.Bombing do
local SkillNameStr = GameDataManager.GetSkillNameStrByName(i)
self.ComboBox_SkillName:AddOption(SkillNameStr)
end
self.ComboBox_SkillName:SetSelectedOption(self.SelectedSkillName)
end
-- [Editor Generated Lua] function define Begin:
function WBP_GM:LuaInit()
if self.bInitDoOnce then
return;
end
self.bInitDoOnce = true;
-- [Editor Generated Lua] BindingProperty Begin:
self.ComboBox_SkillName.OnOpening:Add(self.ComboBox_SkillName_OnOnOpening, self);
self.ComboBox_SkillName.OnSelectionChanged:Add(self.ComboBox_SkillName_OnSelectionChanged, self)
self.ComboBox_SkillLevel.OnSelectionChanged:Add(self.ComboBox_SkillLevel_OnSelectionChanged, self)
self.Button_GM.OnClicked:Add(self.Button_GM_OnClicked, self)
self.Button_AddSkill.OnClicked:Add(self.Button_AddSkill_OnClicked, self)
self.Button_AddCoin.OnClicked:Add(self.Button_AddCoin_OnClicked, self)
self.Button_IncreaseCoin.OnClicked:Add(self.Button_IncreaseCoin_OnClicked, self)
self.Button_DecreaseCoin.OnClicked:Add(self.Button_DecreaseCoin_OnClicked, self)
self.Button_AddTech.OnClicked:Add(self.Button_AddTech_OnClicked, self)
self.Button_IncreaseTech.OnClicked:Add(self.Button_IncreaseTech_OnClicked, self)
self.Button_DecreaseTech.OnClicked:Add(self.Button_DecreaseTech_OnClicked, self)
self.Button_ChangeTimeScale.OnClicked:Add(self.Button_ChangeTimeScale_OnClicked, self)
self.Button_IncreaseTimeScale.OnClicked:Add(self.Button_IncreaseTimeScale_OnClicked, self)
self.Button_DecreaseTimeScale.OnClicked:Add(self.Button_DecreaseTimeScale_OnClicked, self)
self.TextBlock_CoinPoint:BindingProperty("Text", self.TextBlock_CoinPoint_Text, self);
self.TextBlock_TechPoint:BindingProperty("Text", self.TextBlock_TechPoint_Text, self);
self.TextBlock_TimeScale:BindingProperty("Text", self.TextBlock_TimeScale_Text, self);
-- [Editor Generated Lua] BindingProperty End;
-- [Editor Generated Lua] BindingEvent Begin:
-- [Editor Generated Lua] BindingEvent End;
end
function WBP_GM:ComboBox_SkillName_OnOnOpening()
self.ComboBox_SkillName:SetSelectedOption(self.SelectedSkillName)
end
function WBP_GM:ComboBox_SkillName_OnSelectionChanged(SelectedItem, SelectionType)
self.SelectedSkillName = SelectedItem
end
function WBP_GM:ComboBox_SkillLevel_OnSelectionChanged(SelectedItem, SelectionType)
self.SelectedSkillLevel = SelectedItem
end
function WBP_GM:Button_GM_OnClicked()
if self.Panel_GM:IsVisible() then
self.Panel_GM:SetVisibility(ESlateVisibility.Collapsed)
else
self.Panel_GM:SetVisibility(ESlateVisibility.SelfHitTestInvisible)
end
end
function WBP_GM:Button_AddSkill_OnClicked()
local SkillName = ESkillName.Default
local SkillLevel = tonumber(self.SelectedSkillLevel)
for Name, SkillInfo in pairs(GlobalConfigs.SkillInfo) do
if SkillInfo.Name == self.SelectedSkillName then
SkillName = Name
end
end
if SkillName ~= ESkillName.Default and SkillLevel > 0 then
local ItemData = {
ItemID = 20000 + SkillLevel * 10 + SkillName * 100,
ItemCount = 1,
}
local PC = GameDataManager.GetLocalPlayerController()
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_GM_AddItems", {ItemData})
end
end
function WBP_GM:Button_AddCoin_OnClicked()
local PC = GameDataManager.GetLocalPlayerController()
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_GM_AddCoinPoint", self.SelectedCoinPoint)
end
function WBP_GM:Button_IncreaseCoin_OnClicked()
self.SelectedCoinPoint = math.floor(math.clamp(self.SelectedCoinPoint + 10000, 10000, 1000000))
end
function WBP_GM:Button_DecreaseCoin_OnClicked()
self.SelectedCoinPoint = math.floor(math.clamp(self.SelectedCoinPoint - 10000, 10000, 1000000))
end
function WBP_GM:Button_AddTech_OnClicked()
local PC = GameDataManager.GetLocalPlayerController()
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_GM_AddTechPoint", self.SelectedTechPoint)
end
function WBP_GM:Button_IncreaseTech_OnClicked()
self.SelectedTechPoint = math.floor(math.clamp(self.SelectedTechPoint + 100, 100, 100000))
end
function WBP_GM:Button_DecreaseTech_OnClicked()
self.SelectedTechPoint = math.floor(math.clamp(self.SelectedTechPoint - 100, 100, 100000))
end
function WBP_GM:Button_ChangeTimeScale_OnClicked()
local PC = GameDataManager.GetLocalPlayerController()
UnrealNetwork.CallUnrealRPC(PC, PC, "ServerRPC_GM_ChangeTimeScale", self.SelectedTimeScale)
end
function WBP_GM:Button_IncreaseTimeScale_OnClicked()
self.SelectedTimeScale = math.floor(math.clamp(self.SelectedTimeScale + 1.0, 1.0, 10.0))
end
function WBP_GM:Button_DecreaseTimeScale_OnClicked()
self.SelectedTimeScale = math.floor(math.clamp(self.SelectedTimeScale - 1.0, 1.0, 10.0))
end
function WBP_GM:TextBlock_CoinPoint_Text(ReturnValue)
return string.format("%d", math.floor(self.SelectedCoinPoint))
end
function WBP_GM:TextBlock_TechPoint_Text(ReturnValue)
return string.format("%d", math.floor(self.SelectedTechPoint))
end
function WBP_GM:TextBlock_TimeScale_Text(ReturnValue)
return string.format("x%d", math.floor(self.SelectedTimeScale))
end
-- [Editor Generated Lua] function define End;
return WBP_GM;