具有不同角色的实时多人游戏的Google Play游戏

迪帕克·戈亚尔

我创建一个游戏程序objective-c,其使用Google Play Game servicesrealtime Multiplayer功能。在应用程序中,用户必须在开始游戏之前下注一些硬币,我们希望连接的用户必须下注相同数量的硬币。我遵循https://developers.google.com/games/services/ios/realtimeMultiplayer 上的文档该应用程序在搜索实时玩家时运行良好,而无需每个玩家的特定角色,例如拥有不同硬币的玩家。

- (void)createQuickStartRoom {
    GPGMultiplayerConfig *config = [[GPGMultiplayerConfig alloc] init];
    // Could also include variants or exclusive bitmasks here
    config.minAutoMatchingPlayers = totalPlayers - 1;
    config.maxAutoMatchingPlayers = totalPlayers - 1;

    // Show waiting room UI
    [[GPGLauncherController sharedInstance] presentRealTimeWaitingRoomWithConfig:config];
}

但是我想搜索具有相同角色的玩家,就像每个玩家在我的应用中花费了相同数量的硬币一样。

static uint64_t const ROLE_COIN_10 = 0x1; // 001 in binary
static uint64_t const ROLE_COIN_20 = 0x2; // 010 in binary
static uint64_t const ROLE_COIN_50 = 0x4; // 100 in binary

- (void)createQuickStartRoomWithRole:(uint64_t)role  {
    GPGMultiplayerConfig *config = [[GPGMultiplayerConfig alloc] init];

    // auto-match with two random auto-match opponents of different roles
    config.minAutoMatchingPlayers = 2;
    config.maxAutoMatchingPlayers = 2;
    config.exclusiveBitMask = role;

    // create room, etc.
    // …
}

但是,找不到所需的玩家具有相同的角色。它仍然提供具有不同作用的实时播放器。请让我知道,如何实现此功能。谢谢。

克莱顿·威尔金森

您想使用变体字段来匹配请求相同(非零)值的玩家。在您的示例中,将变体设置为硬币数量。独占位掩码用于匹配不同的类型。例如,如果您需要一场比赛的“进攻”和“防守”。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章