/// <summary> /// Raised when the Live player signed in /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnLiveGamerSignedIn(object sender, SignedInEventArgs e) { var identifiedPlayer = new LiveIdentifiedPlayer(e.Gamer); LocalPlayers.Add(e.Gamer.PlayerIndex, identifiedPlayer); OnPlayerLogin(identifiedPlayer); }
/// <summary> /// Raised when a player joins the session /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnLivePlayerJoined(object sender, GamerJoinedEventArgs e) { IdentifiedPlayer identifiedPlayer = null; if (e.Gamer.IsLocal) { var localNetworkGamer = (LocalNetworkGamer)e.Gamer; IdentifiedPlayer[] localPlayersArray = new IdentifiedPlayer[SessionManager.LocalPlayers.Count]; SessionManager.LocalPlayers.Values.CopyTo(localPlayersArray, 0); for (int i = 0; i < localPlayersArray.Length; i++) { var localPlayer = localPlayersArray[i]; if (localPlayer.UniqueId == e.Gamer.Gamertag) { identifiedPlayer = new LiveIdentifiedPlayer(localPlayer.Input, localNetworkGamer); _localPlayers.Add(identifiedPlayer); _allPlayers.Add(identifiedPlayer); break; } } } else { NetworkGamer networkGamer = e.Gamer; identifiedPlayer = new LiveIdentifiedPlayer(networkGamer); _remotePlayers.Add(identifiedPlayer); _allPlayers.Add(identifiedPlayer); } OnPlayerJoined(identifiedPlayer); }
/// <summary> /// Raised when the Live player signed in /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnLiveGamerSignedIn(object sender, SignedInEventArgs e) { var identifiedPlayer = new LiveIdentifiedPlayer(e.Gamer); LocalPlayers.Add(e.Gamer.PlayerIndex, identifiedPlayer); OnPlayerLogin(identifiedPlayer); }
/// <summary> /// Raised when a player joins the session /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnLivePlayerJoined(object sender, GamerJoinedEventArgs e) { IdentifiedPlayer identifiedPlayer = null; if (e.Gamer.IsLocal) { var localNetworkGamer = (LocalNetworkGamer) e.Gamer; IdentifiedPlayer[] localPlayersArray = new IdentifiedPlayer[SessionManager.LocalPlayers.Count]; SessionManager.LocalPlayers.Values.CopyTo(localPlayersArray, 0); for (int i = 0; i < localPlayersArray.Length; i++) { var localPlayer = localPlayersArray[i]; if (localPlayer.UniqueId == e.Gamer.Gamertag) { identifiedPlayer = new LiveIdentifiedPlayer(localPlayer.Input, localNetworkGamer); _localPlayers.Add(identifiedPlayer); _allPlayers.Add(identifiedPlayer); break; } } } else { NetworkGamer networkGamer = e.Gamer; identifiedPlayer = new LiveIdentifiedPlayer(networkGamer); _remotePlayers.Add(identifiedPlayer); _allPlayers.Add(identifiedPlayer); } OnPlayerJoined(identifiedPlayer); }