Permalink
Browse files

tidy up autofac config and the enemy factory

  • Loading branch information...
becdetat committed May 28, 2014
1 parent be142c3 commit 26a12e3595604d807fbe0c76417e34fb99155007
@@ -7,17 +7,18 @@ public class EnemyFactory : IEnemyFactory, IRegistering
{
private readonly IContentManager _contentManager;
private readonly IAnimationFactory _animationFactory;
private ITexture2D _texture;
public EnemyFactory(IContentManager contentManager, IAnimationFactory animationFactory)
{
_contentManager = contentManager;
_animationFactory = animationFactory;
_texture = _contentManager.Load("Graphics/mineAnimation");
}
public IEnemy Build()
{
var texture = _contentManager.Load("Graphics/mineAnimation");
var animation = _animationFactory.Build(texture, 47, 30, 8);
var animation = _animationFactory.Build(_texture, 47, 30, 8);
return new Enemy(animation);
}
}
@@ -12,11 +12,10 @@ public static IContainer Register(Game game)
{
var builder = new ContainerBuilder();
var spriteBatch = new SpriteBatch(game.GraphicsDevice);
game.Content.RootDirectory = "Content";
builder.RegisterInstance(new SpriteBatch(game.GraphicsDevice)).AsSelf();
builder.RegisterInstance(game.Content).AsSelf();
builder.RegisterInstance(spriteBatch).AsSelf();
builder.RegisterInstance(game.GraphicsDevice).AsSelf();
builder.RegisterAssemblyTypes(typeof (AutofacConfig).GetTypeInfo().Assembly)
@@ -32,14 +32,14 @@ public class ShooterGame : Game
IParallaxingBackground _background2;
private ITexture2D _mainBackground;
private Rectangle _mainBackgroundRect;
private ICollection<IEnemy> _enemies = new Collection<IEnemy>();
private readonly ICollection<IEnemy> _enemies = new Collection<IEnemy>();
private TimeSpan _enemySpawnTime = TimeSpan.FromSeconds(1);
private TimeSpan _previousEnemySpawnTime = TimeSpan.Zero;
Random _random = new Random();
readonly Random _random = new Random();
private IContainer _container;
private ISpriteBatch _spriteBatch;
private IEnemyFactory _enemyFactory;
private GraphicsDeviceManager _graphics;
private readonly GraphicsDeviceManager _graphics;
public ShooterGame()
{

0 comments on commit 26a12e3

Please sign in to comment.