/// <summary> /// Gets the scene. /// @see AddObserver /// </summary> /// <returns></returns> public Scene GetScene() { Scene scene = new Scene(); for (int i = 0; i < 3 + level; i++) { Asteroid asteroid = AsteroidFactory.createNewAsteroid(1, Vector2.Zero, RandomGenerator.GetRandomFloat(0f, 6.28f)); asteroid.AddObserver(scene); scene.AddDrawableObject(asteroid); } return scene; }
/// <summary> /// Loads the content and Initialize the Player's instance. /// @see Initialize /// @see AddScoreObserver /// @see StoreBullet /// </summary> /// <param name="_content">The _content.</param> public void LoadContent(ContentManager _content) { content = _content; AsteroidFactory.SetContent(_content); EnemyFactory.SetContent(_content); input = AsteroidGame.input; // Create scene LevelLoader levelLoader = new LevelLoader(level); scene = levelLoader.GetScene(); UIContainer uiContainer = new UIContainer(); uiContainer.LoadContent(content); scene.Initialize(uiContainer, content); // Player Player.GetInstance().Initialize(content, new Sprite(content.Load<Texture2D>("Graphics\\ship"), 0.6f), new Vector2(500, 300)); for (int i = 0; i < Player.MAX_NB_BULLETS; i++) { Bullet bullet = new Bullet(); bullet.Initialize(new Sprite(content.Load<Texture2D>("Graphics\\fork"), 0.4f), Player.GetInstance().Position); bullet.AddVelocity(5f); bullet.AddScoreObserver(Player.GetInstance()); Player.GetInstance().StoreBullet(bullet); } scene.AddDrawableObject(Player.GetInstance()); }