コード例 #1
0
        /// <summary>
        /// Subprogram to handle logic after game as ended
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values</param>
        private static void UpdateGameEnd(GameTime gameTime)
        {
            //Updating playaer name
            KeyboardHelper.BuildString(ref playerName, 8);
            gameEndMsgLocs[3].X = 400 - gameEndedFont.MeasureString(playerName).X / 2;

            //If enter is pressed, submit player data to leaderboard and reset game
            if (KeyboardHelper.NewKeyStroke(Keys.Enter))
            {
                LeaderboardScreen.UpdateLeaderboardData(new LeaderboardEntry(playerName, (byte)(52 - cardDeck.Count), Math.Round(playTime, 3)));
                playerName         = string.Empty;
                Main.CurrentScreen = ScreenMode.Leaderboard;
                gameState          = GameState.InitialState;
                IO.UploadBlankGameData();
                MediaPlayer.Stop();
            }
        }
コード例 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Setting default screen as main menu
            CurrentScreen = ScreenMode.MainMenu;

            //Loading various static classes
            CardHelper.Load(Content);
            SharedData.Load(Content);
            IO.Load();
            MainMenuScreen.Load(Content);
            GameScreen.Load(Content);
            LeaderboardScreen.Load(Content);

            //Setting up screen method dictionary
            screenMethodDictionary.Add(ScreenMode.MainMenu, new ScreenMethodPair(MainMenuScreen.Update, MainMenuScreen.Draw));
            screenMethodDictionary.Add(ScreenMode.Game, new ScreenMethodPair(GameScreen.Update, GameScreen.Draw));
            screenMethodDictionary.Add(ScreenMode.Leaderboard, new ScreenMethodPair(LeaderboardScreen.Update, LeaderboardScreen.Draw));
        }