コード例 #1
0
        /// <summary>
        /// Attaches a control to an <see cref="Entity"/> instance, using the specified offset.
        /// </summary>
        /// <param name="control">Control instance being attached to the entity.</param>
        /// <param name="entity">Entity instance to which the control is being attached.</param>
        /// <param name="offset">Offset from the entity's position to display the control.</param>
        public static void AttachToEntity(this Control control, Entity entity, Vector2 offset)
        {
            ControlComponent controlComponent = new ControlComponent()
            {
                Control = control,
                Offset  = offset
            };

            entity.AddComponent <ControlComponent>(controlComponent);
            entity.Refresh();
        }
コード例 #2
0
        /// <summary>
        /// Attaches a control to an <see cref="Entity"/> instance, using the specified offset.
        /// </summary>
        /// <param name="control">Control instance being attached to the entity.</param>
        /// <param name="entity">Entity instance to which the control is being attached.</param>
        /// <param name="offset">Offset from the entity's position to display the control.</param>
        public static void AttachToEntity(this Control control, Entity entity, Vector2 offset)
        {
            ControlComponent controlComponent = new ControlComponent()
            {
                Control = control,
                Offset = offset
            };

            entity.AddComponent<ControlComponent>(controlComponent);
            entity.Refresh();
        }
コード例 #3
0
        /// <summary>
        /// Processes the provided <see cref="Entity"/> instance.
        /// </summary>
        /// <param name="entity"><see cref="Entity"/> instance to process.</param>
        public override void Process(Entity entity)
        {
            PositionComponent positionComponent = _positionMapper.Get(entity);
            ControlComponent  controlComponent  = _controlMapper.Get(entity);

            if ((positionComponent == null) || (controlComponent == null))
            {
                return;
            }

            controlComponent.Control.Bounds.Location = new UniVector(
                new UniScalar(0.0f, positionComponent.PreviousPosition.X + controlComponent.Offset.X + Director.SharedDirector.TransformationMatrix.Translation.X),
                new UniScalar(0.0f, positionComponent.PreviousPosition.Y + controlComponent.Offset.Y + Director.SharedDirector.TransformationMatrix.Translation.Y));
        }