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


C# Entity.Add方法代码示例

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


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

示例1: BuildEntity

        protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters)
        {
            entity.Transform.Position = parameters.Get<Vector2>(0);
            entity.Add(new CPlayerInfo(2));
            entity.Add<CCamera2D>(new CPlayerCamera2D());
            entity.Add<CWeapon>().Weapon = WeaponFactory.CreateDefaultWeapon();

            entity.Tag = EntityTags.Player;
        }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:9,代码来源:PlayerPrefab.cs

示例2: Attach

	public static void Attach(Entity result, Property<Vector3> property)
	{
		AkGameObjectTracker tracker = result.Get<AkGameObjectTracker>();
		if (tracker == null)
		{
			tracker = new AkGameObjectTracker();
			result.Add(tracker);
			tracker.Add(new Binding<Matrix, Vector3>(tracker.Matrix, x => Microsoft.Xna.Framework.Matrix.CreateTranslation(x), property));
		}
	}
开发者ID:sparker,项目名称:Lemma,代码行数:10,代码来源:AkGameObjectTracker.cs

示例3: LoadContent

        protected override async Task LoadContent()
        {
            await base.LoadContent();

            Window.AllowUserResizing = true;

            // Instantiate a scene with a single entity and model component
            var scene = new Scene();

            // Create a cube entity
            cubeEntity = new Entity();

            // Create a procedural model with a diffuse material
            var model = new Model();
            var material = Material.New(GraphicsDevice, new MaterialDescriptor
            {
                Attributes =
                {
                    Diffuse = new MaterialDiffuseMapFeature(new ComputeColor(Color.White)),
                    DiffuseModel = new MaterialDiffuseLambertModelFeature()
                }
            });
            model.Materials.Add(material);
            cubeEntity.Add(new ModelComponent(model));

            var modelDescriptor = new ProceduralModelDescriptor(new CubeProceduralModel());
            modelDescriptor.GenerateModel(Services, model);

            // Add the cube to the scene
            scene.Entities.Add(cubeEntity);

            // Create a camera entity and add it to the scene
            var cameraEntity = new Entity { new CameraComponent() };
            cameraEntity.Transform.Position = new Vector3(0, 0, 5);
            scene.Entities.Add(cameraEntity);

            // Create a light
            var lightEntity = new Entity()
            {
                new LightComponent()
            };

            lightEntity.Transform.Position = new Vector3(0, 0, 1);
            lightEntity.Transform.Rotation = Quaternion.RotationY(MathUtil.DegreesToRadians(45));
            scene.Entities.Add(lightEntity);

            // Create a graphics compositor
            var compositor = new SceneGraphicsCompositorLayers();

            bool isLDR = false;
            if (isLDR)
            {
                compositor.Master.Renderers.Add(new ClearRenderFrameRenderer());
                compositor.Master.Renderers.Add(new SceneCameraRenderer() {});
            }
            else
            {
                var layer = new SceneGraphicsLayer();
                var renderHDROutput = new LocalRenderFrameProvider { Descriptor = { Format = RenderFrameFormat.HDR, DepthFormat = RenderFrameDepthFormat.Shared} };
                layer.Output = renderHDROutput;
                layer.Renderers.Add(new ClearRenderFrameRenderer());
                layer.Renderers.Add(new SceneCameraRenderer());
                compositor.Layers.Add(layer);
                compositor.Master.Renderers.Add(new SceneEffectRenderer()
                {
                    Effect = new PostProcessingEffects()
                });
            }
            compositor.Cameras.Add(cameraEntity.Get<CameraComponent>());

            SceneSystem.SceneInstance = new SceneInstance(Services, scene);

            // Use this graphics compositor
            scene.Settings.GraphicsCompositor = compositor;

            // Create a scene instance
            SceneSystem.SceneInstance = new SceneInstance(Services, scene);
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:78,代码来源:TestScene.cs

示例4: GetUIEntity

        protected  Entity GetUIEntity(SpriteFont font, bool fixedSize, Vector3 position)
        {
            // Create and initialize "Touch Screen to Start"
            var touchStartLabel = new ContentDecorator
            {
                Content = new TextBlock
                {
                    Font = font,
                    TextSize = 32,
                    Text = (fixedSize) ? "Fixed Size UI" : "Regular UI",
                    TextColor = Color.White
                },
                Padding = new Thickness(30, 20, 30, 25),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            //touchStartLabel.SetPanelZIndex(1);

            var grid = new Grid
            {
                BackgroundColor = (fixedSize) ? new Color(255, 0, 255) : new Color(255, 255, 0),
                MaximumWidth = 100,
                MaximumHeight = 100,
                MinimumWidth = 100,
                MinimumHeight = 100,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition());
            grid.LayerDefinitions.Add(new StripDefinition());

            grid.Children.Add(touchStartLabel);

            // Add the background
            var background = new ImageElement { StretchType = StretchType.Fill };
            background.SetPanelZIndex(-1);

            var uiEntity = new Entity();

            // Create a procedural model with a diffuse material
            var uiComponent = new UIComponent();
            uiComponent.RootElement = new UniformGrid { Children = { background, grid } };

            uiComponent.Resolution = new Vector3(100, 100, 100);    // Same size as the inner grid
            uiComponent.IsFullScreen = false;
//            uiComponent.IsBillboard = true;
            uiComponent.IsFixedSize = fixedSize;
            uiComponent.Size = new Vector3(0.1f);   // 10% of the vertical resolution

            uiEntity.Add(uiComponent);

            uiEntity.Transform.Position = position;

            return uiEntity;
        }
开发者ID:cg123,项目名称:xenko,代码行数:57,代码来源:TestFixedSizeUI.cs

示例5: BuildEntity

 protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters)
 {
     entity.Add(new CVirtualThumbstick(parameters.Get<VirtualThumbstick>(0)));
     entity.Tag = EntityTags.VirtualThumbStick;
 }
开发者ID:JaakkoLipsanen,项目名称:Skypiea,代码行数:5,代码来源:VirtualThumbStickPrefab.cs


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