コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <summary>
        /// Updates the profile sign in screen.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            if (ValidProfileSignedIn())
            {
                // As soon as we detect a suitable profile is signed in,
                // we raise the profile signed in event, then go away.
                if (ProfileSignedIn != null)
                {
                    ProfileSignedIn(this, EventArgs.Empty);
                }

                ExitScreen();
            }
            else if (IsActive && !Guide.IsVisible)
            {
                // If we are in trial mode, and they want to play online, and a profile
                // is signed in, take them to marketplace so they can purchase the game.
                if ((Guide.IsTrialMode) &&
                    (NetworkSessionComponent.IsOnlineSessionType(sessionType)) &&
                    (Gamer.SignedInGamers[ControllingPlayer.Value] != null) &&
                    (!haveShownMarketplace))
                {
                    ShowMarketplace();

                    haveShownMarketplace = true;
                }
                else if (!haveShownGuide && !haveShownMarketplace)
                {
                    // No suitable profile is signed in, and we haven't already shown
                    // the Guide. Let's show it now, so they can sign in a profile.
                    Guide.ShowSignIn(1,
                                     NetworkSessionComponent.IsOnlineSessionType(sessionType));

                    haveShownGuide = true;
                }
                else
                {
                    // Hmm. No suitable profile is signed in, but we already showed
                    // the Guide, and the Guide isn't still visible. There is only
                    // one thing that can explain this: they must have cancelled the
                    // Guide without signing in a profile. We'd better just exit,
                    // which will leave us on the same menu as before.
                    ExitScreen();
                }
            }
        }