It looks to me like Apple was in a bit of a hurry to implement GameCenter. Maybe I am overlooking something.
If you create a game where you want to offer in-app purchases (say you want to sell additional maps or add ons), is there any way at all to match players who share the same maps (plural) using GKMatchRequest? i.e. whose in-app purchases overlap, but are not the exact same.
Or maybe you want to sell c开发者_如何学运维ars in a race game. How can you match players who share some of their cars, not necessarily all of them? I think you can't, because the playerGroup property in a GKMatchRequest compares only if users belong to the same group.
So if one user buys map A and map B and another user buys map B and map C, there is no way to match them, although they could be playing map B together. Of course you could implement your interface so that users have to specify which map they want to play on. But there are other scenarios where an in-app purchase might not be an either/or question, but might be combined in a game (e.g. if you can buy different soldier types in a battle game and then match players who share some of their soldier types... in the game itself you could then implement logic to exclude those types the players do not share).
Can anyone think of a solution that works?
In the map case, I think you would need to let the user choose the map first. Otherwise, say you match two players and they have maps B, C, and E in common. Now you need a way for them to agree on what map to play on. Maybe player 1 intended to play map B and player 2 wanted map E. Even if they share a subset, now you have to do the work that could have been done in the matching process.
In the cars case, I think you need to ask why you want to compare players this way. If it is simply out of fairness (so you don't match someone with powerful cars against a newbie) then you can create a "level" based on top car speed. Maybe you will match people with different sets of cars, but they can be evenly matched.
Finally, if the players absolutely need to have a matching thing, make a best effort using the previous suggestion, and if they don't, pop up a message saying, "Hey, you don't have any matching cars. Want to buy this one so you can play together?" Offer to buy it now or find another player. You might make some sales this way.
P.S. Sorry to be preachy, but it's not fair to say Apple did a half-a***d job. Game Center is a system that must scale up to millions of users, who want to find matches more or less instantly. Attempting to match by overlapping subsets would add a significant amount of complexity to the system, and I don't think you are appreciating the cost of such a design.
It sucks that can't do exactly what you need, but it's a poor attitude to assume the shortcomings are due to incompetence.
Here's another dilemma with supporting both In-app purchases and Game Center (please respond in the comments).
Say my game includes in-app purchases for ten individual puzzle packs and my game also includes a free multiplayer mode using Game Center. At any time, a single iOS device has an iTunes store account logged in and this is the account that is used for determining the status of all in-app purchases for my app. If a user logs out of their iTunes store account on a single device and a new user logs into their iTunes store account on the same device (using the "Store" tab in the settings application), then the status of in-app purchases for my app will be updated for the newly logged in iTunes store user. Perfect! Now what happens if my app uses Game Center to allow different users to use the same app? It seems suddenly you have two different types of user accounts for a single app. One account for Game Center and one account for the iTunes store, correct? For exmaple, if user1 logged into my app using Game Center and bought three puzzle packs, then those puzzle packs would be charged to whatever iTunes account is currently logged in on the device. If user1 logs out of Game Center and user2 logs into Game Center, won't the iTunes account that is currently logged in remain the same, meaning user2 will have access to the puzzle packs bought by user 1? Doesn't that also mean user2 can purchase additional puzzle packs under the same iTunes account that user1 used?
Even worse, what if I want to create Game Center achievements based on completing a purchased puzzle pack? Suddenly, different Game Center users would receive the achievements for puzzle packs they didn't solve since they share the same puzzle pack state, right?
In "Game Kit Programming Guide > Multiplayer > Player Groups", they state that "typically, your game should present its own user interface to allow the player to select parameters that are used to calculate the player group number." I guess they didn't planned to permit this kind of restriction you need.
I can only see four options:
- Use a "demo version" of the map (i.e. if a user bought map A, it will allow him to "host" a match on A, wherever guest players bought A or not). If your game can also play as single player, it may be used as some kind of advertising for guests.
- Create your own server. This is evil and obscure, but I guess you can make any kind of matching rule this way.
- "Reject" a player that didn't bought the map (never tested, but I guess it will be unpleasant for the rejected player).
- Create "groups of maps". Using the car's example (adapted to motorcycles), there could be a 100cc group, a 250cc group, and so on. People could by "A" (100cc) and compete against players that bought "B" (also 100cc). With maps, could be "water maps", "winter maps", and so on. This will add value to the purchase and make things easy for us. But I guess this will require some UI coding, too.
Considering the maximum number of players is only 4, I don't think Apple prepared Game Center to host complex games. Maybe it's just like OpenGLES: great tool, but you must be a super-hardcore-developer to make something uber-cool like the Unreal Engine's Epic Citadel (not available on Brazil's App Store - sadly).
精彩评论