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(); }
private BalloonObject GetBalloonObject() { BalloonObject obj = null; GameObjectBase gameObj; int objectCount = GameObjects.Count; for (int i = 0; i < objectCount; i++) { gameObj = GameObjects[i]; if (gameObj is BalloonObject) { obj = (BalloonObject)gameObj; if (obj.IsActive == false) { return obj; } } } // if all balloon is not active, add more balloon object to objects pull (20% growth) for (int i = 0; i < objectCount / 5; i++) { obj = new BalloonObject(this, Textures["Balloon"], new Vector2(0, 0)); GameObjects.Add(obj); } return obj; }