Inheritance: Microsoft.Xna.Framework.GamerServices.Gamer
        public MainMenuScreen(SignedInGamer gamerOne)
        {
            this.gamerOne = gamerOne;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);
        }
Beispiel #2
0
 /// <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;
 }
Beispiel #3
0
 internal static void OnSignIn(SignedInGamer gamer)
 {
     if (SignedIn != null)
     {
         SignedIn(null, new SignedInEventArgs(gamer));
     }
 }
        public override void HandleInput(InputState input)
        {
            if (!gamerSelected)
            {
                for (int i = 0; i < InputState.MaxInputs; i++)
                {
                    if (input.CurrentGamePadStates[i].IsButtonDown(Buttons.Start) == true && input.PreviousGamePadStates[i].IsButtonUp(Buttons.Start) == true ||
                        input.CurrentKeyboardStates[i].IsKeyDown(Keys.Enter) == true && input.PreviousKeyboardStates[i].IsKeyUp(Keys.Enter) ||
                        input.CurrentKeyboardStates[i].IsKeyDown(Keys.Space) == true && input.PreviousKeyboardStates[i].IsKeyUp(Keys.Space))
                    {
                        gamerOne = Gamer.SignedInGamers[(PlayerIndex)i];

                        gamerSelected = true;

                        if (gamerOne == null)
                        {
                            if (!Guide.IsVisible)
                            {
                                Guide.ShowSignIn(1, false);
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
 public override void Update(GameTime gameTime)
 {
     if (this.gt == TimeSpan.Zero)
     {
         this.gt = this.last = gameTime.TotalGameTime;
     }
     if ((gameTime.TotalGameTime - this.last).Milliseconds > 100)
     {
         this.last        = gameTime.TotalGameTime;
         this.startalpha += (byte)21;
     }
     if ((gameTime.TotalGameTime - this.gt).TotalSeconds > 5.0)
     {
         string str = WindowsIdentity.GetCurrent().Name;
         if (str.Contains("\\"))
         {
             int startIndex = str.IndexOf("\\") + 1;
             str = str.Substring(startIndex, str.Length - startIndex);
         }
         SignedInGamer signedInGamer = new SignedInGamer();
         signedInGamer.DisplayName = str;
         signedInGamer.Gamertag    = str;
         Gamer.SignedInGamers.Add(signedInGamer);
         this.Visible = false;
         this.Enabled = false;
         this.gt      = TimeSpan.Zero;
     }
     base.Update(gameTime);
 }
Beispiel #6
0
 internal static void OnSignOut(SignedInGamer gamer)
 {
     if (SignedOut != null)
     {
         SignedOut(null, new SignedOutEventArgs(gamer));
     }
 }
        public NetworkGameMenu(PlayerIndex enteringPlayer)
            : base("Start a network game")
        {
            currentPlayerIndex = enteringPlayer;
            currentGamer = SignedInGamer.SignedInGamers[currentPlayerIndex];
            // Create our menu entries.
            if (currentGamer != null)
            {
                opt1 = new MenuEntry("Currently signed in");
            }
            else
            {
                opt1 = new MenuEntry("Select to sign in");
                SignedInGamer.SignedIn += new EventHandler<SignedInEventArgs>(gamerSignIn);
            }
            MenuEntry opt2 = new MenuEntry("Host local network game");
            MenuEntry opt3 = new MenuEntry("Join local newtwork game");
            MenuEntry opt4 = new MenuEntry("Go Back");

            opt1.Selected += LiveSignIn;
            opt2.Selected += HostLocalGame;
            opt3.Selected += FindLocalGame;
            opt4.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(opt1);
            MenuEntries.Add(opt2);
            MenuEntries.Add(opt3);
            MenuEntries.Add(opt4);
            SetMenuEntryText();
        }
        public LocalNetworkGameMenu(PlayerIndex enteringPlayer, NetworkSession nSession)
            : base("Local Network Game Lobby")
        {
            netSession = nSession;
            currentPlayerIndex = enteringPlayer;
            currentGamer = SignedInGamer.SignedInGamers[currentPlayerIndex];
            netSession.GameStarted += new EventHandler<GameStartedEventArgs>(loadNetworkGameScreen);

            // Create our menu entries.
            gameTypeOption = new MenuEntry("Game Type: " + GameType());
            highScoreOption = new MenuEntry("Score to Win: " + WinningScore());
            opt2 = new MenuEntry("Host: " + nSession.Host.ToString());
            opt3 = new MenuEntry("Ready?");
            opt4 = new MenuEntry("Waiting for opponent");
            opt5 = new MenuEntry("Go Back");

            netSession.GameStarted += new EventHandler<GameStartedEventArgs>(StartGame);

            gameTypeOption.Selected += changeGameType;
            highScoreOption.Selected += changeWinningScore;
            opt3.Selected += setReady;
            opt4.Selected += startGame;
            opt5.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(gameTypeOption);
            MenuEntries.Add(highScoreOption);
            MenuEntries.Add(opt2);
            MenuEntries.Add(opt3);
            MenuEntries.Add(opt4);
            MenuEntries.Add(opt5);

            SetMenuEntryText();
        }
Beispiel #9
0
        public override void Update(GameTime gameTime)
        {
            if (gt == TimeSpan.Zero)
            {
                gt = last = gameTime.TotalGameTime;
            }

            if ((gameTime.TotalGameTime - last).Milliseconds > 100)
            {
                last        = gameTime.TotalGameTime;
                startalpha += 255 / 12;
            }

            if ((gameTime.TotalGameTime - gt).TotalSeconds > 5) // close after 10 seconds
            {
                string name = "pssuser";
                //TODO: Try get a name from the system (If/When PSS Has something like this)

                SignedInGamer sig = new SignedInGamer();
                sig.DisplayName      = name;
                sig.Gamertag         = name;
                sig.IsSignedInToLive = false;

                Gamer.SignedInGamers.Add(sig);

                this.Visible = false;
                this.Enabled = false;
                //Guide.IsVisible = false;
                gt = TimeSpan.Zero;
            }
            base.Update(gameTime);
        }
Beispiel #10
0
 public SignedInEventArgs(SignedInGamer gamer)
 {
     if (gamer == null)
     {
         throw new ArgumentNullException("gamer");
     }
     this.gamer = gamer;
 }
        public CharacterSelectScreen(SignedInGamer gamerOne)
            : base("Character Select")
        {
            this.gamerOne = gamerOne;

            TransitionOnTime = TimeSpan.FromSeconds(0.3);
            TransitionOffTime = TimeSpan.FromSeconds(0.3);
        }
Beispiel #12
0
 public SignedInEventArgs(SignedInGamer gamer)
 {
     if (gamer == null)
     {
         throw new ArgumentNullException("gamer");
     }
     this.gamer = gamer;
 }
Beispiel #13
0
 protected virtual void OnSignedOut(SignedOutEventArgs e)
 {
     if (SignedInGamer.SignedOut == null)
     {
         return;
     }
     SignedInGamer.SignedOut((object)this, e);
 }
 public InviteAcceptedEventArgs(
     SignedInGamer gamer,
     bool isCurrentSession
     )
 {
     Gamer            = gamer;
     IsCurrentSession = isCurrentSession;
 }
Beispiel #15
0
        internal LocalGamer(SignedInGamer gamer)
        {
            SignedInGamer = gamer;
            SignedInGamer.Tag = this;

            reader = new PacketReader();
            Writer = new PacketWriter();

            InitializeSystemPackets();
        }
        /// <summary>
        /// This method gets the filenames from the universal storage file LbKTileData.sav
        /// </summary>
        /// <param name="device"></param>
        /// <param name="gamer"></param>
        /// <param name="fileNamesOnly"></param>
        public static void LoadGame(StorageDevice device, SignedInGamer gamer, bool fileNamesOnly)
        {
            // Open a storage container.
            // name of container is LbK Storage Device
            IAsyncResult result =
                device.BeginOpenContainer(gamer.Gamertag, null, null);

            // Wait for the WaitHandle to become signaled.
            result.AsyncWaitHandle.WaitOne();

            StorageContainer container = device.EndOpenContainer(result);

            // Close the wait handle.
            result.AsyncWaitHandle.Close();

            string filename = "LbKTileData.sav";

            // Check to see whether the save exists.
            if (!container.FileExists(filename))
            {
                // If not, dispose of the container and return.
                container.Dispose();
                return;
            }

            // Open the file.
            Stream file = container.OpenFile(filename, FileMode.Open);

            // Read the data from the file.
            XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));
            SaveGameData data = (SaveGameData)serializer.Deserialize(file);

            // Close the file.
            file.Close();

            // Dispose the container.
            container.Dispose();

            // Report the data to the console.
            if (fileNamesOnly)
            {
                fileNames = data.Names;
            }
            else
            {
                position = data.TilePosition;
                type = data.TileType;
                objectNumber = data.TileObjectNumber;
                count = data.TileCount;
                fileNames = data.Names;
            }

            GamePlayScreen.storageDevice = device;
            // load up game with respective device
        }
Beispiel #17
0
        public override void Update(GameTime gameTime)
        {
            if (gt == TimeSpan.Zero)
            {
                gt = last = gameTime.TotalGameTime;
            }

            if ((gameTime.TotalGameTime - last).Milliseconds > 100)
            {
                last        = gameTime.TotalGameTime;
                startalpha += 255 / 12;
            }

            if ((gameTime.TotalGameTime - gt).TotalSeconds > delay) // close after 10 seconds
            {
                string name = "androiduser";
                try
                {
                    Android.Accounts.AccountManager mgr = (Android.Accounts.AccountManager)Android.App.Application.Context.GetSystemService(Android.App.Activity.AccountService);
                    if (mgr != null)
                    {
                        var accounts = mgr.GetAccounts();
                        if (accounts != null && accounts.Length > 0)
                        {
                            name = accounts[0].Name;
                            if (name.Contains("@"))
                            {
                                // its an email
                                name = name.Substring(0, name.IndexOf("@"));
                            }
                        }
                    }
                }
                catch
                {
                }

                SignedInGamer sig = new SignedInGamer();
                sig.DisplayName      = name;
                sig.Gamertag         = name;
                sig.IsSignedInToLive = false;

                Gamer.SignedInGamers.Add(sig);

                this.Visible = false;
                this.Enabled = false;
                //Guide.IsVisible = false;
                gt = TimeSpan.Zero;
            }
            base.Update(gameTime);
        }
        /// <summary>
        /// This method loads a serialized data object
        /// from the StorageContainer for this game.
        /// </summary>
        /// <param name="device"></param>
        public static void LoadGame(StorageDevice device, SignedInGamer gamer)
        {
            // Open a storage container.
            // name of container is LbK Storage Device
            IAsyncResult result =
                device.BeginOpenContainer("LbK Storage Device", null, null);

            // Wait for the WaitHandle to become signaled.
            result.AsyncWaitHandle.WaitOne();

            StorageContainer container = device.EndOpenContainer(result);

            // Close the wait handle.
            result.AsyncWaitHandle.Close();

            string filename = "LbKSavedItems.sav";

            // Check to see whether the save exists.
            if (!container.FileExists(filename))
            {
                // If not, dispose of the container and return.
                container.Dispose();
                nothingLoaded = true;
                return;
            }

            // Open the file.
            Stream file = container.OpenFile(filename, FileMode.Open);

            // Read the data from the file.
            XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));
            SaveGameData data = (SaveGameData)serializer.Deserialize(file);

            // Close the file.
            file.Close();

            // Dispose the container.
            container.Dispose();

            // Report the data to the console.
            playerName = data.PlayerName;
            level = data.Level;
            score = data.PlayerScore;
            position = new Vector2(data.playerPosition.X, data.playerPosition.Y);
            checkPoint = data.CheckPoint;

            GamePlayScreen.storageDevice = device;
            // load up game with respective device
        }
Beispiel #19
0
 public Microsoft.Xna.Framework.GamerServices.Gamer SignIn(string username, string password)
 {
   using (MonoLive monoLive = new MonoLive())
   {
     Result result = monoLive.SignIn(username, password);
     if (result.ok)
     {
       SignedInGamer signedInGamer = new SignedInGamer();
       signedInGamer.Gamertag = result.Gamer.GamerTag;
       signedInGamer.DisplayName = result.Gamer.GamerTag;
       return (Microsoft.Xna.Framework.GamerServices.Gamer) signedInGamer;
     }
   }
   return (Microsoft.Xna.Framework.GamerServices.Gamer) null;
 }
Beispiel #20
0
        void profileSelected()
        {
            if (tableView.SelectedRowCount > 0)
            {
                var           rowSelected = tableView.SelectedRow;
                SignedInGamer sig         = new SignedInGamer();
                sig.DisplayName        = gamerList[(int)rowSelected].DisplayName;
                sig.Gamertag           = gamerList[(int)rowSelected].Gamertag;
                sig.InternalIdentifier = gamerList[(int)rowSelected].PlayerInternalIdentifier;

                Gamer.SignedInGamers.Add(sig);
            }
            MonoGameGamerServicesHelper.SerializeProfiles(gamerList);
            NSApp.StopModal();
        }
        public static void Gamer_LoginSuccess(object sender, SignedInEventArgs e)
        {
            // set the local gamer to the signedin gamer
            gamer = e.Gamer;

            // begin asynchronously getting the player's profile. Do this because it may take time to get over the network otherwise.
            gamer.BeginGetProfile(endGetProfile, gamer);

            // remove the signedin handler
            SignedInGamer.SignedIn -= signInHandler;
            Console.WriteLine("Gamer: " + gamer.Gamertag + " signed in.");

            int maxNumberOfPlayers = 1;
            NetworkSession.BeginFind(NetworkSessionType.PlayerMatch, maxNumberOfPlayers, null, endFind, session);
        }
Beispiel #22
0
 private void client_SignInCompleted(object sender, MonoGame.Framework.MonoLive.SignInCompletedEventArgs e)
 {
   if (this.SignInCompleted != null && e.Error != null)
   {
     ((IDisposable) e.UserState).Dispose();
     MonoLiveClient.SignInCompletedEventHandler completedEventHandler = this.SignInCompleted;
     MonoLiveClient monoLiveClient = this;
     SignedInGamer signedInGamer = new SignedInGamer();
     signedInGamer.Gamertag = e.Result.Gamer.GamerTag;
     signedInGamer.DisplayName = e.Result.Gamer.GamerTag;
     SignInCompletedEventArgs e1 = new SignInCompletedEventArgs((Microsoft.Xna.Framework.GamerServices.Gamer) signedInGamer);
     completedEventHandler((object) monoLiveClient, e1);
   }
   else
     this.SignInCompleted((object) this, (SignInCompletedEventArgs) null);
 }
        public override void Update(GameTime gameTime)
        {
            if (gt == TimeSpan.Zero) gt = gameTime.TotalGameTime;

            if ((gameTime.TotalGameTime - gt).TotalSeconds > 10) // close after 10 seconds
            {
                SignedInGamer sig = new SignedInGamer();
                sig.DisplayName = "MonoGamer";
                sig.Gamertag = "MonoGamer";

                Gamer.SignedInGamers.Add(sig);

                this.Enabled = false;
                Guide.IsVisible = false;
                gt = TimeSpan.Zero;                
            }
            base.Update(gameTime);
        }
#pragma warning restore 0067

        #endregion

        #region Public Static Methods

        public static void Initialize(IServiceProvider serviceProvider)
        {
            IsInitialized = true;

            AppDomain.CurrentDomain.ProcessExit += (o, e) =>
            {
                IsInitialized = false;
            };

            List <SignedInGamer> startGamers = new List <SignedInGamer>(1);

            startGamers.Add(new SignedInGamer(
                                "Stub Gamer",
                                IsInitialized
                                ));

            // FIXME: This is stupid -flibit
            startGamers.Add(new SignedInGamer(
                                "Stub Gamer (1)",
                                IsInitialized,
                                true,
                                PlayerIndex.Two
                                ));
            startGamers.Add(new SignedInGamer(
                                "Stub Gamer (2)",
                                IsInitialized,
                                true,
                                PlayerIndex.Three
                                ));
            startGamers.Add(new SignedInGamer(
                                "Stub Gamer (3)",
                                IsInitialized,
                                true,
                                PlayerIndex.Four
                                ));

            Gamer.SignedInGamers = new SignedInGamerCollection(startGamers);
            foreach (SignedInGamer gamer in Gamer.SignedInGamers)
            {
                SignedInGamer.OnSignIn(gamer);
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (gt == TimeSpan.Zero)
            {
                gt = gameTime.TotalGameTime;
            }

            if ((gameTime.TotalGameTime - gt).TotalSeconds > 10) // close after 10 seconds
            {
                SignedInGamer sig = new SignedInGamer();
                sig.DisplayName = "MonoGamer";
                sig.Gamertag    = "MonoGamer";

                Gamer.SignedInGamers.AddGamer(sig);

                this.Enabled    = false;
                Guide.IsVisible = false;
                gt = TimeSpan.Zero;
            }
            base.Update(gameTime);
        }
Beispiel #26
0
        public override void Update(GameTime gameTime)
        {
            if (gt == TimeSpan.Zero)
            {
                gt = last = gameTime.TotalGameTime;
            }

            if ((gameTime.TotalGameTime - last).Milliseconds > 100)
            {
                last        = gameTime.TotalGameTime;
                startalpha += 255 / 12;
            }

            if ((gameTime.TotalGameTime - gt).TotalSeconds > 5) // close after 10 seconds
            {
                string strUsr = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

                if (strUsr.Contains(@"\"))
                {
                    int idx = strUsr.IndexOf(@"\") + 1;
                    strUsr = strUsr.Substring(idx, strUsr.Length - idx);
                }

                SignedInGamer sig = new SignedInGamer();
                sig.DisplayName = strUsr;
                sig.Gamertag    = strUsr;

                Gamer.SignedInGamers.Add(sig);

                this.Visible = false;
                this.Enabled = false;
                //Guide.IsVisible = false;
                gt = TimeSpan.Zero;
            }
            base.Update(gameTime);
        }
        public static void Gamer_LogoutSuccess(object sender, SignedOutEventArgs e)
        {
            Console.WriteLine("Gamer: " + e.Gamer.Gamertag + " signed out.");

            // reset gamer
            gamer = null;

            // add signedin handler
            SignedInGamer.SignedIn += signInHandler;
        }
Beispiel #28
0
 public static void BeginRead(LeaderboardIdentity id, SignedInGamer gamer, int leaderboardPageSize, AsyncCallback leaderboardReadCallback, SignedInGamer gamer2)
 {
     throw new NotImplementedException();
 }
Beispiel #29
0
 public SignedOutEventArgs(SignedInGamer gamer)
 {
 }
Beispiel #30
0
		void profileSelected () 
		{
			if (tableView.SelectedRowCount > 0) {
				var rowSelected = tableView.SelectedRow;
				SignedInGamer sig = new SignedInGamer();
				sig.DisplayName = gamerList[rowSelected].DisplayName;
				sig.Gamertag = gamerList[rowSelected].Gamertag;
				sig.InternalIdentifier = gamerList[rowSelected].PlayerInternalIdentifier;
				
				Gamer.SignedInGamers.Add(sig);
			}
			MonoGameGamerServicesHelper.SerializeProfiles(gamerList);
			NSApp.StopModal();
		}
Beispiel #31
0
 public void AddLocalGamer(SignedInGamer gamer)
 {
   if (gamer == null)
     throw new ArgumentNullException("gamer");
 }
Beispiel #32
0
        /// <summary>
        /// Constructs a new screen manager component.
        /// </summary>
        public ScreenManager(Game game)
            : base(game)
        {
            content = new ContentManager(game.Services, "Content");

            graphicsDeviceService = (IGraphicsDeviceService)game.Services.GetService(
                                                        typeof(IGraphicsDeviceService));

            if (graphicsDeviceService == null)
                throw new InvalidOperationException("No graphics device service.");

            invited = null;
        }
 public SignedInEventArgs(SignedInGamer gamer)
 {
     Gamer = gamer;
 }
Beispiel #34
0
#pragma warning restore 0067

        #endregion

        #region Public Static Methods

        public static void Initialize(IServiceProvider serviceProvider)
        {
            IsInitialized = SteamAPI.Init();

            if (!IsInitialized)
            {
                throw new GamerServicesNotAvailableException(
                          "Steam is not running, please restart Steam!"
                          );
            }

            AppDomain.CurrentDomain.ProcessExit += (o, e) =>
            {
                SteamAPI.Shutdown();
                IsInitialized = false;
            };

            overlayActivated = Callback <GameOverlayActivated_t> .Create(Guide.OnOverlayActivated);

            textInputDismissed = Callback <GamepadTextInputDismissed_t> .Create(Guide.OnTextInputDismissed);

            lobbyJoinRequested = Callback <GameLobbyJoinRequested_t> .Create(Net.NetworkSession.OnInviteAccepted);

            SteamUserStats.RequestCurrentStats();

            List <SignedInGamer> startGamers = new List <SignedInGamer>(1);

            startGamers.Add(new SignedInGamer(
                                SteamUser.GetSteamID(),
                                SteamFriends.GetPersonaName(),
                                IsInitialized
                                ));

            // FIXME: This is stupid -flibit
            startGamers.Add(new SignedInGamer(
                                SteamUser.GetSteamID(),
                                SteamFriends.GetPersonaName() + " (1)",
                                IsInitialized,
                                true,
                                PlayerIndex.Two
                                ));
            startGamers.Add(new SignedInGamer(
                                SteamUser.GetSteamID(),
                                SteamFriends.GetPersonaName() + " (2)",
                                IsInitialized,
                                true,
                                PlayerIndex.Three
                                ));
            startGamers.Add(new SignedInGamer(
                                SteamUser.GetSteamID(),
                                SteamFriends.GetPersonaName() + " (3)",
                                IsInitialized,
                                true,
                                PlayerIndex.Four
                                ));

            Gamer.SignedInGamers = new SignedInGamerCollection(startGamers);
            foreach (SignedInGamer gamer in Gamer.SignedInGamers)
            {
                SignedInGamer.OnSignIn(gamer);
            }
        }
 public static void BeginRead (LeaderboardIdentity id, SignedInGamer gamer, int leaderboardPageSize, AsyncCallback leaderboardReadCallback, SignedInGamer gamer2)
 {
     throw new NotImplementedException ();
 }
 /* Add a random highscore. Used to populate the table for testing.
  * If there is no signed in gamer, use the word "Guest."
  */
 void AddHighscore(SignedInGamer g)
 {
     AddHighscore((g == null) ? "Guest" : g.Gamertag, false);
 }
        public override void Update(GameTime gameTime)
        {
            if (gt == TimeSpan.Zero) gt = last = gameTime.TotalGameTime;

            if ((gameTime.TotalGameTime - last).Milliseconds > 100)
            {
                last = gameTime.TotalGameTime;
                startalpha += 255 / 12;
            }

            if ((gameTime.TotalGameTime - gt).TotalSeconds > 5) // close after 10 seconds
            {
                string strUsr = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

                if (strUsr.Contains(@"\"))
                {
                    int idx = strUsr.IndexOf(@"\") + 1;
                    strUsr = strUsr.Substring(idx, strUsr.Length - idx);
                }

                SignedInGamer sig = new SignedInGamer();
                sig.DisplayName = strUsr;
                sig.Gamertag = strUsr;

                Gamer.SignedInGamers.Add(sig);

                this.Visible = false;
                this.Enabled = false;
                //Guide.IsVisible = false;
                gt = TimeSpan.Zero;
            }
            base.Update(gameTime);
        }
Beispiel #38
0
		public LocalNetworkGamer ()
		{
			sig = new SignedInGamer();
		}
        public static void SaveGame(StorageDevice device, SignedInGamer gamer)
        {
            SaveGameData data = new SaveGameData();
            data.CurrentLevel = level;
            data.SavedPlayerScore = score;
            data.SavedCheckPoint = checkPoint;

            IAsyncResult result =
                device.BeginOpenContainer(gamer.Gamertag, null, null);

            result.AsyncWaitHandle.WaitOne();

            StorageContainer container = device.EndOpenContainer(result);

            // Close the wait handle.
            result.AsyncWaitHandle.Close();
            //.sav is important
            string filename = "LbKSavedInfo.sav";

            if (!container.FileExists(filename))
            {
                Stream file = container.CreateFile(filename);

                XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));

                serializer.Serialize(file, data);

                file.Close();
            }
            else
            {

                container.DeleteFile(filename);

                Stream file = container.CreateFile(filename);

                XmlSerializer serializer = new XmlSerializer(typeof(SaveGameData));

                serializer.Serialize(file, data);

                file.Close();
            }

            // Dispose the container, to commit the data.
            container.Dispose();
        }
Beispiel #40
0
		public SignedOutEventArgs (SignedInGamer gamer )
		{
			
		}
Beispiel #41
0
 public override void Update(GameTime gameTime)
 {
   if (this.gt == TimeSpan.Zero)
     this.gt = this.last = gameTime.TotalGameTime;
   if ((gameTime.TotalGameTime - this.last).Milliseconds > 100)
   {
     this.last = gameTime.TotalGameTime;
     this.startalpha += (byte) 21;
   }
   if ((gameTime.TotalGameTime - this.gt).TotalSeconds > 5.0)
   {
     string str = WindowsIdentity.GetCurrent().Name;
     if (str.Contains("\\"))
     {
       int startIndex = str.IndexOf("\\") + 1;
       str = str.Substring(startIndex, str.Length - startIndex);
     }
     SignedInGamer signedInGamer = new SignedInGamer();
     signedInGamer.DisplayName = str;
     signedInGamer.Gamertag = str;
     Gamer.SignedInGamers.Add(signedInGamer);
     this.Visible = false;
     this.Enabled = false;
     this.gt = TimeSpan.Zero;
   }
   base.Update(gameTime);
 }
Beispiel #42
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
            bool coveredByOtherScreen)
        {
            //BEGIN NEW XBOX LIVE GamerPicture code etc
            //You just need to get the GamerCard info if you don't have it already
            if (gamer == null && SignedInGamer.SignedInGamers.Count > 0)
            {
                //Get info for the 1st player
                gamer = SignedInGamer.SignedInGamers[0];
                profile = gamer.GetProfile();
                //place to draw the gamer picture (in the middle of the screen)
                GamerPictureRectangle = new Rectangle(
                                30,
                                150,
                                64,
                                64
                              );
                //place to write some info
                gamerTagVector = new Vector2(GamerPictureRectangle.X, 0);
            }
            //END NEW XBOX LIVE GamerPicture code etc
            //Get the current state of the keyboard (what keys are and are not being pressed)
            KeyboardState aKeyboard = Keyboard.GetState();
            if (aKeyboard.IsKeyDown(Keys.P))
            {
                //pause the game
                paused = !paused;

            }

            if (paused)
            {

            }
            else
            {
                CheckForRumble(gameTime);

                // TODO: Add your update logic here
                //The time since Update was called last
                float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

                //Update the game objects

                //Lets rotate both ways
                //Only Math.PI / 2( one quarter turn)
                const float quarterturn = (float)Math.PI / 2;

                if (rotation < quarterturn)
                {
                    // The grid is currently rotateing
                    // Just Draw
                }
                else
                    if (rotation > Math.PI / 2 && rotation_direction != 0)
                    {//Rotation completed
                        if (rotation_direction > 0) mPlayfield.Rotate_Grid();
                        else mPlayfield.Rotate_Grid_Clockwise();
                        rotation_direction = 0;
                        rotation = 3.14f;
                    }
                    else
                        if (mPlayfield.CheckCollision(mCurrentShape) == true && mCurrentShape.PositionY < 4)
                        {
                        gameover = true;
                        SaveHighScore();
                        }
                        else
                            UpdateGameObjects(elapsed, aKeyboard);

                base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

                if (IsActive)
                {

                }
            }
        }
Beispiel #43
0
		public LocalNetworkGamer () : base(null, 0, 0)
		{
			sig = new SignedInGamer ();
			receivedData = new Queue<CommandReceiveData>();
		}
Beispiel #44
0
		public LocalNetworkGamer (NetworkSession session,byte id,GamerStates state)
			: base(session, id, state | GamerStates.Local)
		{
			sig = new SignedInGamer ();
			receivedData = new Queue<CommandReceiveData>();
		}
Beispiel #45
0
 public void AddLocalGamer(SignedInGamer gamer)
 {
     throw new NotImplementedException();
 }
Beispiel #46
0
        public PlayerHUD( Player player, SignedInGamer gamer )
        {
            GameplayScreen screen = player.Screen;

              if ( gamer != null )
              {
            profile = gamer.GetProfile();
            Name = gamer.Gamertag;
              }
              else Name = "CPU";

              Player = player;
              Score = 0;
              Boost = 1f;

              Rectangle safeRect = ScreenRects.SafeRegion;

              screenScale = GameCore.Instance.GraphicsDevice.Viewport.Height / 1080f;
              float ss = screenScale;

              // base hud object
              hudCageTexture = screen.Content.Load<Texture2D>( "Textures/playerHUDCage" );
              hudTexture = screen.Content.Load<Texture2D>( "Textures/playerHUD" );
              int hudWidth  = (int)( hudTexture.Width * screenScale );
              int hudHeight = (int)( hudTexture.Height * screenScale );

              int x0 = xPadding + safeRect.X + Player.PlayerNumber * ( safeRect.Width - hudWidth - 2 * xPadding ) / 3;
              int y0 = -(int)( yPadding * screenScale + .5f ) + safeRect.Y + safeRect.Height - hudHeight;

              hudRect = new Rectangle( x0, y0, hudWidth, hudHeight );

              // profile picture
              profileRect = new Rectangle( x0 + (int)( 88 * ss + .5f ),
                                   y0 + (int)( 26 * ss + .5f ),
                                   (int)( 60 * ss + .5f ),
                                   (int)( 60 * ss + .5f ) );

              // boost meter
              boostRect = new Rectangle( x0 + (int)(  90 * ss + .5f ),
                                 y0 + (int)( 111 * ss + .5f ),
                                 (int)( 142 * ss + .5f ),
                                 (int)( 18 * ss + .5f ) );

              boostEffect = screen.Content.Load<Effect>( "Effects/meterEffect" );
              boostEffect.CurrentTechnique = boostEffect.Techniques[0];
              boostEffectParamBoost = boostEffect.Parameters["Boost"];
              boostEffectParamBoosting = boostEffect.Parameters["Boosting"];
              boostEffectParamTime = boostEffect.Parameters["Time"];
              boostTexture = new Texture2D( screen.ScreenManager.GraphicsDevice, boostRect.Width, boostRect.Height );

              // name
              namePos = new Vector2( x0 + 162 * ss, y0 + 12 * ss );
              nameFont = screen.Content.Load<SpriteFont>( "Fonts/HUDNameFont" );
              nameOrigin = nameFont.MeasureString( Name ) / 2;
              float nameLength = nameOrigin.X * 2;
              nameScale = ss * Math.Min( 150f / nameLength, 1f );

              // score
              scorePos = new Vector2( x0 + 230 * ss, y0 + 100 * ss );
              scoreFont = screen.Content.Load<SpriteFont>( "Fonts/HUDScoreFont" );
              scoreSpring = new SpringInterpolater( 1, 700f, .25f * SpringInterpolater.GetCriticalDamping( 700f ) );
              scoreSpring.SetSource( 1f );
              scoreSpring.SetDest( 1f );
              scoreSpring.Active = true;
              scoreString = new StringBuilder( 1 );

              //// score popup
              //scorePopup = new PopupText( ss, scorePos + new Vector2( -25f, -120f ) * screenScale,
              //                            scorePos + new Vector2( -15f, -15f ) * screenScale, 1f );
              // score popup
              //float yMax = GameCore.Instance.DisplayGamertags ? -50f : -10f;
              //float yMin = GameCore.Instance.DisplayGamertags ? 0f : 40f;
              float yMax = -50f;
              float yMin = 0f;
              scorePopup = new PopupText( ss, new Vector2( 0f, yMax ) * screenScale,
                                  new Vector2( 0, yMin ) * screenScale, 1f );

              // place
              placePos = new Vector2( x0 + 36 * ss, y0 + 91 * ss );
              placeFont = screen.Content.Load<SpriteFont>( "Fonts/HUDPlaceFont" );
              placeSmallFont = screen.Content.Load<SpriteFont>( "Fonts/HUDPlaceTagFont" );
              placeNumber = new StringBuilder( "0" );
              placeSpring = new SpringInterpolater( 1, 700f, .25f * SpringInterpolater.GetCriticalDamping( 700f ) );
              placeSpring.SetSource( 1f );
              placeSpring.SetDest( 1f );
              placeSpring.Active = true;
              Place = 1;
        }