public Player(IContentManager contentManager, IViewport viewport, IAnimationFactory animationFactory, ISpriteBatch spriteBatch, IPlayerConfiguration configuration) : base(spriteBatch) { _configuration = configuration; _viewport = viewport.Viewport; _animation = animationFactory.Build( contentManager.Load(@"Graphics\shipAnimation"), 115, 30, 8); Position = new Vector2(_viewport.TitleSafeArea.X + 100, _viewport.TitleSafeArea.Y + _viewport.TitleSafeArea.Height / 2); BeforeDraw += time => _animation.Update(time); BeforeUpdate += state => { if (_health <= 0) { _active = false; } UpdateVelocity(state); }; _boundaries = new[] { new Rectangle(-100, 0, 100 + _configuration.LeftBoundary, _viewport.Height), new Rectangle(_viewport.Width - _configuration.RightBoundary, 0, 100, _viewport.Height), new Rectangle(0, -100, _viewport.Width, 100 + _configuration.TopBoundary), new Rectangle(0, _viewport.Height - _configuration.BottomBoundary, _viewport.Width, 100), }; }
public IEnemy Build() { var animation = _animationFactory.Build(_texture, 47, 30, 8); return(new Enemy(animation, _spriteBatch)); }