UGCProjects/GZJ/Script/Global/NoticeTipsTools.lua

115 lines
4.6 KiB
Lua
Raw Normal View History

2025-01-08 22:46:12 +08:00
NoticeTipsTools = NoticeTipsTools or {}
NoticeTipsTools.HasRegPlayerController = false
---广播客户端显示UI(客户端发出无效)
function NoticeTipsTools.MulticastShowPanel(InUIType, ...)
local GameState = UGCGameSystem.GameState
if GameState == nil or UE.IsValid(GameState) == false or GameState:HasAuthority() == false then
return
end
UnrealNetwork.CallUnrealRPC_Multicast(GameState, "Client_MulticastRPC_ShowPanel", InUIType, ...)
end
---广播客户端关闭UI(客户端发出无效)
function NoticeTipsTools.MulticastClosePanel(InUIType)
local GameState = UGCGameSystem.GameState
if GameState == nil or UE.IsValid(GameState) == false or GameState:HasAuthority() == false then
return
end
UnrealNetwork.CallUnrealRPC_Multicast(GameState, "Client_MulticastRPC_ClosePanel", InUIType)
end
---广播客户端自定义事件(客户端发出无效)
function NoticeTipsTools.MulticastSendEvent(InEventType, ...)
local GameState = UGCGameSystem.GameState
if GameState == nil or UE.IsValid(GameState) == false or GameState:HasAuthority() == false then
return
end
UnrealNetwork.CallUnrealRPC_Multicast(GameState, "Client_MulticastRPC_SendEvent", InEventType, ...)
end
---服务器发出全体客户端广播普通通知(客户端发出无效)
---@param InText string 提示内容
---@param ShowAlert boolean 是否显示警告图标(可选,默认false)
---@param ShowTime number 提示时长(可选,默认2秒)
function NoticeTipsTools.MulticastGeneralNoticeTips(InText, ShowAlert, ShowTime)
local GameState = UGCGameSystem.GameState
if GameState == nil or UE.IsValid(GameState) == false or GameState:HasAuthority() == false then
return
end
if ShowAlert == nil then
ShowAlert = false
end
if ShowTime == nil then
ShowTime = 2.0
end
UnrealNetwork.CallUnrealRPC_Multicast_Unreliable(GameState, "Client_MulticastRPC_ShowGeneralNoticeTips", InText, ShowAlert, ShowTime)
end
---服务器发出全体客户端广播通知(客户端发出无效)
---@param InNoticeType ECustomNoticeType 指定提示内容
function NoticeTipsTools.MulticastNoticeTips(InNoticeType, ...)
local GameState = UGCGameSystem.GameState
if GameState == nil or UE.IsValid(GameState) == false or GameState:HasAuthority() == false then
return
end
UnrealNetwork.CallUnrealRPC_Multicast_Unreliable(GameState, "Client_MulticastRPC_ShowNoticeTips", InNoticeType, ...)
end
---服务器发出给特定客户端普通通知(客户端发出无效)
---@param PlayerKey number PlayerKey
---@param InText string 提示内容
---@param ShowAlert boolean 是否显示警告图标(可选,默认false)
---@param ShowTime number 提示时长(可选,默认2秒)
function NoticeTipsTools.ServerGeneralNoticeTips(PlayerKey, InText, ShowAlert, ShowTime)
local PlayerController = UGCGameSystem.GetPlayerControllerByPlayerKey(PlayerKey)
if PlayerController == nil or UE.IsValid(PlayerController) == false or PlayerController:HasAuthority() == false then
return
end
if ShowAlert == nil then
ShowAlert = false
end
if ShowTime == nil then
ShowTime = 2.0
end
UnrealNetwork.CallUnrealRPC_Unreliable(PlayerController, PlayerController, "ClientRPC_ShowGeneralNoticeTips", InText, ShowAlert, ShowTime)
end
---服务器发出给特定客户端通知(客户端发出无效)
---@param PlayerKey number PlayerKey
---@param InNoticeType ECustomNoticeType 指定提示内容
function NoticeTipsTools.ServerNoticeTips(PlayerKey, InNoticeType, ...)
local PlayerController = UGCGameSystem.GetPlayerControllerByPlayerKey(PlayerKey)
if PlayerController == nil or UE.IsValid(PlayerController) == false or PlayerController:HasAuthority() == false then
return
end
UnrealNetwork.CallUnrealRPC_Unreliable(PlayerController, PlayerController, "ClientRPC_ShowNoticeTips", InNoticeType, ...)
end
---@param NoticeType ECustomNoticeType
function NoticeTipsTools.ClientNoticeTips(NoticeType, ...)
if UIManager then
UIManager:ShowNotice(NoticeType, ...)
end
end
---指定客户端显示UI(客户端发出无效)
function NoticeTipsTools.ServerSendShowPanel(PlayerKey, InUIType, ...)
local PlayerController = UGCGameSystem.GetPlayerControllerByPlayerKey(PlayerKey)
if PlayerController == nil or UE.IsValid(PlayerController) == false or PlayerController:HasAuthority() == false then
return
end
UnrealNetwork.CallUnrealRPC(PlayerController, PlayerController, "ClientRPC_ShowPanel", InUIType, ...)
end
return NoticeTipsTools