Esempio n. 1
0
 public virtual void Render(SpriteBatch spriteBatch, Vector2?OverridePosition)
 {
     if (RenderComponent != null)
     {
         RenderComponent.Render(spriteBatch, PositionComponent == null ? OverridePosition ?? new Vector2(300, 300) : PositionComponent.CurrentPosition);
     }
 }
Esempio n. 2
0
        public void RenderEntities()
        {
            List <RenderComponent> rcList = ComponentManager.GetComponents <RenderComponent>();

            for (int i = 0; i < rcList.Count; i++)
            {
                RenderComponent   rc = ComponentManager.GetComponent <RenderComponent>(rcList[i].OwnerID);
                PositionComponent pc = ComponentManager.GetComponent <PositionComponent>(rcList[i].OwnerID);
                //System.Console.WriteLine( "owner:: " + rcList[i].OwnerID );
                if (rc != null && pc != null)
                {
                    rc.Render(canvas[pc.X, pc.Y]);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Renders a renderable components and applies its required renderstate if necessary.
        /// </summary>
        void Render(ICamera camera, RenderComponent renderable) {
            RenderState desiredState = renderable.RenderState;

            if (desiredState != null) {
                if (_currentlyEnabledState != desiredState) {
                    if (_currentlyEnabledState != null) {
                        _currentlyEnabledState(false);
                    }

                    desiredState(true);

                    _currentlyEnabledState = desiredState;
                }
            }

            renderable.Render(camera);
        }
Esempio n. 4
0
        public void Render()
        {
            if (RenderByDepth)
            {
                List <Entity> renderList = new List <Entity>();
                RenderBackupCount = 0;
                this.BuildSortedRenderList(renderList);
                renderList.Sort(new EntitySorter());
                foreach (Entity entity in renderList)
                {
                    entity.RenderComponent.Render();
                }
                return;
            }

            if (!Visible)
            {
                return;
            }
            if (Parent != null)
            {
                relativeX = Parent.RelativeX + X;
                relativeY = Parent.RelativeY + Y;
            }
            else
            {
                relativeX = X;
                relativeY = Y;
            }
            if (RenderComponent != null)
            {
                RenderComponent.Render();
            }
            if (Children.Count != 0)
            {
                LinkedListNode <Entity> child = Children.First;
                while (child != null)
                {
                    child.Value.Render();
                    child = child.Next;
                }
            }
        }