public Ingame(Game game) { Game = game; Ecs = new EntityComponentSystem(Game); EntityFactory = new EntityFactory(Game, Ecs); LevelManager = new LevelManager(Game); }
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); }
public GameMain() { Content.RootDirectory = "Content"; IsMouseVisible = true; Window.AllowUserResizing = false; IsFixedTimeStep = true; _graphicsDeviceManager = new GraphicsDeviceManager(this) { IsFullScreen = false, PreferredBackBufferWidth = 800, PreferredBackBufferHeight = 600, PreferredBackBufferFormat = SurfaceFormat.Color, PreferMultiSampling = false, PreferredDepthStencilFormat = DepthFormat.None, SynchronizeWithVerticalRetrace = true, }; _ecs = new EntityComponentSystem(this); _entityManager = _ecs.EntityManager; // scan for components and systems in provided assemblies _ecs.Scan(Assembly.GetExecutingAssembly()); Services.AddService(Content); Services.AddService(_ecs); Services.AddService(_random); }
public EntityFactory(EntityComponentSystem ecs, ContentManager contentManager) { _ecs = ecs; _entityManager = ecs.EntityManager; LoadContent(contentManager); }
public EntityFactory(EntityComponentSystem entityComponentSystem) { _entityComponentSystem = entityComponentSystem; var texture = Game1.Instance.Content.Load <Texture2D>("free-tileset"); _tilesetAtlas = TextureAtlas.Create("tiny-characters-atlas", texture, 128, 128, 100, 2, 2); }
protected override void Initialize() { _ecs = new EntityComponentSystem(this); Services.AddService(_ecs); _ecs.Scan(Assembly.GetExecutingAssembly()); base.Initialize(); }
protected override void Initialize() { esc = new EntityComponentSystem(this); entityManager = esc.EntityManager; esc.Scan(Assembly.GetExecutingAssembly()); Services.AddService(spriteBatch); base.Initialize(); }
/// <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(); }
public void ECS_CreateEntityFromTemplate_UsingManager_Test() { // Seems to work with null. var ecs = new EntityComponentSystem(null); ecs.Scan(typeof(EntityTemplateUsingManager).Assembly); var manager = ecs.EntityManager; Entity entity = null; try { entity = manager.CreateEntityFromTemplate(EntityTemplateUsingManager.Name); } catch (Exception e) { Assert.Fail("Failed to create entity from template.\n" + e.StackTrace); } Assert.NotNull(entity); Assert.NotNull(entity.Get <EntityComponentBasic>()); }
public EntityFactory(EntityComponentSystem entityComponentSystem, ContentManager contentManager) { _entityComponentSystem = entityComponentSystem; LoadContent(contentManager); }
public EntityFactory(Game game, EntityComponentSystem ecs) : base(game) { Content = new ContentManager(Game.Content.ServiceProvider, game.Content.RootDirectory); Ecs = ecs; }