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


C# World.AddEntity方法代码示例

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


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

示例1: BlockUpdate

 /// <summary>
 /// Called when an action in the world causes this block to update.
 /// </summary>
 /// <param name="world">The world the update occured in</param>
 /// <param name="position">The location of the updated block</param>
 /// <remarks></remarks>
 public override void BlockUpdate(World world, Vector3 position)
 {
     Block b = world.GetBlock(position + Vector3.Down);
     if (b is AirBlock ||
         b is WaterFlowingBlock ||
         b is WaterStillBlock ||
         b is LavaFlowingBlock ||
         b is LavaStillBlock)
     {
         world.AddEntity(new FallingEnderDragonEggEntity(position));
         world.SetBlock(position, new AirBlock());
     }
 }
开发者ID:vatt849,项目名称:LibMinecraft,代码行数:19,代码来源:EnderdragonEggBlock.cs

示例2: Main

        static void Main(string[] args)
        {
            var world = new World();

            world.AddSystem(new MovementSystem());
            world.AddSystem(new RenderingSystem());

            world.AddEntity((e) =>
            {
                e.AddComponent(new PositionComponent(0, 0));
                e.AddComponent(new VelocityComponent(0.7, 0.3));
            });

            world.AddEntity((e) =>
            {
                e.AddComponent(new PositionComponent(24, 7));
            });

            world.AddEntity((e) =>
            {
                e.AddComponent(new PositionComponent(0, 0));
                e.AddComponent(new VelocityComponent(-0.64, 0.42));
            });

            double delta = 0;

            while (true)
            {
                world.Process(delta);

                Console.Write(">");
                var input = Console.ReadLine();
                if (input != null && input.ToLowerInvariant() == "q")
                    return;

                delta = 0.5;
            }
        }
开发者ID:bnwasteland,项目名称:diana,代码行数:38,代码来源:Program.cs

示例3: TestForm_Load

        private void TestForm_Load(object sender, EventArgs e)
        {
            _world = new World();
            _inputService = _world.Get<Services.Input>();
            _renderingService = _world.Get<Services.Rendering>();

            Entity protoPlayer = new Entity(1,
                typeof(Position),
                typeof(PreviousPosition),
                typeof(Direction),
                typeof(Health),
                typeof(Body),
                typeof(Animation),
                typeof(Viewport),
                typeof(Hotspots));

            /*Entity player = new Entity(1,
                typeof(Position),
                typeof(PreviousPosition),
                typeof(Direction),
                typeof(Health),
                typeof(Body),
                typeof(Animation),
                typeof(Input),
                typeof(Viewport),
                typeof(WorldCollisionTag),
                typeof(Hotspots));*/
            Entity player = new Entity(1, protoPlayer,
                typeof(Input),
                typeof(WorldCollisionTag));
            Entity droppingPlayer = new Entity(1, protoPlayer,
                typeof(TypeChanger));

            player.Create();
            player.Get<Input>().DroppingPlayer = droppingPlayer;
            player.Get<Animation>().Sprite = Image.FromFile("test.png");
            player.Get<Body>().Friction[0] = 0;
            player.Get<Body>().Weight[0] = 1.8f;
            {
                var viewport = player.Get<Viewport>();
                viewport.Left = 0;
                viewport.Top = 0;
                viewport.Width = 200;
                viewport.Height = 200;
            }
            {
                var hotspots = player.Get<Hotspots>();
                hotspots.Bottom[0] = new List<Point>();
                hotspots.Bottom[0].Add(new Point(32, 64));
                hotspots.Top[0] = new List<Point>();
                hotspots.Left[0] = new List<Point>();
                hotspots.Right[0] = new List<Point>();
            }

            Entity map = new Entity(1,
                typeof(Tilemap),
                typeof(Tilesheet),
                typeof(Viewport),
                typeof(Position));
            map.Get<Tilemap>().GenerateTest();
            {
                var viewport = map.Get<Viewport>();
                viewport.Top = 200;
                viewport.Width = 800;
                viewport.Height = 600;
            }
            {
                var tilesheet = map.Get<Tilesheet>();
                tilesheet.TileWidth = 64;
                tilesheet.TileHeight = 64;
                tilesheet.PaddingBottom = tilesheet.PaddingRight = 1;
                tilesheet.Rows = 2;
                tilesheet.Columns = 2;
                tilesheet.Sheet = Image.FromFile("tilesheet.PNG");
            }

            _world.AddEntity(player);
            _world.AddEntity(droppingPlayer);
            _world.AddEntity(map);
        }
开发者ID:LorenzJ,项目名称:ComponentTest,代码行数:80,代码来源:TestForm.cs


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