예제 #1
0
        public override void Draw(RenderManager renderMgr, Camera camera)
        {
            int xStart = (int)((camera.Center.X - camera.Size.X * 0.5f) / TileWidth);
            int xEnd = (int)(1 + (camera.Center.X + camera.Size.X * 0.5f) / TileWidth);

            var yStart = (int)((camera.Center.Y - camera.Size.Y * 0.5f) / TileHeight);
            var yEnd = (int)(1 + (camera.Center.Y + camera.Size.Y * 0.5f) / TileHeight); ;

            if (xStart < 0)
                xStart = 0;
            if (xEnd > MapWidth - 1)
                xEnd = MapWidth - 1;
            if (yStart < 0)
                yStart = 0;
            if (yEnd > MapHeight - 1)
                yEnd = MapHeight - 1;

            for (var i = xStart; i < xEnd; i++)
            {
                for (var j = yStart; j < yEnd; j++)
                {
                    if (Tiles[i, j].Texture == null)
                        continue;

                    var position = new Vector2f(
                                    TileWidth * i + TileWidth * 0.5f,
                                    TileHeight * j + TileHeight * 0.5f);

                    renderMgr.DrawSprite(Tiles[i, j].Texture, Tiles[i, j].SubImageRect, position + WorldPosition, TileWidth, TileHeight, false, false, Tint, ZIndex);

                }
            }
        }
예제 #2
0
 public override void Draw(RenderManager renderMgr, Camera camera)
 {
     if (DebugDraw)
     {
         WorldPosition = Parent.Position;
         RectShape.Position = Parent.Position - new Vector2f(RectShape.Size.X * 0.5f, RectShape.Size.Y * 0.5f);
         renderMgr.Target.Draw(RectShape);
     }
 }
 public override void Draw(RenderManager renderMgr, Camera camera)
 {
     renderMgr.DrawSprite(
         CurrentSprite.Texture,
         CurrentSprite.SubImageRect,
         WorldPosition,
         WorldWidth,
         WorldHeight,
         FlipX,
         FlipY,
         Tint, ZIndex);
 }
        /// <summary>
        /// Returns the clip rect
        /// </summary>
        /// <param name="camera">The active camera</param>
        /// <returns>The clip rect</returns>
        public override FloatRect GetScreenRect(Camera camera)
        {
            Vector2f pos = (WorldPosition - camera.Center) * ParallaxFactor + camera.Center;

            FloatRect rect;

            rect.Left = pos.X - WorldWidth * 0.5f;
            rect.Top = pos.Y - WorldHeight * 0.5f;
            rect.Width = WorldWidth;
            rect.Height = WorldHeight;

            return rect;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="parent">GameObect that owns the component</param>
        public CharacterControllerComponent(AnimationSetRenderComponent animSetComponent, 
            PhysicsComponent physicsComponent,
            Camera camera, // for camera shake, needs to be moved if there are other "Characters" than the player.
            GameObject parent)
            : base(parent)
        {
            AnimationSetRenderComponent = animSetComponent;
            PhysicsComponent = physicsComponent;

            Camera = camera;

            FeetColliders = new List<GameObject>();

            Debug.Assert(AnimationSetRenderComponent != null);
            Debug.Assert(PhysicsComponent != null);
        }
예제 #6
0
        public virtual FloatRect GetScreenRect(Camera camera)
        {
            FloatRect rect = new FloatRect();

            rect.Width = WorldWidth;
            rect.Height = WorldHeight;
            rect.Top = WorldPosition.Y - WorldHeight * 0.5f;
            rect.Left = WorldPosition.X - WorldWidth * 0.5f;

            /*
            rect.Width = float.PositiveInfinity;
            rect.Width = float.PositiveInfinity;
            rect.Top = 0;
            rect.Left = 0;
            */
            return rect;
        }
예제 #7
0
 public override FloatRect GetScreenRect(Camera camera)
 {
     FloatRect rect;
     rect.Top = 0;
     rect.Left = 0;
     rect.Width = WorldWidth;
     rect.Height = WorldHeight;
     return rect;
 }
 public override void Draw(RenderManager renderMgr, Camera camera)
 {
     Animation.Draw(renderMgr, WorldPosition, WorldWidth, WorldHeight, FlipX, FlipY, Tint, ZIndex);
 }
예제 #9
0
        public override void Draw(RenderManager renderMgr, Camera camera)
        {
            float healthFactor = HealthComponent.CurrentHealth / HealthComponent.MaxHealth;

            if (healthFactor < 0)
                healthFactor = 0;

            float shieldFactor = HealthComponent.CurrentShield / HealthComponent.MaxShield;
            if (shieldFactor < 0)
                shieldFactor = 0;

            HealthVertices[0].Position = new Vector2f(HealthLeftX, HealthTopY);
            HealthVertices[1].Position = new Vector2f(HealthLeftX, HealthBottomY);
            HealthVertices[2].Position = new Vector2f(HealthLeftX + (HealthBottomRightX - HealthLeftX) * healthFactor, HealthBottomY);
            HealthVertices[3].Position = new Vector2f(HealthLeftX + (HealthTopRightX - HealthLeftX) * healthFactor, HealthTopY);

            ShieldVertices[0].Position = new Vector2f(ShieldTopLeftX, ShieldTopY);
            ShieldVertices[1].Position = new Vector2f(ShieldBottomLeftX, ShieldBottomY);
            ShieldVertices[2].Position = new Vector2f(ShieldBottomLeftX + (ShieldRightX - ShieldBottomLeftX) * shieldFactor, ShieldBottomY);
            ShieldVertices[3].Position = new Vector2f(ShieldTopLeftX + (ShieldRightX - ShieldTopLeftX) * shieldFactor, ShieldTopY);

            for (int i = 0; i < 4; i++)
            {
                HealthVertices[i].Position = HealthVertices[i].Position + Offset;
                ShieldVertices[i].Position = ShieldVertices[i].Position + Offset;
            }

            renderMgr.SetOverlayView();

            RenderStates renderStates = new RenderStates(BorderTexture);
            RenderStates healthGradientRenderStates = new RenderStates(HealthTexture);
            RenderStates shieldGradientRenderStates = new RenderStates(ShieldTexture);

            renderMgr.Target.Draw(BorderVertices, PrimitiveType.Quads, renderStates);
            renderMgr.Target.Draw(HealthVertices, PrimitiveType.Quads, healthGradientRenderStates);
            renderMgr.Target.Draw(ShieldVertices, PrimitiveType.Quads, shieldGradientRenderStates);

            renderMgr.SetCameraView();
        }
예제 #10
0
 public virtual void Draw(RenderManager renderMgr, Camera camera)
 {
 }
예제 #11
0
 /// <summary>
 /// Draw it.
 /// </summary>
 /// <param name="renderMgr"></param>
 /// <param name="camera"></param>
 public override void Draw(RenderManager renderMgr, Camera camera)
 {
     //add camera position to where we want to draw on the screen, and let the view transform just subtract it back off
     renderMgr.DrawSprite(Texture, SubImageRect, (WorldPosition - camera.Center) * ParallaxFactor + camera.Center,
         WorldWidth, WorldHeight, FlipX, FlipY, Tint, ZIndex);
 }