Exemplo n.º 1
0
    void OnGUI()
    {
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        beginColumn();


        // if there is no game in progress we show buttons to setup a room
        if (!_isGameInProgress)
        {
            if (GUILayout.Button("Authenticate"))
            {
                PlayGameServices.authenticate();
            }


            GUILayout.Label("Room Creation");

            if (GUILayout.Button("Show Invitation Inbox"))
            {
                GPGMultiplayer.showInvitationInbox();
            }


            if (GUILayout.Button("Create Room Programmatically"))
            {
                GPGMultiplayer.createRoomProgrammatically(1, 1, 0);
            }


            if (GUILayout.Button("Show Player Selector"))
            {
                GPGMultiplayer.showPlayerSelector(1, 1);
            }
        }
        else
        {
            GUILayout.Label("In Real-time Match");

            if (GUILayout.Button("Leave Room"))
            {
                GPGMultiplayer.leaveRoom();
            }


            if (GUILayout.Button("Send Unreliable Message to All"))
            {
                var bytes = System.Text.Encoding.UTF8.GetBytes("howdy. current time: " + System.DateTime.Now);
                GPGMultiplayer.sendUnreliableRealtimeMessageToAll(bytes);
            }


            GUILayout.Space(40);

            GUILayout.Label(_lastReceivedMessage);
        }

        endColumn(false);
    }
Exemplo n.º 2
0
 private void onRoomJoinedOrCreated(GPGRoom room, GPGRoomUpdateStatus status)
 {
     if (status == GPGRoomUpdateStatus.STATUS_OK && room.hasData)
     {
         GPGMultiplayer.showWaitingRoom(int.MaxValue);
     }
     else
     {
         Debug.Log("An error occurred while joining or creating a room. Status: " + status);
     }
 }