• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Artemis.EntityWorld类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Artemis.EntityWorld的典型用法代码示例。如果您正苦于以下问题:C# EntityWorld类的具体用法?C# EntityWorld怎么用?C# EntityWorld使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EntityWorld类属于Artemis命名空间,在下文中一共展示了EntityWorld类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            this.spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: Add your initialization logic here
            this.world = new EntityWorld();

            this.world.SystemManager.SetSystem(new PlayerShipControlSystem(), ExecutionType.Update);
            this.world.SystemManager.SetSystem(new MovementSystem(this.GraphicsDevice), ExecutionType.Update);
            this.world.SystemManager.SetSystem(new RenderSystem(GraphicsDevice, this.spriteBatch), ExecutionType.Draw);

            this.world.SystemManager.InitializeAll();

            // initialize player
            Entity entity = this.world.CreateEntity();
            entity.AddComponent(new Placement(
                new Vector2(this.GraphicsDevice.Viewport.Width / 2, this.GraphicsDevice.Viewport.Height / 2),
                270.0f
            ));
            entity.AddComponent(new Acceleration());
            entity.AddComponent(new Velocity());
            entity.AddComponent(new SpatialForm(SpatialForms.Player));
            entity.Refresh();

            entity.Tag = "PLAYER";

            base.Initialize();
        }
开发者ID:sigod,项目名称:asteroids,代码行数:35,代码来源:Game1.cs


示例2: Start

            public void Start()
            {
                GameWindow.Window = new RenderWindow(new VideoMode(1280, 720), "Subject2Change");
                GameWindow.Window.SetFramerateLimit(120);
                GameWindow.Window.SetVisible(true);

                GameWindow.Window.Closed += OnClosed;
                GameWindow.Window.KeyPressed += GameEventHandler.OnKeyPressed;
                GameWindow.Window.Resized += GameEventHandler.OnResized;
                GameWindow.Window.KeyReleased += GameEventHandler.OnKeyReleased;

                _world = new EntityWorld(false, true, true);

                //Entity camera = _world.CreateEntityFromTemplate("camera");
                EntityFactory.CreatePlayer(_world);

                Sprite testSprite = SFMLwrap.LoadSprite("test.png", SFMLwrap.DefaultScale);

                while (GameWindow.Window.IsOpen())
                {
                    GameWindow.Window.DispatchEvents();
                    GameWindow.Window.Clear(Color.Blue);
                    testSprite.Position = EntityFactory.Player.GetComponent<TransformC>().Position;
                    _world.Update();
                    //SpriteBatch batch = new SpriteBatch(GameWindow.Window);

                    GameWindow.Window.Draw(testSprite);
                    GameWindow.Window.Display();
                }
            }
开发者ID:krixalis,项目名称:Subject2Change,代码行数:30,代码来源:Program.cs


示例3: BuildEntity

 public Entity BuildEntity(Entity et1, EntityWorld world , params object[] args)
 {
     et1.AddComponent(new Power());
     et1.GetComponent<Power>().POWER = 100;
     et1.Refresh();
     return et1;
 }
开发者ID:dackjaniels2001,项目名称:artemis_CSharp,代码行数:7,代码来源:EntTemplate.cs


示例4: BattleWorld

        public BattleWorld(IHeroesService heroesService, GraphicResources graphicResources)
        {
            _heroesService = heroesService;
            _content = graphicResources.Content;
            _entityWorld = new EntityWorld();
            var systemManager = _entityWorld.SystemManager;
            EntityCreator entityCreator = new EntityCreator(_entityWorld);
            BattleEngine.EntityCreator = entityCreator;
            _fighterManager = new FighterManager(_entityWorld);
            EntitySystem.BlackBoard.SetEntry("Resources", graphicResources);

            systemManager.SetSystem(new CharacterPlacingSystem(graphicResources), GameLoopType.Update, 0);
            systemManager.SetSystem(new EffectManagerSystem(), GameLoopType.Update, 0);
            systemManager.SetSystem(new MovingSystem(), GameLoopType.Update, 1);
            systemManager.SetSystem(new ActingSystem(), GameLoopType.Update, 3);
            systemManager.SetSystem(new AISkillSelectionSystem(_fighterManager), GameLoopType.Update, 4);
            systemManager.SetSystem(new ExpirationSystem(), GameLoopType.Update, 5);
            systemManager.SetSystem(new InputSkillSelectionSystem(_fighterManager, graphicResources), GameLoopType.Update, 5);
            systemManager.SetSystem(new AnimationSystem(entityCreator), GameLoopType.Update, 5);
            systemManager.SetSystem(new ParticleGeneratorSystem(), GameLoopType.Update, 5);

            systemManager.SetSystem(new ImageRenderingSystem(graphicResources), GameLoopType.Draw, 0);
            systemManager.SetSystem(new CharacterInfoRenderingSystem(graphicResources), GameLoopType.Draw, 1);
            systemManager.SetSystem(new ParticleRenderingSystem(graphicResources), GameLoopType.Draw, 1);
            systemManager.SetSystem(new ColoredTextRenderingSystem(graphicResources), GameLoopType.Draw, 2);
            systemManager.SetSystem(new InputSkillSelectionRenderingSystem(graphicResources), GameLoopType.Draw, 2);
        }
开发者ID:nicojans,项目名称:FinalQuest,代码行数:27,代码来源:BattleWorld.cs


示例5: Initialize

        protected override void Initialize()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            Type[] types = new Type[] {typeof(Enemy),typeof(Expires),typeof(Health),typeof(SpatialForm),typeof(Transform),typeof(Velocity),typeof(Weapon)};
            pool = new GamePool(100,types);
            pool.Initialize();

            spriteBatch = new SpriteBatch(GraphicsDevice);
            world = new EntityWorld();
            world.GetEntityManager().RemovedComponentEvent += new RemovedComponentHandler(RemovedComponent);
            world.SetPool(pool);

            font = Content.Load<SpriteFont>("Arial");
            SystemManager systemManager = world.GetSystemManager();
            renderSystem = systemManager.SetSystem(new RenderSystem(GraphicsDevice,spriteBatch,Content),ExecutionType.Draw);
            hudRenderSystem = systemManager.SetSystem(new HudRenderSystem(spriteBatch, font), ExecutionType.Draw);
            controlSystem = systemManager.SetSystem(new MovementSystem(spriteBatch), ExecutionType.Update,1);
            movementSystem = systemManager.SetSystem(new PlayerShipControlSystem(spriteBatch),ExecutionType.Update);
            enemyShooterSystem = systemManager.SetSystem(new EnemyShipMovementSystem(spriteBatch), ExecutionType.Update,1);
            enemyShipMovementSystem = systemManager.SetSystem(new EnemyShooterSystem(), ExecutionType.Update);
            collisionSystem = systemManager.SetSystem(new CollisionSystem(), ExecutionType.Update,1);
            healthBarRenderSystem = systemManager.SetSystem(new HealthBarRenderSystem(spriteBatch, font), ExecutionType.Draw);
            enemySpawnSystem = systemManager.SetSystem(new EnemySpawnSystem(500, spriteBatch), ExecutionType.Update);
            expirationSystem = systemManager.SetSystem(new ExpirationSystem(), ExecutionType.Update);

            systemManager.InitializeAll();

            InitPlayerShip();
            InitEnemyShips();

            base.Initialize();
        }
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:32,代码来源:Game1.cs


示例6: Intro

        private IEnumerable Intro(Story story, EntityWorld world)
        {
            var bgGenerator = ServiceLocator.Instance.GetService<SpaceBackgroundGeneratorService>();
            bgGenerator.GenerateBackground(world, 12345);

            var entity = world.CreateStoryOverlay(Properties.Resources.String_ActOne_Intro01);

            yield return Coroutine.WaitFor(TimeSpan.FromSeconds(2));
            entity.FadeGuiElement(TimeSpan.FromSeconds(1.5), 0)
                .OnDone = () => entity.Delete();
            yield return Coroutine.WaitFor(TimeSpan.FromSeconds(2));

            var variant = new ShipVariant
            {
                HullId = "Jormugand",
                TrimDecalColor = Color.Cyan,
                BaseDecalColor = new Color(212, 113, 108),
            };
            _playerEntity = world.CreateShip(variant, new Vector2(500,0),0, physics:true);
            _playerEntity.Tag = "PlayerShip";
            _playerEntity.Refresh();
            var cameraControl = world.SystemManager.GetSystem<Systems.CameraControlSystem>();
            cameraControl.Mode = Systems.CameraMode.FollowEntity;
            cameraControl.FollowedEntity = _playerEntity;

            var test = world.CreateShip("mobius", new Vector2(0, 0), MathHelper.Pi * 1.5f, physics:true);
            test.GetComponent<ShipModelComponent>().BaseDecalColor = Color.Khaki;

            story.State.Fire(Story.Triggers.NextScene);
            yield return null;
        }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:31,代码来源:ActOne.cs


示例7: AttributesTestsMethod

        public void AttributesTestsMethod()
        {
            EntityWorld world = new EntityWorld();
            world.PoolCleanupDelay = 1;
            world.InitializeAll();

            Debug.Assert(world.SystemManager.Systems.Size == 2);

            Entity et = world.CreateEntity();
            var power = et.AddComponentFromPool<Power2>();
            power.POWER = 100;
            et.Refresh();

            Entity et1 = world.CreateEntityFromTemplate("teste");
            Debug.Assert(et1 != null);

            {
                world.Update(0, ExecutionType.UpdateSynchronous);
            }

            et.RemoveComponent<Power2>();
            et.Refresh();

            {
                world.Update(0, ExecutionType.UpdateSynchronous);
            }

            et.AddComponentFromPool<Power2>();
            et.GetComponent<Power2>().POWER = 100;
            et.Refresh();

            world.Update(0, ExecutionType.UpdateSynchronous);
        }
开发者ID:dackjaniels2001,项目名称:artemis_CSharp,代码行数:33,代码来源:GeneralTest.cs


示例8: CreateTestHealthEntityWithId

 /// <summary>Creates the test health entity with ID.</summary>
 /// <param name="entityWorld">The entity world.</param>
 /// <param name="id">The id.</param>
 /// <returns>The Entity.</returns>
 public static Entity CreateTestHealthEntityWithId(EntityWorld entityWorld, long id)
 {
     Entity entity = entityWorld.CreateEntity(id);
     entity.AddComponent(new TestHealthComponent());
     entity.GetComponent<TestHealthComponent>().Points = 100;            
     return entity;
 }
开发者ID:KellanHiggins,项目名称:artemis_CSharp,代码行数:11,代码来源:TestEntityFactory.cs


示例9: SpriteSystem

 public SpriteSystem(EntityWorld world)
     : base(Aspect.All(
         typeof(Sprite),
         typeof(Renderable),
         typeof(Position)))
 {
     _world = world;
 }
开发者ID:zunath,项目名称:MMXEngine,代码行数:8,代码来源:SpriteSystem.cs


示例10: Initialize

        public void Initialize(EntityWorld entityWorld, IEntityFactory entityFactory)
        {
            _entityWorld = entityWorld;
            EntityFactory = entityFactory;

            _entityWorld.EntityManager.AddedEntityEvent += OnEntityAdded;
            _entityWorld.EntityManager.RemovedEntityEvent += OnEntityRemoved;
        }
开发者ID:jtuttle,项目名称:umbra-client,代码行数:8,代码来源:CrawEntityManager.cs


示例11: BuildEntity

        public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
        {
            e.AddComponent(new Position());

            e.Refresh();

            return e;
        }
开发者ID:krixalis,项目名称:Subject2Change,代码行数:8,代码来源:Templates.cs


示例12: BuildEntity

 public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args)
 {
     var shipDef = Game.WorldConfiguration.Ships[args[0] as string];
     entity.AddComponent(new ModelComponent(shipDef.Model));
     entity.AddComponent(new SceneGraphNode());
     entity.AddComponent(shipDef);
     return entity;
 }
开发者ID:raycrasher,项目名称:Project-Misplaced-Optimism,代码行数:8,代码来源:ShipEntityTemplate.cs


示例13: HeartbeatSystem

 public HeartbeatSystem(IScriptManager scriptManager,
     EntityWorld world)
     : base(Aspect.All(typeof(Heartbeat),
         typeof(Script)))
 {
     _scriptManager = scriptManager;
     _world = world;
 }
开发者ID:zunath,项目名称:MMXEngine,代码行数:8,代码来源:HeartbeatSystem.cs


示例14: BuildEntity

        /// <summary>The build entity.</summary>
        /// <param name="entity">The entity.</param>
        /// <param name="entityWorld">The entity world.</param>
        /// <param name="args">The args.</param>
        /// <returns>The built <see cref="Entity" />.</returns>
        public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args)
        {
            entity.AddComponent(new TestPowerComponent());
            entity.GetComponent<TestPowerComponent>().Power = 100;

            entity.Refresh();

            return entity;
        }
开发者ID:KellanHiggins,项目名称:artemis_CSharp,代码行数:14,代码来源:TestEntityTemplate.cs


示例15: BuildEntity

 public Entity BuildEntity(Entity entity, EntityWorld entityWorld, params object[] args)
 {
     PhysicsBody body = entity.AddComponentFromPool<SPShared.ECS.Components.PhysicsBody>();
     body.Body.Shape = shipShape;
     PhysicsSystem physicsSystem = entityWorld.SystemManager.GetSystem<PhysicsSystem>();
     physicsSystem.AddBody(body);
     physicsSystem.AddConstraint(new Constraint2D(body.Body));
     return entity;
 }
开发者ID:coryleeio,项目名称:SPShared,代码行数:9,代码来源:ShipTemplate.cs


示例16: UnitController

 public UnitController(InputManager inputManager, InputState inputState, EntityWorld entityWorld, DisFieldMixer disFieldMixer, Lord lord)
 {
     this.inputManager = inputManager;
     this.inputState = inputState;
     this.entityWorld = entityWorld;
     this.disFieldMixer = disFieldMixer;
     this.lord = lord;
     pathGoal = null;
 }
开发者ID:CheeseSoftware,项目名称:RTS-test,代码行数:9,代码来源:UnitController.cs


示例17: Start

 void Start()
 {
     world = new EntityWorld (false, true, true);
     world.InitializeAll (true);
     Entity e = world.CreateEntityFromTemplate ("Ship");
     GameObject obj = new GameObject("Ship");
     PhysicsRelay relay = obj.AddComponent<PhysicsRelay>();
     relay.SetEntity (e);
 }
开发者ID:coryleeio,项目名称:SPClient,代码行数:9,代码来源:ECSTest.cs


示例18: LoadTiledMap

        // BuildEntity(entity, entityWorld)
        public static void LoadTiledMap(EntityWorld entityWorld, string mapFile, string tilesetLocation)
        {
            // Actual map entity. Contains map data. Rendering system draws map from this entity
            Entity tiledMapEntity = entityWorld.CreateEntity();
            tiledMapEntity.Tag = "map";
            tiledMapEntity.AddComponent(new TransformComponent());
            tiledMapEntity.AddComponent(new TiledMapComponent(mapFile, tilesetLocation));
            TmxMap tmxMap = tiledMapEntity.GetComponent<TiledMapComponent>().Map;
            List<Texture2D> textures = tiledMapEntity.GetComponent<TiledMapComponent>().Textures;

            // Farseer world associated with map
            Entity farseerWorldEntity = entityWorld.CreateEntity();
            farseerWorldEntity.AddComponent(new FarseerWorldComponent(9.81f));
            World world = farseerWorldEntity.GetComponent<FarseerWorldComponent>().world;
            
            foreach (var objLayer in tmxMap.ObjectGroups)
            {
                // Create entities for static objects in map
                // TODO: If there are performance issues, can optimize all static objects into single entity
                if (objLayer.Name == "collision")
                {
                    foreach (var tmxObj in objLayer.Objects)
                    {
                        Entity fixtureEntity = entityWorld.CreateEntity();
                        fixtureEntity.AddComponent(new FarseerFixtureComponent(tmxObj, world));
                    }
                }

                // Create dynamic objects
                // In particular starting location of player is in here
                if (objLayer.Name == "dynamic")
                {
                    foreach (var tmxObj in objLayer.Objects)
                    {
                        tmxObj.Properties.Add("BodyType", "Dynamic");
                        Entity dynamicEntity = entityWorld.CreateEntity();

                        if (tmxObj.Tile != null)
                        {
                            dynamicEntity.AddComponent(new TransformComponent());

                            Texture2D texture = GetTexture(tmxMap, textures, tmxObj.Tile.Gid);
                            dynamicEntity.AddComponent(new TextureComponent(texture));
                        }

                        dynamicEntity.AddComponent(new FarseerFixtureComponent(tmxObj, world));

                        if (tmxObj.Name == "player")
                        {
                            dynamicEntity.Tag = "player";
                        }
                    }
                }
            }

        }
开发者ID:AnotherProgrammingGroup,项目名称:Project-CS,代码行数:57,代码来源:LoadTiledMapUtility.cs


示例19: CreateChildEntities

 public void CreateChildEntities(EntityWorld world, Entity parentEntity)
 {
     var modelComponent = new ShipModelComponent { Model = this };
     parentEntity.AddComponent(modelComponent);
     foreach (var part in Parts)
     {
         part.CreateEntity(world, parentEntity);
     }
     modelComponent.BoundingBox = CalculateBoundingBox(0);
 }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:10,代码来源:ShipModel.cs


示例20: BuildEntity

 public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
 {
     e.Group = "EFFECTS";
     e.AddComponentFromPool<Transform>();
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Expires());
     e.GetComponent<SpatialForm>().SpatialFormFile = "ShipExplosion";
     e.GetComponent<Expires>().LifeTime = 1000;
     return e;
 }
开发者ID:dackjaniels2001,项目名称:starwarrior_CSharp,代码行数:10,代码来源:ShipExplosionTemplate.cs



注:本文中的Artemis.EntityWorld类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Service.OperationResult类代码示例发布时间:2022-05-24
下一篇:
C# AriCliModel.AriClinicContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap