Fixed graphics partially

This commit is contained in:
SergoDobro 2024-08-18 13:02:33 +03:00
parent 600411cd55
commit b9c015455d
4 changed files with 12 additions and 24 deletions

View file

@ -16,7 +16,8 @@ namespace ZoFo.GameCore.GameObjects.MapObjects
{
public virtual bool IsColliderOn { get; protected set; } = true;//Who added that?
public Rectangle sourceRectangle;
public override StaticGraphicsComponent graphicsComponent { get; } = new StaticGraphicsComponent();
public override GraphicsComponent graphicsComponent { get; }
= new StaticGraphicsComponent();
/// <summary>
/// Создается простой объект на карте - no animations, только где, насколько крупно рисовать, по какой сорс ректанглу рисовать и из какой текстуры
@ -27,10 +28,11 @@ namespace ZoFo.GameCore.GameObjects.MapObjects
/// <param name="textureName"></param>
public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName) : base(position)
{
graphicsComponent._textureName = textureName;
graphicsComponent.BuildComponent(textureName);
graphicsComponent.ObjectDrawRectangle = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
graphicsComponent.LoadContent();
(graphicsComponent as StaticGraphicsComponent)._textureName = textureName;
(graphicsComponent as StaticGraphicsComponent).BuildComponent(textureName);
(graphicsComponent as StaticGraphicsComponent).ObjectDrawRectangle = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
(graphicsComponent as StaticGraphicsComponent).LoadContent();
this.sourceRectangle = sourceRectangle;
}
public override void Draw(SpriteBatch spriteBatch)

View file

@ -17,7 +17,6 @@ namespace ZoFo.GameCore.Graphics
private List<Texture2D> textures;
private List<string> texturesNames;
private AnimationContainer currentAnimation;
static public int scaling = 6;
static public int Camera_XW=800;
static public int Camera_YH = 400;
static public Vector2 CameraSize = new Vector2(1800, 960);
@ -216,14 +215,6 @@ namespace ZoFo.GameCore.Graphics
_spriteBatch.Draw(texture,
destinationRectangle, sourceRectangle, Color.White);
}
private Rectangle Scaling(Rectangle destinationRectangle)
{
destinationRectangle.X *= scaling;
destinationRectangle.Y *= scaling;
destinationRectangle.Width *= scaling;
destinationRectangle.Height *= scaling;
return destinationRectangle;
}
private void buildSourceRectangle()
{
sourceRectangle = new Rectangle();

View file

@ -1,6 +0,0 @@
namespace ZoFo.GameCore.Graphics;
public class AnimationComponent
{
}

View file

@ -20,6 +20,7 @@ using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies;
using ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player;
using ZoFo.GameCore.GameObjects.MapObjects;
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore
{
@ -174,7 +175,7 @@ namespace ZoFo.GameCore
sourceRectangle = (gameObject as StopObject).sourceRectangle,
Size = (gameObject as StopObject).graphicsComponent.ObjectDrawRectangle.Size,
collisions = (gameObject as StopObject).collisionComponents.Select(x=>x.stopRectangle).ToArray(),
tileSetName = (gameObject as StopObject).graphicsComponent.mainTextureName
tileSetName = ((gameObject as StopObject).graphicsComponent as StaticGraphicsComponent)._textureName
});//TODO
foreach (var item in (gameObject as StopObject).collisionComponents)
{
@ -190,7 +191,7 @@ namespace ZoFo.GameCore
Position = (gameObject as MapObject).position,
sourceRectangle = (gameObject as MapObject).sourceRectangle,
Size = (gameObject as MapObject).graphicsComponent.ObjectDrawRectangle.Size,
tileSetName = (gameObject as MapObject).graphicsComponent.mainTextureName
tileSetName = ((gameObject as MapObject).graphicsComponent as StaticGraphicsComponent)._textureName
});//TODO
return;
}