Ejemplo n.º 1
0
    public void CreateNewRoom()
    {
        GUI.ShowNewGamePopup((bool ok, string gameName) =>
        {
            if (ok)
            {
                roomData_       = new RoomCustomData();
                roomData_.name  = gameName;
                roomData_.team1 = new TeamCustomData();
                roomData_.team2 = new TeamCustomData();
                roomData_.team1.players.Add(NetworkClient.Lobby.PlayerId);

                // use the serializable roomData_ object as room's custom data.
                NetworkClient.Lobby.CreateRoom(roomData_, true, 4, (successful, reply, error) =>
                {
                    if (successful)
                    {
                        Debug.Log("Room created " + reply);
                        // refresh the room list
                        GetRooms();

                        // refresh the player list
                        GetPlayersInCurrentRoom();
                    }
                    else
                    {
                        Debug.Log("Failed to create room " + error);
                    }
                });
            }
        });
    }
Ejemplo n.º 2
0
    public void GetRooms()
    {
        // Get the rooms for the current page.
        NetworkClient.Lobby.GetRooms(currentRoomPageIndex_, 6, (successful, reply, error) =>
        {
            if (successful)
            {
                Debug.Log("Got rooms " + reply);

                // Remove rooms in the rooms list
                GUI.ClearRoomList();

                foreach (SWRoom room in reply.rooms)
                {
                    Debug.Log(room);
                    // Deserialize the room custom data.
                    RoomCustomData rData = room.GetCustomData <RoomCustomData>();
                    if (rData != null)
                    {
                        // Add rooms to the rooms list.
                        GUI.AddRowForRoom(rData.name, room.id, OnRoomSelected);
                    }
                }
            }
            else
            {
                Debug.Log("Failed to get rooms " + error);
            }
        });
    }
Ejemplo n.º 3
0
    void Lobby_OnRoomCustomDataChangeEvent(SWRoomCustomDataChangeEventData eventData)
    {
        Debug.Log("Room custom data changed: " + eventData);

        SWRoom room = NetworkClient.Lobby.RoomData;

        roomData_ = room.GetCustomData <RoomCustomData>();

        // Room custom data changed, refresh the player list.
        RefreshPlayerList();
    }
Ejemplo n.º 4
0
    public void GetRoomCustomData()
    {
        NetworkClient.Lobby.GetRoomCustomData((successful, reply, error) =>
        {
            if (successful)
            {
                Debug.Log("Got room custom data " + reply);

                // Deserialize the room custom data.
                roomData_ = reply.GetCustomData <RoomCustomData>();
                if (roomData_ != null)
                {
                    RefreshPlayerList();
                }
            }
            else
            {
                Debug.Log("Failed to get room custom data " + error);
            }
        });
    }