/// <summary> /// Creates a new instance /// </summary> /// <param name="signedInGamer">The Xbox Live player SignedInGamer instance</param> internal LiveIdentifiedPlayer(SignedInGamer signedInGamer) : base(Application.Input.GetPlayerInput(signedInGamer.PlayerIndex)) { LiveGamer = signedInGamer; UniqueId = signedInGamer.Gamertag; DisplayName = signedInGamer.Gamertag; }
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); if (entered) { SignedInGamer gamer = Gamer.SignedInGamers[entryIndex]; if ((gamer == null || gamer.IsGuest) && !Guide.IsVisible) { try { Guide.ShowSignIn(4, false); } catch { Console.WriteLine("caught ya"); } } else { (Manager.Game as Game1).needStorageDevice = true; (Manager.Game as Game1).ControllingIndex = entryIndex; ExitScreen(); Manager.AddScreen(new MainMenuScreen("Super Fish Hunter!"), entryIndex); entered = false; } return; } }
public void writeToLeaderboard( int leaderboardID, int score, TimeSpan time, bool win, LeaderboardKey key) { SignedInGamer gamer = XNAConnect.getGamer(); if (gamer == null) { return; } if (TheSims3.IsTrialMode) { return; } try { //LeaderboardIdentity leaderboardId = LeaderboardIdentity.Create(key, leaderboardID); //LeaderboardEntry leaderboard = gamer.LeaderboardWriter.GetLeaderboard(leaderboardId); //leaderboard.Rating = !Scene.IsScoreLeaderboard(leaderboardID) ? (long) time.TotalMinutes : (long) score; //leaderboard.Columns.SetValue("Outcome", win ? LeaderboardOutcome.Win : LeaderboardOutcome.Loss); } //catch (GameUpdateRequiredException ex) //{ // XNAConnect.PromptForUpdate(); //} catch (Exception ex) { } }
public void AddLocalGamer(SignedInGamer signedInGamer) { if (IsDisposed) { throw new ObjectDisposedException("NetworkSession"); } if (localGamerFromSignedInGamer.ContainsKey(signedInGamer)) { return; } if (pendingSignedInGamers.Contains(signedInGamer)) { // Already waiting to join return; } if (GetOpenSlotsForMachine(localMachine) > 0) { pendingSignedInGamers.Add(signedInGamer); SendGamerIdRequest(); } }
// Token: 0x06000065 RID: 101 RVA: 0x0000BF5C File Offset: 0x0000A15C public void AwardAchievement(string achievementKey) { SignedInGamer signedInGamer = Gamer.SignedInGamers[PlayerIndex.One]; if (signedInGamer == null) { return; } lock (this.achievementsLockObject) { if (this.achievements != null) { foreach (Achievement achievement in this.achievements) { if (achievement.Key == achievementKey) { if (!achievement.IsEarned) { signedInGamer.BeginAwardAchievement(achievementKey, new AsyncCallback(this.AwardAchievementCallback), signedInGamer); } break; } } } } }
public void readLeaderboard(int leaderboardID, LeaderboardKey key) { this.LeaderboardsRead = (XNAConnect.LeaderboardResult)null; if (TheSims3.IsTrialMode) { return; } SignedInGamer gamer = XNAConnect.getGamer(); if (gamer == null) { return; } LeaderboardIdentity leaderboardIdentity = LeaderboardIdentity.Create(key, leaderboardID); this.LeaderboardsRead = new XNAConnect.LeaderboardResult(leaderboardIdentity); try { //LeaderboardReader.BeginRead(leaderboardIdentity, (Gamer)gamer, 20, new AsyncCallback(this.LeaderboardCallback), (object)gamer); } //catch (GameUpdateRequiredException ex) //{ // XNAConnect.PromptForUpdate(); //} catch (Exception ex) { XNAConnect.NotifyConnectionLost(); } }
// Token: 0x06000067 RID: 103 RVA: 0x0000C050 File Offset: 0x0000A250 public void LoadLeaderboardEntries() { SignedInGamer signedInGamer = Gamer.SignedInGamers[PlayerIndex.One]; int num = ObjectSystem.globalVariables[114]; try { LeaderboardIdentity leaderboardId; if (num == 0) { leaderboardId = LeaderboardIdentity.Create(LeaderboardKey.BestScoreLifeTime, num); } else { leaderboardId = LeaderboardIdentity.Create(LeaderboardKey.BestTimeLifeTime, num + 1); } GlobalAppDefinitions.gameMode = 7; LeaderboardReader.BeginRead(leaderboardId, signedInGamer, 100, new AsyncCallback(this.LeaderboardReadCallback), signedInGamer); } catch (GameUpdateRequiredException e) { this.ReadNullLeaderboardEntries(); this.HandleGameUpdateRequired(e); } catch (Exception) { this.ReadNullLeaderboardEntries(); Guide.BeginShowMessageBox("Xbox LIVE", EngineCallbacks.liveErrorMessage[(int)GlobalAppDefinitions.gameLanguage], new string[] { "OK" }, 0, MessageBoxIcon.Alert, new AsyncCallback(EngineCallbacks.LiveErrorMessage), null); } }
/// <summary> /// Helper checks whether a valid player profile is signed in. /// </summary> bool ValidProfileSignedIn() { // If there is no profile signed in, that is never good. SignedInGamer gamer = Gamer.SignedInGamers[ControllingPlayer.Value]; if (gamer == null) { return(false); } // If we want to play in a Live session, also make sure the profile is // signed in to Live, and that it has the privilege for online gameplay. if (NetworkSessionComponent.IsOnlineSessionType(sessionType)) { if (!gamer.IsSignedInToLive) { return(false); } if (!gamer.Privileges.AllowOnlineSessions) { return(false); } } // Okeydokey, this looks good. return(true); }
internal static int GetHostingGamerIndex(IEnumerable <SignedInGamer> localGamers) { SignedInGamer signedInGamer1 = (SignedInGamer)null; if (localGamers == null) { throw new ArgumentNullException("localGamers"); } foreach (SignedInGamer signedInGamer2 in localGamers) { if (signedInGamer2 == null) { throw new ArgumentException("gamer can not be null in list of localGamers."); } if (signedInGamer2.IsDisposed) { throw new ObjectDisposedException("localGamers", "A gamer is disposed in the list of localGamers"); } if (signedInGamer1 == null) { signedInGamer1 = signedInGamer2; } } if (signedInGamer1 == null) { throw new ArgumentException("Invalid gamer in localGamers."); } else { return((int)signedInGamer1.PlayerIndex); } }
internal static int GetHostingGamerIndex(IEnumerable <SignedInGamer> localGamers) { SignedInGamer hostGamer = null; if (localGamers == null) { throw new ArgumentNullException("localGamers"); } foreach (SignedInGamer gamer in localGamers) { if (gamer == null) { throw new ArgumentException("gamer can not be null in list of localGamers."); } if (gamer.IsDisposed) { throw new ObjectDisposedException("localGamers", "A gamer is disposed in the list of localGamers"); } if (hostGamer == null) { hostGamer = gamer; } } if (hostGamer == null) { throw new ArgumentException("Invalid gamer in localGamers."); } return((int)hostGamer.PlayerIndex); }
public void AddLocalGamer(SignedInGamer gamer) { if (gamer == null) { throw new ArgumentNullException("gamer"); } }
/// <summary> /// Screen-specific update to gamer rich presence. /// </summary> public override void UpdatePresence() { if (!IsExiting && (networkSession != null)) { bool isTied = (world.HighScorers.Count > 1); for (int i = 0; i < networkSession.AllGamers.Count; ++i) { NetworkGamer networkGamer = networkSession.AllGamers[i]; if (networkGamer.IsLocal) { SignedInGamer signedInGamer = (networkGamer as LocalNetworkGamer).SignedInGamer; if (signedInGamer.IsSignedInToLive) { if (world.HighScorers.Contains(i)) { if (isTied) { signedInGamer.Presence.PresenceMode = GamerPresenceMode.ScoreIsTied; } else { signedInGamer.Presence.PresenceMode = GamerPresenceMode.Winning; } } else { signedInGamer.Presence.PresenceMode = GamerPresenceMode.Losing; } } } } } }
public void ReadProfile(SignedInGamer gamer) { if (!gamer.IsGuest) { Main.AchievementSystem.GetEarnedAchievements(gamer, UpdateTriggerChecks); } }
/// <summary> /// Raised when a player leaves /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnLivePlayerLeft(object sender, GamerLeftEventArgs e) { IdentifiedPlayer identifiedPlayer = null; if (e.Gamer.IsLocal) { SignedInGamer signedInGamer = ((LocalNetworkGamer)e.Gamer).SignedInGamer; _localPlayers.ForEach(action => { if (action.UniqueId == signedInGamer.Gamertag) { identifiedPlayer = action; _localPlayers.Remove(action); _allPlayers.Remove(action); } }); } else { _remotePlayers.ForEach(action => { if (action.UniqueId == e.Gamer.Gamertag) { identifiedPlayer = action; _remotePlayers.Remove(action); _allPlayers.Remove(action); } }); } OnPlayerLeft(identifiedPlayer); }
public static void SetPresenceMode(this PlayerIndex player, GamerPresenceMode presenceMode) { SignedInGamer gamer = Gamer.SignedInGamers[player]; if (gamer != null) { gamer.Presence.PresenceMode = presenceMode; } }
/// <summary> /// Returns true if the PlayerIndex is allowed to purchase content from the marketplace /// </summary> public static bool CanBuyGame(this PlayerIndex player) { SignedInGamer gamer = Gamer.SignedInGamers[player]; if (gamer == null) { return(false); } return(gamer.Privileges.AllowPurchaseContent); }
public void GetEarnedAchievements(SignedInGamer gamer, EarnedAchievementsCallback callback) { EarnedAchievementsData earnedAchievementsData = new EarnedAchievementsData(); earnedAchievementsData.Callback = callback; earnedAchievementsData.Gamer = gamer; EarnedAchievementsData asyncState = earnedAchievementsData; gamer.BeginGetAchievements(ProcessEarnedAchievements, asyncState); }
// Token: 0x06000066 RID: 102 RVA: 0x0000C018 File Offset: 0x0000A218 protected void AwardAchievementCallback(IAsyncResult result) { SignedInGamer signedInGamer = result.AsyncState as SignedInGamer; if (signedInGamer != null) { signedInGamer.EndAwardAchievement(result); signedInGamer.BeginGetAchievements(new AsyncCallback(this.GetAchievementsCallback), signedInGamer); } }
/// <summary> /// Retrieves a value indicating whether the player can buy the game, /// e.g. if the signed in player has the privileges and the game is in /// trial mode. /// </summary> /// <param name="player">The player index.</param> /// <returns>true if the player can buy the game; false otherwise.</returns> public static bool CanBuyGame(this PlayerIndex player) { SignedInGamer gamer = Gamer.SignedInGamers[player]; return (gamer != null && gamer.IsSignedInToLive == true && Guide.IsTrialMode == true && gamer.Privileges.AllowPurchaseContent); }
public PlayerProfile(SignedInGamer MyGamer, BasicController MyController, ControllerIndex controllerIndex) { if (MyGamer != null) { PlayerName = MyGamer.DisplayName; } this.MyGamer = MyGamer; this.MyController = MyController; this.controllerIndex = controllerIndex; }
internal LocalNetworkGamer( SignedInGamer gamer, NetworkSession session ) : base( session ) { SignedInGamer = gamer; packetQueue = new Queue <NetworkSession.NetworkEvent>(); }
public static bool CanPlayerBuyGame(PlayerIndex player) { bool result = false; SignedInGamer gamer = Gamer.SignedInGamers[player]; if (gamer != null) { result = gamer.Privileges.AllowPurchaseContent; } return(result); }
public void AddLocalGamer(SignedInGamer gamer) { if (LocalGamers.Count == maxLocalGamers) { throw new InvalidOperationException("LocalGamer max limit!"); } LocalNetworkGamer adding = new LocalNetworkGamer(gamer, this); LocalGamers.collection.Add(adding); AllGamers.collection.Add(adding); }
public void UpdateAchievements(SignedInGamer gamer) { for (int num = 29; num >= 0; num--) { int trigger = (int)Links[num].Trigger; Achievement achievement = Links[num].Achievement; if (CheckTriggers[trigger] && Triggers[trigger]) { CheckTriggers[trigger] = false; Main.AchievementSystem.Award(gamer, achievement); } } }
/// <summary> /// http://blog.nickgravelyn.com/2008/12/how-to-test-if-a-player-can-purchase-your-game/ /// </summary> /// <param name="player"></param> /// <returns></returns> public static bool CanPlayerBuyGame(PlayerIndex player) { SignedInGamer gamer = Gamer.SignedInGamers[player]; // if the player isn't signed in, they can't buy games if (gamer == null) { return(false); } // lastly check to see if the account is allowed to buy games return(gamer.Privileges.AllowPurchaseContent); }
public void LoadHighScores(PlayerIndex playerIndex) { SignedInGamer sig = V2DGame.instance.GetSignedInGamer((int)(playerIndex)); if (sig == null) { SignedInGamer.SignedIn += new EventHandler <SignedInEventArgs>(OnSignedIn); } else { tryLoadHighScores = true; } }
public void RemoveLocalGamer(SignedInGamer gamer) { if (IsDisposed) { throw new ObjectDisposedException("NetworkSession"); } pendingSignedInGamers.Remove(gamer); if (localGamerFromSignedInGamer.ContainsKey(gamer)) { SendGamerLeft(localGamerFromSignedInGamer[gamer]); } }
public void AddLocalGamer(SignedInGamer gamer) { if (gamer == null) { throw new ArgumentNullException("gamer"); } // _allGamers.AddGamer(gamer); // _localGamers.AddGamer((LocalNetworkGamer)gamer); // // // We will attach a property change handler to local gamers // // se that we can broadcast the change to other peers. // gamer.PropertyChanged += HandleGamerPropertyChanged; }
public void Update(GameTime gameTime) { this.remainingTime -= gameTime.ElapsedGameTime.TotalMilliseconds; #if XBOX if (TGPAContext.Instance.InputManager.PlayerPressYButton(TGPAContext.Instance.Player1)) { if (Guide.IsVisible == false) { //Player need rights SignedInGamer xboxProfile = Device.DeviceProfile(TGPAContext.Instance.Player1.Device); if (xboxProfile.Privileges.AllowPurchaseContent) { Guide.ShowMarketplace((PlayerIndex)TGPAContext.Instance.Player1.Device.Index); } else { Guide.BeginShowMessageBox(LocalizedStrings.GetString("BuyFailTitle"), LocalizedStrings.GetString("BuyFailContent"), new List <string> { "OK" }, 0, MessageBoxIcon.Warning, null, null); } } } #endif //Leave the game with fade out if (alpha < 1f) { if ((TGPAContext.Instance.InputManager.PlayerPressButtonConfirm(TGPAContext.Instance.Player1)) || (this.remainingTime < 0f) || (Keyboard.GetState().IsKeyDown(Keys.Escape)) || (TGPAContext.Instance.IsTrialMode == false) ) { alpha += 0.05f; this.remainingTime = -1f; } } else { if (TGPAContext.Instance.IsTrialMode == false) { TGPAContext.Instance.CurrentGameState = GameState.LevelSelectionScreen; } else { TGPAContext.Instance.CurrentGameState = GameState.TitleScreen; } } }
public static void FindSessionsThread() { NetworkSessionProperties networkSessionProperties = new NetworkSessionProperties(); UI main = UI.main; if (main.HasOnline()) { SignedInGamer signedInGamer = main.signedInGamer; if (signedInGamer != null) { try { List <SignedInGamer> list = new List <SignedInGamer>(1); list.Add(signedInGamer); FriendCollection friends = signedInGamer.GetFriends(); int num = friends.Count - 1; while (num >= 0 && !stopSessionFinderThread) { FriendGamer friendGamer = friends[num]; if (friendGamer.IsJoinable) { ulong xuid = friendGamer.GetXuid(); networkSessionProperties[0] = (int)xuid; networkSessionProperties[1] = (int)(xuid >> 32); AvailableNetworkSessionCollection availableNetworkSessionCollection = NetworkSession.Find(NetworkSessionType.PlayerMatch, list, networkSessionProperties); if (availableNetworkSessionCollection.Count > 0) { lock (availableSessions) { availableSessions.Add(new JoinableSession(availableNetworkSessionCollection[0])); } } if (stopSessionFinderThread) { break; } Thread.Sleep(5000); } num--; } } catch (Exception) { } } } stopSessionFinderThread = false; sessionFinderThread = null; }