108 lines
4.1 KiB
Lua
108 lines
4.1 KiB
Lua
TipConfig = TipConfig or {}
|
|
|
|
TipConfig.TipStyleType = {
|
|
Tip1 = 1;
|
|
Tip2 = 2;
|
|
Tip3 = 3;
|
|
Tip4 = 4;
|
|
}
|
|
|
|
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.TipType = {
|
|
GameWillStart = 1,
|
|
EnergyDeficiency = 2,
|
|
MechanismOccupied = 3,
|
|
TriggerMechanism = 4,
|
|
UseMeleeToKill = 5,
|
|
PlayerCompleteGradient = 6,
|
|
OneMinuteRemaining = 7,
|
|
}
|
|
|
|
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.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(EventTypes.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 |