当前位置: 首页>>代码示例>>C#>>正文


C# Entity.AddComponent方法代码示例

本文整理汇总了C#中Entity.AddComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.AddComponent方法的具体用法?C# Entity.AddComponent怎么用?C# Entity.AddComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


在下文中一共展示了Entity.AddComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        public override void Initialize()
        {
            this.RegisterSystems();

            FPSCamera camera = new FPSCamera(new Vector3(0f, 0f, 0f), Vector3.Zero,
                Blackboard.Get<GraphicsDevice>("GraphicsDevice").Viewport.AspectRatio, 0.05f, 100f);

            Entity fpscounter = new Entity();
            fpscounter.AddComponent(new Transform2DComponent() { Position = new Vector2(5, 150) });
            fpscounter.AddComponent(new FPSCounterComponent());
            fpscounter.AddComponent(new GUITextComponent());

            Entity pos = new Entity();
            pos.AddComponent(new PositionalTrackingComponent() { Target = camera.Get<Transform3DComponent>() });
            pos.AddComponent(new GUITextComponent());
            pos.AddComponent(new Transform2DComponent() { Position = new Vector2(5, 180) });

            Entity model = new Entity();
            model.AddComponent(new Transform3DComponent(new Vector3(0f, -1f, 2f)));
            model.Get<Transform3DComponent>().Rotation = new Vector3(0f, MathHelper.PiOver2, 3f*MathHelper.PiOver2);
            Model m = Blackboard.Get<ContentManager>("ContentManager").Load<Model>("dragon");
            model.AddComponent(new ModelComponent() { Model = m });

            this.AddEntity(model);
            this.AddEntity(pos);
            this.AddEntity(fpscounter);
            this.AddEntity(camera);
        }
开发者ID:TheCommieDuck,项目名称:Pancakes,代码行数:28,代码来源:WaffleCatWorld.cs

示例2: BuildEntity

        public Entity BuildEntity(Entity e, params object[] args)
        {
            e.Tag = "Chassis";

            #region Body
            Body Chassis = e.AddComponent<Body>(new Body(_World, e));
            {
                Vertices vertices = new Vertices(8);
                vertices.Add(new Vector2(-2.5f, 0.08f));
                vertices.Add(new Vector2(-2.375f, -0.46f));
                vertices.Add(new Vector2(-0.58f, -0.92f));
                vertices.Add(new Vector2(0.46f, -0.92f));
                vertices.Add(new Vector2(2.5f, -0.17f));
                vertices.Add(new Vector2(2.5f, 0.205f));
                vertices.Add(new Vector2(2.3f, 0.33f));
                vertices.Add(new Vector2(-2.25f, 0.35f));
                PolygonShape chassisShape = new PolygonShape(vertices, 2f);

                Chassis.BodyType = BodyType.Dynamic;
                Chassis.Position = new Vector2(0.0f, -1.0f);
                Chassis.CreateFixture(chassisShape);
            }
            #endregion

            #region Sprite
            e.AddComponent<Sprite>(new Sprite(args[0] as Texture2D, (Rectangle)args[1],
               Chassis, 1, Color.White, 0f));
            #endregion
            return e;
        }
开发者ID:LostCodeStudios,项目名称:GameLib,代码行数:30,代码来源:ChassisTemplate.cs

示例3: Before

 public void Before() {
     var pool = Helper.CreatePool();
     _e = pool.CreateEntity();
     _e.AddComponent(CP.ComponentA, new ComponentA());
     _e.AddComponent(CP.ComponentB, new ComponentB());
     _e.AddComponent(CP.ComponentC, new ComponentC());
 }
开发者ID:ChicK00o,项目名称:Entitas-CSharp,代码行数:7,代码来源:EntityGetComponent.cs

示例4: 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

示例5: Before

 public void Before()
 {
     var context = Helper.CreateContext();
     _e = context.CreateEntity();
     _e.AddComponent(CP.ComponentA, new ComponentA());
     _e.AddComponent(CP.ComponentB, new ComponentB());
     _e.AddComponent(CP.ComponentC, new ComponentC());
 }
开发者ID:sschmid,项目名称:Entitas-CSharp,代码行数:8,代码来源:EntityGetComponents.cs

示例6: BuildEntity

 public Entity BuildEntity(Entity e)
 {
     e.Group = "EFFECTS";
     e.AddComponent(new Transform());
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Expires());
     e.GetComponent<SpatialForm>().SpatialFormFile = "BulletExplosion";
     e.GetComponent<Expires>().LifeTime = 1000;
     return e;
 }
开发者ID:sigod,项目名称:starwarrior_CSharp,代码行数:10,代码来源:BulletExplosionTemplate.cs

示例7: 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

示例8: BuildEntity

        public Entity BuildEntity(Entity e)
        {
            e.Group = "BULLETS";

            e.AddComponent(new Transform());
            e.AddComponent(new SpatialForm());
            e.AddComponent(new Velocity());
            e.AddComponent(new Expires());
            e.GetComponent<SpatialForm>().SpatialFormFile = "Missile";
            e.GetComponent<Expires>().LifeTime = 2000;
            return e;
        }
开发者ID:sigod,项目名称:starwarrior_CSharp,代码行数:12,代码来源:MissileTemplate.cs

示例9: InitTestEntities

        private static void InitTestEntities()
        {
            var e = new Entity("player");
            //e.Transform.Scale = new Vector2(0.5f, 0.5f);

            e.AddComponent(new SpriteComponent(e, Engine.Textures["crate"]));
            //e.AddComponent(new PlayerInput(e));
            e.AddComponent(new RectCollider(e) {Width = 96, Height = 96});
            e.AddComponent(new RectRenderer(e, Rectangle.Empty, new Texture2D(Engine.Window.GraphicsDevice, 1, 1)));

            Engine.Entities.AddEntity(e);
        }
开发者ID:jpgdev,项目名称:JPEngine,代码行数:12,代码来源:Game1.cs

示例10: BuildEntity

        public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
        {
            e.Group = "BULLETS";

            e.AddComponentFromPool<Transform>();
            e.AddComponent(new SpatialForm());
            e.AddComponent(new Velocity());
            e.AddComponent(new Expires());
            e.GetComponent<SpatialForm>().SpatialFormFile = "Missile";
            e.GetComponent<Expires>().LifeTime = 2000;
            return e;
        }
开发者ID:dackjaniels2001,项目名称:starwarrior_CSharp,代码行数:12,代码来源:MissileTemplate.cs

示例11: BuildEntity

 public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
 {
     e.Group = "SHIPS";
     e.AddComponentFromPool<Transform>();
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Health());
     e.AddComponent(new Weapon());
     e.AddComponent(new Enemy());
     e.AddComponent(new Velocity());
     e.GetComponent<SpatialForm>().SpatialFormFile = "EnemyShip";
     e.GetComponent<Health>().HP = 10;
     return e;
 }
开发者ID:dackjaniels2001,项目名称:starwarrior_CSharp,代码行数:13,代码来源:EnemyShipTemplate.cs

示例12: Before

 public void Before()
 {
     _context = Helper.CreateContext();
     _context.GetGroup(Matcher.AllOf(new [] { CP.ComponentA }));
     _e = _context.CreateEntity();
     _e.AddComponent(CP.ComponentA, new ComponentA());
 }
开发者ID:sschmid,项目名称:Entitas-CSharp,代码行数:7,代码来源:ContextOnEntityReplaced.cs

示例13: Before

 public void Before() {
     _pool = new Pool(CP.NumComponents);
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentA }));
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentB }));
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentC }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentB
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentC
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentB,
         CP.ComponentC
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentB,
         CP.ComponentC
     }));
     _e = new Entity(CP.NumComponents);
     _e.AddComponent(CP.ComponentA, new ComponentA());
 }
开发者ID:ntl92bk,项目名称:Entitas-CSharp,代码行数:25,代码来源:EntityReplaceComponent.cs

示例14: Before

 public void Before() {
     _pool = Helper.CreatePool();
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentA }));
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentB }));
     _pool.GetGroup(Matcher.AllOf(new [] { CP.ComponentC }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentB
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentC
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentB,
         CP.ComponentC
     }));
     _pool.GetGroup(Matcher.AllOf(new [] {
         CP.ComponentA,
         CP.ComponentB,
         CP.ComponentC
     }));
     _e = _pool.CreateEntity();
     _componentA = new ComponentA();
     _e.AddComponent(CP.ComponentA, _componentA);
 }
开发者ID:ChicK00o,项目名称:Entitas-CSharp,代码行数:26,代码来源:EntityRemoveAddComponent.cs

示例15: OnAdded

 public override void OnAdded(Entity entity)
 {
     if (entity.HasComponent<ShipComponent>())
     {
         entity.AddComponent(new SpatialTokenComponent { Token = Ships.AllocateToken(entity) });
     }
 }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:7,代码来源:SpatialDatabaseSystem.cs


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