Beispiel #1
0
        public PipeSet(Entity referencePipeEntity, float scrollSpeed, float startScrollPos, float screenWidth)
        {
            this.scrollSpeed = scrollSpeed;
            this.startScrollPos = startScrollPos;
            halfScrollWidth = screenWidth / 2f;

            // Store Entity and create another one for two rendering:
            // top and bottom sprite of pipe.
            var spriteComp = referencePipeEntity.Get<SpriteComponent>();
             bottomPipe = referencePipeEntity.Clone();
            topPipe = referencePipeEntity.Clone();
            Entity.AddChild(bottomPipe);
            Entity.AddChild(topPipe);

            var sprite = spriteComp.CurrentSprite;
            pipeWidth = sprite.SizeInPixels.X;
            pipeHeight = sprite.SizeInPixels.Y;
            halfPipeWidth = pipeWidth/2f;

            // Setup pipeCollider
            pipeCollider = new RectangleF(0, 0, pipeWidth, pipeHeight);

            // Place the top/bottom pipes relatively to the root.
            topPipe.Transform.Position.Y = -(VerticalDistanceBetweenPipe + pipeHeight) * 0.5f;
            bottomPipe.Transform.Position.Y = (VerticalDistanceBetweenPipe + pipeHeight) * 0.5f;
            bottomPipe.Transform.Rotation = Quaternion.RotationZ(MathUtil.Pi);

            ResetPipe();
        }
Beispiel #2
0
        private void CreateCube(string name, Vector3 position, float scaleFactor, float angleStep, float speed)
        {
            var cube = new Entity(name)
                           .AddComponent(new Transform3D() { Position = position, Scale = new Vector3(scaleFactor) })
                           .AddComponent(Model.CreateCube())
                            .AddComponent(new MaterialsMap(new BasicMaterial(GenerateRandomColors())))
                       .AddComponent(new ModelRenderer())
                       .AddComponent(new CubeBehavior(name, angleStep, speed));

            EntityManager.Add(cube);

            var clone = cube.Clone(name + "_1");
            clone.FindComponent<Transform3D>().Position = new Vector3(position.X + 5, position.Y + 5, position.Z + 5);
            EntityManager.Add(clone);

            clone = cube.Clone(name + "_2");
            clone.FindComponent<Transform3D>().Position = new Vector3(position.X - 5, position.Y - 5, position.Z - 5);
            EntityManager.Add(clone);
        }
Beispiel #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ent"></param>
        /// <param name="position"></param>
        /// <param name="rotation"></param>
        /// <param name="scale"></param>
        /// <param name="color"></param>
        public override void AddEntity(Entity entity, Vector3 position, Quaternion rotation, Vector3 scale, ColorEx color)
        {
            SceneNode node = mRootNode.CreateChildSceneNode();
            node.Position = position;
            mNodeList.Add(node);

            Entity ent = entity.Clone(GetUniqueID());
            ent.CastShadows = false;
            ent.RenderQueueGroup = entity.RenderQueueGroup;
            node.AttachObject(ent);
        }
            /// <summary>
            /// 从指定的对象中拷贝所有数据到另一对象中。
            /// 
            /// 默认实体只拷贝所有数据属性。
            /// 子类可重写此方法来拷贝更多一般字段。
            /// </summary>
            /// <param name="src">数据源对象。</param>
            /// <param name="dst">目标对象。</param>
            protected virtual void MemoryClone(Entity src, Entity dst)
            {
                //同时由于以下代码只是对托管属性进行了拷贝,会导致一些一般字段无法复制。(参见 Rafy.RBAC.ModuleAC 实体类型。)

                //返回的子对象的属性只是简单的完全Copy参数data的数据。
                dst.Clone(src, CloneOptions.ReadDbRow());
            }
        /// <summary>
        /// Extension method to join the attributes of entity e and otherEntity
        /// </summary>
        /// <param name="e"></param>
        /// <param name="otherEntity"></param>
        /// <param name="attributes"></param>
        /// <returns></returns>
        public static Entity JoinAttributes(this Entity e, Entity otherEntity, ColumnSet columnSet, string alias, XrmFakedContext context)
        {
            if (otherEntity == null) return e; //Left Join where otherEntity was not matched

            otherEntity = otherEntity.Clone(); //To avoid joining entities from/to the same entities, which would cause collection modified exceptions

            if (columnSet.AllColumns)
            {
                foreach (var attKey in otherEntity.Attributes.Keys)
                {
                    e[alias + "." + attKey] = new AliasedValue(alias, attKey, otherEntity[attKey]);
                }
            }
            else
            {
                //Return selected list of attributes
                foreach (var attKey in columnSet.Columns)
                {
                    if (!context.AttributeExistsInMetadata(otherEntity.LogicalName, attKey))
                    {
                        OrganizationServiceFaultQueryBuilderNoAttributeException.Throw(attKey);
                    }

                    if (otherEntity.Attributes.ContainsKey(attKey))
                    {
                        e[alias + "." + attKey] = new AliasedValue(alias, attKey, otherEntity[attKey]);
                    }
                    else
                    {
                        e[alias + "." + attKey] = new AliasedValue(alias, attKey, null);
                    }
                    
                }
            }
            return e;
        }
Beispiel #6
0
        /// <summary>
        /// Add a single entity
        /// </summary>
        /// <param name="e">the entity</param>
        /// <param name="label">optional label, null if none</param>
        /// <returns>the 2 entity clones actually used in the view</returns>
        public Entity[] Add(Entity e, devDept.Eyeshot.Labels.Label[] labels)
        {
            Entity[] ents = new Entity[2];
            m_viewleft.Entities.Add(ents[0] = (Entity)e.Clone());
            m_viewright.Entities.Add(ents[1] = (Entity)e.Clone());
            ents[0].EntityData = ents[1].EntityData = e.EntityData;
            ents[0].GroupIndex = ents[1].GroupIndex = e.GroupIndex;

            if (e is Mesh)
            {
                e.ColorMethod = colorMethodType.byEntity;
                Color baseColor = e.Color;
                if (e.LayerIndex > 0 && e.LayerIndex < this[0].Layers.Count)
                    baseColor = this[0].Layers[e.LayerIndex].Color;
                e.Color = Color.FromArgb(50, baseColor);
            }
            if (labels != null)
            {
                foreach (devDept.Eyeshot.Labels.Label label in labels)
                {
                    label.Visible = false;
                    m_viewleft.Labels.Add(label);
                    m_viewright.Labels.Add(label);
                }
            }

            return ents;
        }