156 lines
6.0 KiB
Lua
Raw Permalink Normal View History

2025-01-04 23:00:19 +08:00
TipConfig = TipConfig or {}
TipConfig.TipStyleType = {
Tip1 = 1;
Tip2 = 2;
Tip3 = 3;
Tip4 = 4;
Tip5 = 5;
}
TipConfig.TipStylePath = {
[TipConfig.TipStyleType.Tip1] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_Tip.WB_Tip_C'),
[TipConfig.TipStyleType.Tip2] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_Tip_2.WB_Tip_2_C'),
[TipConfig.TipStyleType.Tip3] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_Tip_3.WB_Tip_3_C'),
[TipConfig.TipStyleType.Tip4] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_Tip_4.WB_Tip_4_C'),
[TipConfig.TipStyleType.Tip5] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_Tip_5.WB_Tip_5_C'),
}
TipConfig.TipType = {
GameWillStart = 1,
EnergyDeficiency = 2,
MechanismOccupied = 3,
TriggerMechanism = 4,
UseMeleeToKill = 5,
PlayerCompleteGradient = 6,
OneMinuteRemaining = 7,
PlayerPickFakeKey = 8,
PlayerPickRealKey = 9,
DiscardsKeyFailure = 10,
SwapBronPoint = 11,
MiniGameIsSelected = 12,
SelectedMiniGameSucceed = 13,
UnlockStar = 14,
}
TipConfig.TipInfo = {
[TipConfig.TipType.GameWillStart] = {
Text = "游戏即将开始",
Style = TipConfig.TipStyleType.Tip1,
},
[TipConfig.TipType.EnergyDeficiency] = {
Text = "机关能量不足",
Style = TipConfig.TipStyleType.Tip2,
},
[TipConfig.TipType.MechanismOccupied] = {
Text = "机关已被占用",
Style = TipConfig.TipStyleType.Tip2,
},
[TipConfig.TipType.TriggerMechanism] = {
Text = function(PlayerKey, MechanismType)
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(PlayerKey)
local MechanismName = MechanismConfig.MechanismTypeName[MechanismType]
return string.format("%s触发了%s", PlayerName, MechanismName)
end,
Style = TipConfig.TipStyleType.Tip3,
SoundInfo = { SoundType = SoundSystem.ESound.ActiveMechanism, DelayActive = 0.2}
},
[TipConfig.TipType.UseMeleeToKill] = {
Text = "请使用非枪械武器淘汰玩家",
Style = TipConfig.TipStyleType.Tip2,
},
[TipConfig.TipType.PlayerCompleteGradient] = {
Text = function(PlayerKey)
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(PlayerKey)
return string.format("%s突破武器梯度 [+%s]", PlayerName, tostring(GlobalConfigs.GameSetting.FullGradientAddScore))
end,
Style = TipConfig.TipStyleType.Tip4,
SoundInfo = { SoundType = SoundSystem.ESound.Incentive, DelayActive = 0.2}
},
[TipConfig.TipType.OneMinuteRemaining] = {
Text = "游戏剩余1分钟",
Style = TipConfig.TipStyleType.Tip1,
},
[TipConfig.TipType.PlayerPickFakeKey] = {
Text = function(PlayerKey)
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(PlayerKey)
return string.format("%s排除了虚拟钥匙", PlayerName)
end,
Style = TipConfig.TipStyleType.Tip3,
SoundInfo = { SoundType = SoundSystem.ESound.Dissipate, DelayActive = 0.1}
},
[TipConfig.TipType.PlayerPickRealKey] = {
Text = function(PlayerKey)
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(PlayerKey)
return string.format("%s找到了真钥匙", PlayerName)
end,
Style = TipConfig.TipStyleType.Tip4,
SoundInfo = { SoundType = SoundSystem.ESound.Incentive, DelayActive = 0.2}
},
[TipConfig.TipType.DiscardsKeyFailure] = {
Text = "前方有阻挡物丢弃失败",
Style = TipConfig.TipStyleType.Tip3,
},
[TipConfig.TipType.SwapBronPoint] = {
Text = "队伍出生点调换",
Style = TipConfig.TipStyleType.Tip5,
},
[TipConfig.TipType.MiniGameIsSelected] = {
Text = "该玩法已被选择!",
Style = TipConfig.TipStyleType.Tip3,
},
[TipConfig.TipType.SelectedMiniGameSucceed] = {
Text = "选择成功!",
Style = TipConfig.TipStyleType.Tip3,
},
[TipConfig.TipType.UnlockStar] = {
Text = function(StarCount)
return string.format("解锁%s星成就", tostring(StarCount))
end,
Style = TipConfig.TipStyleType.Tip5,
SoundInfo = { SoundType = SoundSystem.ESound.KillFX, DelayActive = 0.2}
},
}
-- TipConfig.TipStyleType = UUserWidget
TipConfig.TipStyleInst = {}
--- 使用前需初始化
function TipConfig.Init(Controller)
if UE.IsValid(Controller) then
for i, v in pairs(TipConfig.TipInfo) do
if TipConfig.TipStyleInst[v.Style] == nil then
TipConfig.TipStyleInst[v.Style] = UserWidget.NewWidgetObjectBP(Controller, UE.LoadClass(TipConfig.TipStylePath[v.Style]))
TipConfig.TipStyleInst[v.Style]:AddToViewport(20000)
end
end
else
UGCLogSystem.LogError("[TipConfig_Init] Controller is not Valid")
end
UGCEventSystem.AddListener(EventEnum.AddTip, TipConfig.AddTip)
end
---@param TipConfig.TipType
function TipConfig.AddTip(InTipType, ...)
local Info = TipConfig.TipInfo[InTipType]
if Info then
local TempWidgetInst = TipConfig.TipStyleInst[Info.Style]
if Info.SoundInfo then
UGCEventSystem.SetTimer(UGCGameSystem.GameState, function() SoundSystem.PlaySound(Info.SoundInfo.SoundType) end, Info.SoundInfo.DelayActive)
end
if TempWidgetInst then
local TextType = type(Info.Text)
if TextType == "string" then
TempWidgetInst:AddTip(Info.Text)
elseif TextType == "function" then
TempWidgetInst:AddTip(Info.Text(...))
else
UGCLogSystem.LogError("[TipConfig_AddTip] 提示类型错误 TextType:%s", TextType)
end
else
UGCLogSystem.LogError("[TipConfig_AddTip] 没有生成提示UI")
end
else
UGCLogSystem.LogError("[TipConfig_AddTip] Info is nil. InTipType:%s", tostring(InTipType))
end
end