mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 15:01:53 +08:00
00c56484f4
为MultiplayerState类添加@tool注解以支持编辑器功能 在Starter面板中为连接状态文本添加"状态:"前缀
33 lines
877 B
GDScript
33 lines
877 B
GDScript
@tool
|
|
class_name MultiplayerState
|
|
|
|
enum ConnectionState {
|
|
DISCONNECTED,
|
|
CONNECTING,
|
|
CONNECTED_HOST,
|
|
CONNECTED_CLIENT,
|
|
}
|
|
static var stateTextMap = {
|
|
ConnectionState.DISCONNECTED: "未连接到服务器。",
|
|
ConnectionState.CONNECTING: "连接中...",
|
|
ConnectionState.CONNECTED_HOST: "服务器启动成功!",
|
|
ConnectionState.CONNECTED_CLIENT: "已连接到服务器!",
|
|
}
|
|
static var stateColorMap = {
|
|
ConnectionState.DISCONNECTED: Color.RED,
|
|
ConnectionState.CONNECTING: Color.YELLOW,
|
|
ConnectionState.CONNECTED_HOST: Color.GREEN,
|
|
ConnectionState.CONNECTED_CLIENT: Color.GREEN,
|
|
}
|
|
|
|
static var state: ConnectionState = ConnectionState.DISCONNECTED
|
|
static var isMultiplayer: bool = false
|
|
|
|
static var maxPlayer: int = 10
|
|
|
|
static func launchServer(port: int):
|
|
isMultiplayer = true
|
|
var peer = ENetMultiplayerPeer.new()
|
|
peer.create_server(port, maxPlayer)
|
|
return peer
|