Ejemplo n.º 1
0
        /// <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());
        }