简体   繁体   English

为Google Play游戏多人游戏创建不同的房间

[英]Create different rooms for Google Play game Multiplayer

I want to create three different rooms as follows: Room 1: All players want to play 10 coins match Room 2: All players want to play 50 coins match Room 3: All players want to play 100 coins match 我要创建三个不同的房间,如下所示:房间1:所有玩家都想玩10个硬币比赛房间2:所有玩家都想玩50个硬币比赛房间3:所有玩家都想玩100个硬币比赛

Now, if a player presses the match with 10 coins, only those players can join the room with different players (it's a 2 player match) not the all players pressed 50 coins or 100 coin match. 现在,如果一个玩家按下10个硬币进行比赛,那么只有那些玩家可以与其他玩家一起进入房间(这是2个玩家进行比赛),而不是所有按下50个硬币或100个硬币比赛的玩家。

Please let me know how I do this as the code: 请让我知道如何将其作为代码:

Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(1, 1, role);

Only sends the role to other players but all players can join the room, either presses the 10, 50 or 100 coin match. 仅将角色发送给其他玩家,但所有玩家都可以加入房间,按10、50或100硬币比赛。

Here is the answer to my own question, If someone also stuck here: 这是我自己的问题的答案,如果有人也卡在这里:

Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(1, 1, role);

Here 'role' represents the player role in the game, like for RPG game role maybe, Shooter, Snipper etc. 这里的“角色”代表游戏中的玩家角色,例如RPG游戏角色,例如Shooter,Snipper等。

Where, for the game variant as I want for the different game mode, set the variant type value as 'int' to the RoomConfig 'setVariant(variant)' as below: 对于我想在不同游戏模式下使用的游戏变体,将变体类型值设置为'int'RoomConfig'setVariant(variant)' ,如下所示:

RoomConfig roomConfig =
                RoomConfig.builder(mRoomUpdateCallback)
                        .setOnMessageReceivedListener(mMessageReceivedHandler)
                        .setRoomStatusUpdateCallback(mRoomStatusCallbackHandler)
                        .setAutoMatchCriteria(autoMatchCriteria)
                        .setVariant(variant)
                        .build();

This resolved my problem and works well for different game mode. 这解决了我的问题,并且适用于不同的游戏模式。

Now, In my game, the players playing for 10 coins match auto join for the 10 match players only. 现在,在我的游戏中,玩10个硬币比赛的玩家仅会自动加入10个比赛玩家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM