public override void LoadContent() { base.LoadContent(); var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(viewportAdapter); _map = Content.Load <TiledMap>("level-1"); _mapRenderer = new TiledMapRenderer(GraphicsDevice); _entityComponentSystem = new EntityComponentSystem(); _entityFactory = new EntityFactory(_entityComponentSystem, Content); var service = new TiledObjectToEntityService(_entityFactory); var spawnPoint = _map.GetLayer <TiledMapObjectLayer>("entities").Objects.Single(i => i.Type == "Spawn").Position; _entityComponentSystem.RegisterSystem(new PlayerMovementSystem()); _entityComponentSystem.RegisterSystem(new EnemyMovementSystem()); _entityComponentSystem.RegisterSystem(new CharacterStateSystem(_entityFactory, spawnPoint)); _entityComponentSystem.RegisterSystem(new BasicCollisionSystem(gravity: new Vector2(0, 1150))); _entityComponentSystem.RegisterSystem(new ParticleEmitterSystem()); _entityComponentSystem.RegisterSystem(new AnimatedSpriteSystem()); _entityComponentSystem.RegisterSystem(new SpriteBatchSystem(GraphicsDevice, _camera) { SamplerState = SamplerState.PointClamp }); service.CreateEntities(_map.GetLayer <TiledMapObjectLayer>("entities").Objects); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 1024, 768); _mapRenderer = new TiledMapRenderer(GraphicsDevice); _camera = new Camera2D(_viewportAdapter); _entityComponentSystem = new EntityComponentSystem(); _entityFactory = new EntityFactory(_entityComponentSystem); _objectToEntityService = new TiledObjectToEntityService(_entityFactory); position = Vector2.Zero; base.Initialize(); }
protected override void LoadContent() { base.LoadContent(); var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _camera = new Camera2D(viewportAdapter); Services.AddService(_camera); _spriteBatch = new SpriteBatch(GraphicsDevice); Services.AddService(_spriteBatch); _map = Content.Load <TiledMap>("level-1"); _mapRenderer = new TiledMapRenderer(GraphicsDevice); _entityFactory = new EntityFactory(_ecs, Content); var service = new TiledObjectToEntityService(_entityFactory); var spawnPoint = _map.GetLayer <TiledMapObjectLayer>("entities").Objects.Single(i => i.Type == "Spawn").Position; service.CreateEntities(_map.GetLayer <TiledMapObjectLayer>("entities").Objects); }