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


C# Entity.AddAttribute方法代码示例

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


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

示例1: AddAttributes

 private void AddAttributes( Dictionary<string, object> attributes, Entity entity )
 {
     // create and load data for all entity attributes
     foreach ( KeyValuePair<string, object> attributeData in attributes ) {
         // TODO: make sure these attributes are deep copied
         entity.AddAttribute( attributeData.Key, attributeData.Value );
     }
 }
开发者ID:tgorkin,项目名称:XEngine,代码行数:8,代码来源:EntityFactory.cs

示例2: AddTestComponent

        public static void AddTestComponent(Entity entity)
        {
            // Setup a velocity attribute
            Vector3 velocity = new Vector3(0, 0, -1.0f);
            entity.AddAttribute( Attributes.VELOCITY, velocity );

            // Add the test component
            MoveComponent moveComponent = new MoveComponent( entity );
            entity.AddComponent( moveComponent );
        }
开发者ID:tgorkin,项目名称:XEngine,代码行数:10,代码来源:MoveComponent.cs

示例3: AddTestComponent

        public static void AddTestComponent( Entity entity, GeometricPrimitiveType primitiveType, float size )
        {
            Transform transform = new Transform();
            entity.AddAttribute( Attributes.TRANSFORM, transform );

            PrimitiveRenderComponent renderComponent = new PrimitiveRenderComponent( entity );
            renderComponent.GeometricPrimitiveType = primitiveType;
            renderComponent.Color = Color.LimeGreen;
            renderComponent.Wireframe = false;
            renderComponent.m_size = size;
            entity.AddComponent( renderComponent );
        }
开发者ID:tgorkin,项目名称:XEngine,代码行数:12,代码来源:PrimitiveRenderComponent.cs

示例4: CreateEntity

        private Entity CreateEntity(ParseTreeNode node, Scene scene, bool prototype)
        {
            Entity entity = new Entity() { Name = grammar.GetName(node), IsPrototype = prototype };

            foreach (string name in grammar.GetPrototypes(node)) entity.AddPrototype(game.GetPrototype(name));

            foreach (Tuple<string, object> attribute in GetProperties(node))
            {
                ParseTreeNode attributeNode = (ParseTreeNode)attribute.Item2;
                entity.AddAttribute(new Attribute(attribute.Item1) { Value = new Value(getStrVal(attributeNode)) });
            }

            foreach (ParseTreeNode componentNode in grammar.GetOfType(node, grammar.Component))
            {
                // Adding a component adds any other components that the new component requires.
                // It is necessary to check if the component we are attempting to add already
                // exists. If it does, we should not attempt to create a new component.

                Plugin plugin = game.GetPlugin(grammar.GetName(componentNode));

                Component component = entity.GetComponentByType(plugin.CoreType);
                if (null == component)
                {
                    component = new Component(plugin);
                    entity.AddComponent(component);
                }

                foreach (Tuple<string, object> property in GetProperties(componentNode))
                {
                    ParseTreeNode propertyNode = (ParseTreeNode)property.Item2;
                    component.SetProperty(property.Item1, new Value(getStrVal(propertyNode)));
                }
            }

            foreach (ParseTreeNode eventNode in grammar.GetOfType(node, grammar.Evt))
            {
                Event evt = CreateEvent(eventNode);
                entity.AddEvent(evt);
            }

            return entity;
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:42,代码来源:KglGameStorage.cs

示例5: Entity_RemoveAttribute

        public void Entity_RemoveAttribute()
        {
            var entity = new Entity();
            var attribute = new Attribute("test");
            entity.AddAttribute(attribute);
            entity.SelectedAttribute = attribute;

            CommandHelper.TestUndoableCommand(
                () => Assert.AreEqual(1, entity.Attributes.Count),
                () => entity.RemoveAttributeCommand.Execute(null),
                () => Assert.AreEqual(0, entity.Attributes.Count)
            );
        }
开发者ID:kinectitude,项目名称:kinectitude,代码行数:13,代码来源:CommandTests.cs

示例6: ComponentTest

        public static void ComponentTest()
        {
            XEngineComponentTest testGame = new XEngineComponentTest();

            Entity entity1 = null;
            Entity entity2 = null;
            testGame.InitDelegate = delegate {
                entity1 = new Entity();
                AddShipTestComponent( entity1 );
                entity1.AddAttribute( Attributes.TRANSFORM, new Transform( new Vector3( 0, 1.0f, 0 ) ) );
                entity1.Initialize();

                entity2 = new Entity();
                AddGridTestComponent( entity2 );
                entity2.Initialize();
            };
            testGame.DrawDelegate = delegate( GameTime gameTime ) {
                entity1.Draw( gameTime );
                entity2.Draw( gameTime );
            };
            testGame.Run();
        }
开发者ID:tgorkin,项目名称:XEngine,代码行数:22,代码来源:ModelRenderComponent.cs


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