コード例 #1
0
ファイル: Game1.cs プロジェクト: MichalKubik/GameTest
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            _map = Content.Load <TiledMap>("level01");

            _entityComponentSystem.RegisterSystem(new CollisionSystem());
            _entityComponentSystem.RegisterSystem(new SpriteBatchSystem(GraphicsDevice, _camera));
            _entityComponentSystem.RegisterSystem(new PlayerMovementSystem());

            _objectToEntityService.createEntities(_map.GetLayer <TiledMapObjectLayer>("entities").Objects);
        }
コード例 #2
0
        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);
        }