/// <summary> /// Store the text that was typed in by the user. /// </summary> /// <param name="r">Result of the keyboard input.</param> protected void GetTypedChars(IAsyncResult r) { typedText = Guide.EndShowKeyboardInput(r); HighScoreTable.SendScore(typedText, PlayerManager.Score); //call to send the score to the database gameState = GameStates.TitleScreen; //leave the game, go to the title screen bannerAd.Visible = true; //set the ad to visible since we are leaving the playing state }
/// <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); //Load the personal scores and sound setting ScoresData = personalScoresSaver.LoadMyData("LocalScores"); if (ScoresData == null) { ScoresData = new LocalScores(); } SoundManager.PlaySounds = ScoresData.soundOn; //Create banner ad on the screen bannerAd = adManager.CreateAd("10016958", new Rectangle(160, 0, 480, 80), RotationMode.Manual, false); //Load all the graphics gameScreen = Content.Load <Texture2D>(@"MenuScreens\gamestartscreen"); howToScreen = Content.Load <Texture2D>(@"MenuScreens\howtoscreen"); highScores = Content.Load <Texture2D>(@"MenuScreens\highscoresscreen"); contactInfo = Content.Load <Texture2D>(@"MenuScreens\contactscreen"); myScoresScreen = Content.Load <Texture2D>(@"MenuScreens\myscoresscreen"); spriteSheet = Content.Load <Texture2D>("spritesheet"); background1 = Content.Load <Texture2D>("background01"); background2 = Content.Load <Texture2D>("background02"); pausedScreen = Content.Load <Texture2D>(@"MenuScreens\pausedscreen"); submitScore = Content.Load <Texture2D>(@"MenuScreens\enterhighscore"); offonSprite = Content.Load <Texture2D>(@"MenuScreens\offonsprite"); //Load all the fonts highScoresFont = Content.Load <SpriteFont>(@"Fonts\highscores"); submitScoreFont = Content.Load <SpriteFont>(@"Fonts\submitscores"); scoreFont = Content.Load <SpriteFont>(@"Fonts\score"); //Set the size of the WHOLE world and the viewable screen CameraManager.WorldRectangle = new Rectangle(0, 0, 1600, 1440); CameraManager.ViewPortWidth = 800; CameraManager.ViewPortHeight = 480; //Initialize all the managers BackgroundManager.Initialize(background1, background2, new Rectangle(0, 0, 1600, 1440), 1); PlayerManager.Initialize(spriteSheet, new Rectangle(0, 0, 161, 86), new Vector2(65, 200), 2); ItemManager.Initialize(spriteSheet); SoundManager.Initialize(Content); HighScoreTable.Initialize(); //Set the locations of the buttons for touching startGameButton = new MenuItem(new Rectangle(40, 240, 250, 55)); howToButton = new MenuItem(new Rectangle(40, 325, 275, 55)); myScoresButton = new MenuItem(new Rectangle(40, 416, 235, 55)); highScoresButton = new MenuItem(new Rectangle(488, 240, 270, 55)); contactInfoButton = new MenuItem(new Rectangle(465, 325, 305, 55)); soundButton = new MenuItem(new Rectangle(488, 416, 270, 55)); yesScore = new MenuItem(new Rectangle(257, 282, 121, 51)); noScore = new MenuItem(new Rectangle(439, 282, 121, 51)); yesExit = new MenuItem(new Rectangle(257, 307, 121, 51)); noExit = new MenuItem(new Rectangle(439, 307, 121, 51)); }
/// <summary> /// Retrieve high scores online. /// </summary> private void getHighScores() { if (!enteredOnce && HighScoreTable.names[0].Equals(" ")) //if we haven't before called to retrieve scores and the high score table is empty { enteredOnce = true; //we have just entered once, so we will never enter again HighScoreTable.RetrieveScores(); //call to retrieve the scores } else //we have the scores, draw them on screen. { for (int i = 0; i < 10; i++) { spriteBatch.DrawString(highScoresFont, HighScoreTable.ranks[i], new Vector2(160, i * 32 + 125), Color.White); spriteBatch.DrawString(highScoresFont, HighScoreTable.names[i], new Vector2(200, i * 32 + 125), Color.White); spriteBatch.DrawString(highScoresFont, HighScoreTable.scores[i].ToString(), new Vector2(515, i * 32 + 125), Color.White); } } }