LADXHD/InGame/GameObjects/Base/Components/ShadowBodyDrawComponent.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2023-12-14 22:21:22 +00:00
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ProjectZ.InGame.GameObjects.Base.CObjects;
using ProjectZ.InGame.Things;
namespace ProjectZ.InGame.GameObjects.Base.Components
{
class ShadowBodyDrawComponent : DrawShadowComponent
{
private readonly CPosition _position;
private readonly Vector2 _offset = new Vector2(0, -1.5f);
public int ShadowWidth = 8;
public int ShadowHeight = 4;
public float Transparency = 1;
public ShadowBodyDrawComponent(CPosition position)
{
_position = position;
Draw = SpriteDrawFunction;
}
public void SpriteDrawFunction(SpriteBatch spriteBatch)
{
if (!IsActive)
return;
// draw the shadow
DrawHelper.DrawShadow(Resources.SprItem, new Vector2(_position.X - ShadowWidth / 2 + _offset.X, _position.Y - ShadowHeight / 2 + _offset.Y),
new Rectangle(1, 218, 8, 4), ShadowWidth, ShadowHeight, false, 1, 0, Color.White * ((_position.Z + 10) / 20f) * Transparency);
}
}
}