Saturday, 7 April 2012

Dream.Build.Play: Trying to Connect the World




This week I have been contemplating whether to start implementing online play into the game or if I should wait until further in the development to start implementing it. After reading various posts on my phone on a very long train ride over the weekend, it was recommended that it would be easier to implement online play from the beginning instead of shoe-horning it in further in the development cycle. So over the week I have designed and developed a generic solution for wrapping XNA's network session to help with the sending and reading of online based packets. It was also recommended that the same code base should exist for both on and offline gameplay. However, this possed a problem with what I wanted to implement.

My idea was to have players drop in and out of the online "lobby". This is fine as when players join the network session they are added to an accessable collection. However my idea was to have a number of players on the same console the ability to join a given online session, so online play could consist of a mixture of remote and local players. This is fine when players want to join a session on a given console, as a method for adding local players exists. But what happens if that said player then decides they don't want to play? This wouldn't be a problem if a RemoveLocalPlayer method existed, but it doesn't. Local play is fine as there is only ever going to be local players (maximum of 4 in the session and maximum of 4 on a console), so I can look at other variables to determine which players are actually "active" in the session. But for an online game I can't leave that now gone local player attached to the session because this will stop new players from being able to join, as according to NetworkSession it has the maximum number of players. The reasoning behind this needed method not existing according to shawn was because of only two scenarios existing for a player leaving. He says usually either a single player wants to leave so they sign out (which NetworkSession then removes said player from the session), or all parties on the console want to leave and hense they destroy their session. Becuse of this limitation I have had to come up with a disjointed solution between offline and online play. In the offline scenario players can join and leave as they please with their presence still being attached to the session. This is fine as I have other means to determine active players. In online play, when a player attempts to leave they will be greeted with a message saying that they need to sign out in order to leave. NetworkSession will then deal with this and remove the local player freeing up space for other players to join. Yuck!

Having online and offline play joined by a single code base has also lead me to another design choice. In the beginning I wanted players to be able to join a game without having to sign in. Unfortuantely in order for a player to join a NetworkSession, that said player must be signed into a profile (local or live enabled). So now my game requires the player to sign into any profile for offline play and a live enabled profile (even if it's as a guest) for online play. On the plus side I have still managed to keep the ability for players to choose a random avatar if their own avatar is really that bad :)

So that's what progress has been made this week. No new screenshots unfortunately as it all looks pretty much the same as last week. Also, no further progress will be made this week as I'm away from my computer for the Easter holidays. Hope you all have a good Easter.

No comments:

Post a comment

Got an opinion? Who hasn't? Post it here...