2025-01-18 21:26:02 +08:00

231 lines
8.8 KiB
Lua
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

TipConfig = TipConfig or {}
TipConfig.TipStyleType = {
Tip1 = 1;
Tip2 = 2;
Tip3 = 3;
Tip4 = 4;
Tip5 = 4;
Tip6 = 5;
FrontSightTip = 20;
TipLike = 100;
TipGodOfWarCome = 101;
TipKillingGod = 102;
}
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.TipStyleType.Tip6] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_Tip_6.WB_Tip_6_C'),
[TipConfig.TipStyleType.FrontSightTip] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_FrontSightTip.WB_FrontSightTip_C'),
[TipConfig.TipStyleType.TipLike] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_Tip_Like.WB_Tip_Like_C'),
[TipConfig.TipStyleType.TipGodOfWarCome] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_GodOfWarCome.WB_GodOfWarCome_C'),
[TipConfig.TipStyleType.TipKillingGod] = UGCGameSystem.GetUGCResourcesFullPath('Asset/UI/Tip/WB_KillingGod.WB_KillingGod_C'),
}
TipConfig.TipType = {
GameWillStart = 1,
ImportCodeCallBack = 2;
AddScore = 3;
OneMinuteRemaining = 4,
IncrementSucceed = 5; -- 增量成功
UnlockSucceed = 6; -- 解锁成功
ConsumablesInsufficient = 7; -- 消耗品不足
PlaceFailure = 8; -- 放置失败
NeedUnlock = 9;
ExchangeSucceed = 10; -- 兑换成功
CollectionSuccessful = 11; -- 收藏成功
PlayerBreakthrough = 12; -- 玩家突破
PlayerLike = 100; -- 玩家点赞
GodOfWarCome = 101; -- 战神降临
KillingGod = 102;-- 诛神
BeFatedNotToDieOwner = 200; -- 命不该绝触发者
BeFatedNotToDieCauser = 201; -- 命不该绝伤害者
}
TipConfig.TipInfo = {
[TipConfig.TipType.GameWillStart] = {
Text = "游戏即将开始",
Style = TipConfig.TipStyleType.Tip1,
},
[TipConfig.TipType.ImportCodeCallBack] = {
Text = function(DecodeCallBackType)
if DecodeCallBackType == PlacementModeConfig.EPlaceDecodeCallback.Succeed then
SoundSystem.PlaySound(SoundSystem.ESound.Btn)
return "导入成功"
else
SoundSystem.PlaySound(SoundSystem.ESound.Error)
return "代码错误 code:" .. tostring(DecodeCallBackType)
end
end,
Style = TipConfig.TipStyleType.Tip3,
},
[TipConfig.TipType.AddScore] = {
Text = function(AddScoreType)
-- 得分音效
PlacementModeConfig.AddScoreSound = {
[PlacementModeConfig.AddScoreType.KillAddScore] = SoundSystem.ESound.Kill3;
[PlacementModeConfig.AddScoreType.AssistAddScore] = SoundSystem.ESound.Kill;
[PlacementModeConfig.AddScoreType.DefendSucceedAddScore] = SoundSystem.ESound.PickUpBuff;
[PlacementModeConfig.AddScoreType.EnterDefenseLineAddScore] = SoundSystem.ESound.IsReady;
}
SoundSystem.PlaySound(PlacementModeConfig.AddScoreSound[AddScoreType])
return tostring(PlacementModeConfig.AddScoreName[AddScoreType]) .. " +" .. tostring(PlacementModeConfig.ScoreVal[AddScoreType])
end,
Style = TipConfig.TipStyleType.Tip5,
},
[TipConfig.TipType.OneMinuteRemaining] = {
Text = "游戏剩余1分钟",
Style = TipConfig.TipStyleType.Tip1,
},
[TipConfig.TipType.IncrementSucceed] = {
Text = "上限增加成功",
Style = TipConfig.TipStyleType.Tip5,
SoundInfo = { SoundType = SoundSystem.ESound.KillFX, DelayActive = 0.2}
},
[TipConfig.TipType.UnlockSucceed] = {
Text = "解锁成功",
Style = TipConfig.TipStyleType.Tip5,
SoundInfo = { SoundType = SoundSystem.ESound.KillFX, DelayActive = 0.2}
},
[TipConfig.TipType.ConsumablesInsufficient] = {
Text = function(UnlockType)
local ConsumablesName = PlacementModeConfig.UnlockName[UnlockType]
if ConsumablesName then
return ConsumablesName .. "不足"
else
return "消耗品不足"
end
end,
Style = TipConfig.TipStyleType.Tip3,
SoundInfo = { SoundType = SoundSystem.ESound.Error, DelayActive = 0.2}
},
[TipConfig.TipType.PlaceFailure] = {
Text = function(PlaceCallbackType)
local PlaceFailureName = PlacementModeConfig.PlaceCallbackName[PlaceCallbackType]
if PlaceFailureName then
return PlaceFailureName
else
return "放置失败"
end
end,
Style = TipConfig.TipStyleType.Tip3,
SoundInfo = { SoundType = SoundSystem.ESound.Error, DelayActive = 0.2}
},
[TipConfig.TipType.NeedUnlock] = {
Text = "请先解锁",
Style = TipConfig.TipStyleType.Tip3,
SoundInfo = { SoundType = SoundSystem.ESound.Error, DelayActive = 0.2}
},
[TipConfig.TipType.ExchangeSucceed] = {
Text = "兑换成功",
Style = TipConfig.TipStyleType.Tip5,
SoundInfo = { SoundType = SoundSystem.ESound.KillFX, DelayActive = 0.2}
},
[TipConfig.TipType.CollectionSuccessful] = {
Text = "收藏成功",
Style = TipConfig.TipStyleType.Tip3,
-- SoundInfo = { SoundType = SoundSystem.ESound.KillFX, DelayActive = 0.2}
},
[TipConfig.TipType.PlayerBreakthrough] = {
Text = function(PlayerKey)
return tostring(UGCGameSystem.GameState:GetPlayerNameByPlayerKey(PlayerKey)) .. "成功突破"
end,
Style = TipConfig.TipStyleType.Tip6,
-- SoundInfo = { SoundType = SoundSystem.ESound.KillFX, DelayActive = 0.2}
},
[TipConfig.TipType.PlayerLike] = {
Text = "",
Style = TipConfig.TipStyleType.TipLike,
},
[TipConfig.TipType.GodOfWarCome] = {
Text = function(InPlayerKey)
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(InPlayerKey);
return PlayerName
end,
Style = TipConfig.TipStyleType.TipGodOfWarCome,
},
[TipConfig.TipType.KillingGod] = {
Text = function(InPlayerKey)
local PlayerName = UGCGameSystem.GameState:GetPlayerNameByPlayerKey(InPlayerKey);
return PlayerName
end,
Style = TipConfig.TipStyleType.TipKillingGod,
},
[TipConfig.TipType.BeFatedNotToDieOwner] = {
Text = function (UseCount)
return "命不该绝 × " .. UseCount
end,
Style = TipConfig.TipStyleType.Tip5,
SoundInfo = { SoundType = SoundSystem.ESound.KillFX, DelayActive = 0.2}
},
[TipConfig.TipType.BeFatedNotToDieCauser] = {
Text = "命不该绝",
Style = TipConfig.TipStyleType.FrontSightTip,
-- 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