X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=Project06%2FCS%203505%20Project%2006%2FCS%203505%20Project%2006%2FNetworkGame.cs;h=72a588cf62f6fcbab846b40794fd387dbf529a52;hb=0e2cd798178ca471d26ea33ee849365c3b9b593e;hp=2386ef60717983e77271ee1aa4a81a16683769c9;hpb=9187849a37e447f2440ef8257e15e8652f0c51e8;p=chaz%2Fcarfire diff --git a/Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs b/Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs index 2386ef6..72a588c 100644 --- a/Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs +++ b/Project06/CS 3505 Project 06/CS 3505 Project 06/NetworkGame.cs @@ -104,10 +104,17 @@ namespace CS_3505_Project_06 mNetworkSession = NetworkSession.EndCreate(result); mNetworkSession.AllowHostMigration = true; mNetworkSession.AllowJoinInProgress = false; - + mNetworkSession.GameStarted += new EventHandler(mNetworkSession_GameStarted); mJoinedSessionDelegate(mNetworkSession, this); } + + //gamestarted event + void mNetworkSession_GameStarted(object sender, GameStartedEventArgs e) + { + Reset(); + } + /// /// Determine whether or not the network game object is associated with any network session. /// @@ -160,6 +167,8 @@ namespace CS_3505_Project_06 mJoinedSessionDelegate(mNetworkSession, this); mJoinedSessionDelegate = null; + + mNetworkSession.GameStarted += new EventHandler(mNetworkSession_GameStarted); } @@ -232,25 +241,15 @@ namespace CS_3505_Project_06 if (mNetworkSession.SessionState == NetworkSessionState.Lobby) { mLobby.Update(gameTime, this); - - //if state started as lobby and was changed to playing, call reset. - if (mNetworkSession.SessionState == NetworkSessionState.Playing) - Reset(); } else if (mNetworkSession.SessionState == NetworkSessionState.Playing) { - //TODO reset needs to be called for all players, currently LocalGamerInfo throughs exception for all nonhosts - // because in start game reset is only called on hosts games thus other clients never get an updated list - // gamers. - - -//thoughs exeption see TODO above - //if (mGame.IsGameOver(LocalGamerInfo) || mGame.IsTerminated(LocalGamerInfo)) - //{ - // // TODO: Should support moving back to the session lobby. - // LeaveSession(); - // return; - //} + if (mGame.IsGameOver(LocalGamerInfo) || mGame.IsTerminated(LocalGamerInfo)) + { + // TODO: Should support moving back to the session lobby. + LeaveSession(); + return; + } if (HaveNeededEvents) {