public override void Reset() { base.Reset(); TextObject gameText; // Clear any existing objects GameObjects.Clear(); // Add the "new game" option gameText = new TextObject(_game, _game.Fonts["Miramonte"], new Vector2(_game.GraphicsDevice.Viewport.Width * 0.5f, _game.GraphicsDevice.Viewport.Height * 0.5f), "Start new game", TextObject.TextAlignment.Center, TextObject.TextAlignment.Near); gameText.Scale = new Vector2(1.0f); gameText.Tag = "NewGame"; GameObjects.Add(gameText); // Add the "High Scores" option gameText = new TextObject(_game, _game.Fonts["Miramonte"], new Vector2(_game.GraphicsDevice.Viewport.Width * 0.5f, _game.GraphicsDevice.Viewport.Height * 0.6f), "View the high scores", TextObject.TextAlignment.Center, TextObject.TextAlignment.Near); gameText.Scale = new Vector2(1.0f); gameText.Tag = "HighScores"; GameObjects.Add(gameText); // Add the "Exit" option gameText = new TextObject(_game, _game.Fonts["Miramonte"], new Vector2(_game.GraphicsDevice.Viewport.Width * 0.5f, _game.GraphicsDevice.Viewport.Height * 0.7f), "Exit", TextObject.TextAlignment.Center, TextObject.TextAlignment.Near); gameText.Scale = new Vector2(1.0f); gameText.Tag = "Exit"; GameObjects.Add(gameText); }
/// <summary> /// Create a series of TextObjects to represent the scores in the specified table /// </summary> /// <param name="tableName">The name of the table whose scores are to be displayed</param> /// <param name="font">The font to use for the score objects</param> /// <param name="scale">A scaling factor for the text</param> /// <param name="top">The coordinate for the topmost text item</param> /// <param name="height">The height of each score item</param> /// <param name="firstColor">The color for the topmost item in the table</param> /// <param name="lastColor">The color for the final item in the table</param> /// <param name="highlightEntry">An entry to highlight in the table (e.g., a newly-added item)</param> /// <param name="highlightColor">The color for the highlighted entry</param> public void CreateTextObjectsForTable(string TableName, SpriteFont font, float scale, float top, float height, Color firstColor, Color lastColor, HighScoreEntry highlightEntry, Color highlightColor) { HighScoreTable table; int entryCount; float yPosition; TextObject textObject; Color entryColor; table = GetTable(TableName); entryCount = table.Entries.Count; for (int i = 0; i < entryCount; i++) { // Find the vertical position for the entry yPosition = top + (height * i); // Find the color for the entry if (table.Entries[i] == highlightEntry) { entryColor = highlightColor; } else { entryColor = new Color(Vector3.Lerp(firstColor.ToVector3(), lastColor.ToVector3(), (float)i / entryCount)); } // Create and add a text item for the position and name textObject = new TextObject(_game, font, new Vector2(_game.GraphicsDevice.Viewport.Width/2-200, yPosition), (i + 1).ToString() + ". " + table.Entries[i].Name); textObject.Scale = new Vector2(scale); textObject.SpriteColor = entryColor; _game.GameObjects.Add(textObject); // Create and add a text item for the score textObject = new TextObject(_game, font, new Vector2(_game.GraphicsDevice.Viewport.Width/2 + 200, yPosition), table.Entries[i].Score.ToString(), TextObject.TextAlignment.Far, TextObject.TextAlignment.Near); textObject.Scale = new Vector2(scale); textObject.SpriteColor = entryColor; _game.GameObjects.Add(textObject); } }
private void ResetGame() { GameObjects.Clear(); // Play back ground music var bgSong = Songs["BackgroundMusic"]; MediaPlayer.Play(bgSong); // Create some balloon object BalloonObject balloonObject; for (int i = 0; i < 30; i++) { balloonObject = new BalloonObject(this, Textures["Balloon"], new Vector2(LeftColumnPos, 100)); GameObjects.Add(balloonObject); } // Add controller ControlObject controlObject; int controlPosY = GraphicsDevice.Viewport.Height - 200; controlObject = new ControlObject(this, new Vector2(0, controlPosY), Textures["UpArrow"], ControlObject.ControlType.Up); GameObjects.Add(controlObject); controlObject = new ControlObject(this, new Vector2(200, controlPosY), Textures["DownArrow"], ControlObject.ControlType.Down); GameObjects.Add(controlObject); controlObject = new ControlObject(this, new Vector2(400, controlPosY), Textures["LeftArrow"], ControlObject.ControlType.Left); GameObjects.Add(controlObject); controlObject = new ControlObject(this, new Vector2(600, controlPosY), Textures["RightArrow"], ControlObject.ControlType.Right); GameObjects.Add(controlObject); // Add mark line LineObject line; line = new LineObject(this, new Vector2(0, ScoreRowBeginPos), Textures["RedLine"]); line.ScaleX = 5; GameObjects.Add(line); line = new LineObject(this, new Vector2(0, ScoreRowEndPos), Textures["RedLine"]); line.ScaleX = 5; GameObjects.Add(line); // Add score _score = new TextObject(this, Fonts["Kootenay"], new Vector2(GraphicsDevice.Viewport.Width / 2, 100), "0") { ScaleX = 5, ScaleY = 5 }; GameObjects.Add(_score); // Load beat LoadBeat("Beat.txt"); GetRightBeat(); GetLeftBeat(); }