예제 #1
0
    public override void _Ready()
    {
        GetTree().Connect("network_peer_connected", this, nameof(PlayerConnected));
        GetTree().Connect("network_peer_disconnected", this, nameof(PlayerDisconnected));
        GetTree().Connect("connected_to_server", this, nameof(ConnectedToServer));
        GetTree().Connect("connection_failed", this, nameof(ConnectionFailed));
        GetTree().Connect("server_disconnected", this, nameof(ServerDisconnected));

        HostButton = (Button)GetNode("MarginContainer/VBoxContainer/HostGameButton");
        HostButton.Connect("pressed", this, nameof(HostGame));

        JoinButton = (Button)GetNode("MarginContainer/VBoxContainer/JoinGameButton");
        JoinButton.Connect("pressed", this, nameof(JoinGame));

        LeaveButton = (Button)GetNode("MarginContainer/VBoxContainer/LeaveGameButton");
        LeaveButton.Connect("pressed", this, nameof(LeaveGame));
        LeaveButton.Disabled = true;

        AddressText = (TextEdit)GetNode("MarginContainer/VBoxContainer/Address");
        NameText    = (TextEdit)GetNode("MarginContainer/VBoxContainer/Name");
    }