示例#1
0
    public void StartMultiplayerHost()
    {
        CancelConnection();
        StartServer(3);
        client = ClientScene.ConnectLocalServer();
        LobbyClientHandler lobby = new LobbyClientHandler(this);

        OpenClientHandler(lobby);
        OpenScreen(new LobbyScreen(this, RB.DisplaySize, lobby));
    }
示例#2
0
 public LobbyScreen(Game game, Vector2i size, LobbyClientHandler lobby) : base(game, size)
 {
     playerCardPos        = new int[4];
     desiredPlayerCardPos = new int[4];
     lastPlayerCount      = 0;
     for (int i = 0; i < 4; i++)
     {
         playerCardPos[i] = desiredPlayerCardPos[i] = size.x / 2;
     }
     this.lobby = lobby;
 }
示例#3
0
 public void JoinMultiplayerHost(string ip)
 {
     CancelConnection();
     client = new NetworkClient();
     client.Configure(networkConfig, 1);
     client.RegisterHandler(MsgType.Connect, (msg) => {
         client.UnregisterHandler(MsgType.Connect);
         client.UnregisterHandler(MsgType.Error);
         LobbyClientHandler lobby = new LobbyClientHandler(this);
         OpenClientHandler(lobby);
         OpenScreen(new LobbyScreen(this, RB.DisplaySize, lobby));
     });
     client.RegisterHandler(MsgType.Error, (msg) => {
         client.UnregisterHandler(MsgType.Connect);
         client.UnregisterHandler(MsgType.Error);
         ShowMessage("Failed to connect: " + Enum.GetName(typeof(NetworkError), msg.ReadMessage <ErrorMessage>().errorCode), null);
     });
     client.Connect(ip, 4789);
 }