/// <summary> /// Initializes the specified instance of an enemy. /// </summary> /// <param name="_sprite">The _sprite.</param> /// <param name="_position">The _position.</param> /// <param name="_bulletSprite">The _bullet sprite.</param> public void Initialize(Sprite _sprite, Vector2 _position, Sprite _bulletSprite) { bullets = new Queue<Bullet>(); base.Initialize(_sprite, _position); AddVelocity(1f); for (int i = 0; i < MAX_NB_BULLETS; i++) { Bullet bullet = new Bullet(); bullet.Initialize(_bulletSprite, position); bullet.AddVelocity(5f); bullets.Enqueue(bullet); } }
/// <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()); }