private void readNewJuggernaut() //Reads in who should be the new juggernaut. { string tag = reader.ReadString(); Global.msgNewJuggernaut(tag); //Fires off a message to the message displayer unit. NetworkGamer gamer = findGamerWithTag(tag); if (gamer.IsLocal) { LocalPlayer player = gamer.Tag as LocalPlayer; player.setAsJuggernaut(); for (int i = 0; i < Global.localPlayers.Count; i++) { if (Global.localPlayers[i] != player) { Global.localPlayers[i].setAsNotJuggernaut(); } } for (int i = 0; i < Global.remotePlayers.Count; i++) { Global.remotePlayers[i].setAsNotJuggernaut(); } } else { RemotePlayer rPlayer = gamer.Tag as RemotePlayer; rPlayer.setAsJuggernaut(); for (int i = 0; i < Global.localPlayers.Count; i++) { Global.localPlayers[i].setAsNotJuggernaut(); } for (int i = 0; i < Global.remotePlayers.Count; i++) //Loop for all remotes except the juggernaut { if (Global.remotePlayers[i] != rPlayer) { Global.remotePlayers[i].setAsNotJuggernaut(); } } } }
void GameStartedEventHandler(object sender, GameStartedEventArgs e) { if (hostSessionType == HostSessionType.Host) { int firstJugIndex = Global.rand.Next(0, Global.networkManager.networkSession.AllGamers.Count); NetworkGamer firstJug = networkSession.AllGamers[firstJugIndex]; newJuggernaut(firstJug); if (firstJug.IsLocal) { LocalPlayer player = firstJug.Tag as LocalPlayer; player.setAsJuggernaut(); } else { RemotePlayer player = firstJug.Tag as RemotePlayer; player.setAsJuggernaut(); } } Global.gameState = Global.GameState.Playing; Global.menusong.Stop(); Global.actionsong.Play(); }