Google Play游戏实时多人游戏:获取参与者ID并将其存储到字符串中

时间:2018-10-10 11:22:43

标签: c# unity3d google-play-games multiplayer

我在我的统一游戏中第一次尝试使用Google实时多人游戏。 QuickMatch正常运行,我的意思是我可以使用以下方式获取连接的参与者的ID并将其存储到字符串中:

string MyId = PlayGamesPlatform.Instance.RealTime.GetSelf ().ParticipantId;

//string frndId = PlayGamesPlatform.Instance.RealTime.GetParticipant ();
//Get all opponent's ID
List<Participant> playerIDs = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants ();

if (MyId == playerIDs [0].ParticipantId) {

    oppoUsarname = playerIDs [1].DisplayName.ToString ();
    multiplayersName [1].text = "nothosting" + oppoUsarname;
    gameHost = true;

    OppoID = playerIDs [1].ParticipantId;

    OppoDN = playerIDs [1].DisplayName.ToString ();
} else {
    oppoUsarname = playerIDs [0].DisplayName.ToString ();
    multiplayersName [1].text = "gamehoster" + oppoUsarname;
    gameHost = false;
     OppoID = playerIDs [0].ParticipantId;
     OppoDN = playerIDs [0].DisplayName.ToString ();
}

在对手连接到房间之后,我可以显示他的displayname。但是对于CreateWithInvitationScreen,即使他们没有接受邀请或没有连接到会议室,我也想获得被邀请者(我是使用邀请屏幕邀请过的)参与者的ID。有人可以告诉我该怎么做吗? / p>

0 个答案:

没有答案