This commit is contained in:
Mootfrost777 2024-08-18 00:26:36 +03:00
parent fb2366c03c
commit bd25894407
8 changed files with 32 additions and 5 deletions

View file

@ -12,7 +12,7 @@ namespace ZoFo.GameCore.GameObjects.Entities
{
//public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "тут пишите название анимации" }, "сдублируйте " +
public override AnimatedGraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "player_running_top_rotate" }, "player_running_top_rotate");
public override AnimatedGraphicsComponent graphicsComponent { get; } = new(new List<string> { "player_running_top_rotate" }, "player_running_top_rotate");
public EntittyForAnimationTests(Vector2 position) : base(position)
{
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,16*12, 16 * 16);

View file

@ -6,7 +6,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
public class Wood : Collectable
{
public override StaticGraphicsComponent graphicsComponent { get; } = new("Wood");
public override AnimatedGraphicsComponent graphicsComponent { get; } = new("Wood");
public Wood(Vector2 position) : base(position)
{

View file

@ -9,7 +9,7 @@ public class Door : Interactable
{
public bool isOpened;
public override StaticGraphicsComponent graphicsComponent { get; } = new("DoorClosed");
public override AnimatedGraphicsComponent graphicsComponent { get; } = new("DoorClosed");
public Door(Vector2 position) : base(position)
{

View file

@ -9,7 +9,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables;
public class Interactable : Entity
{
public override StaticGraphicsComponent graphicsComponent => throw new System.NotImplementedException();
public override AnimatedGraphicsComponent graphicsComponent => throw new System.NotImplementedException();
public Interactable(Vector2 position) : base(position)
{

View file

@ -16,7 +16,7 @@ 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();
public override AnimatedGraphicsComponent graphicsComponent { get; } = new();
/// <summary>
/// Создается простой объект на карте - no animations, только где, насколько крупно рисовать, по какой сорс ректанглу рисовать и из какой текстуры

View file

@ -4,6 +4,7 @@ using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GUI;
namespace ZoFo.GameCore.Graphics
{
@ -202,6 +203,7 @@ namespace ZoFo.GameCore.Graphics
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
{
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
float scale;
if (currentAnimation.Offset.X != 0)
{
@ -223,10 +225,14 @@ namespace ZoFo.GameCore.Graphics
destinationRectangle = Scaling(destinationRectangle);
_spriteBatch.Draw(texture,
destinationRectangle, sourceRectangle, Color.White);
DebugHUD.Instance.Log(texture.Name);
}
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
{
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
float scale;
if (currentAnimation.Offset.X != 0)
{

View file

@ -0,0 +1,16 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace ZoFo.GameCore.Graphics;
public interface IGraphicsComponent
{
public Rectangle ObjectDrawRectangle { get; set; }
public static int scaling = 1;
public string mainTextureName { get; set; }//TODO костыль - пофиксить
public abstract void LoadContent();
public abstract void Update();
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch);
public abstract void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle);
}

View file

@ -4,6 +4,7 @@ using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GUI;
namespace ZoFo.GameCore.Graphics
{
@ -42,6 +43,8 @@ namespace ZoFo.GameCore.Graphics
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
{
DebugHUD.Instance.Log("draw ");
destinationRectangle.X -= CameraPosition.X;
destinationRectangle.Y -= CameraPosition.Y;
destinationRectangle = Scaling(destinationRectangle);
@ -50,6 +53,8 @@ namespace ZoFo.GameCore.Graphics
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
{
DebugHUD.Instance.Log("draw ");
destinationRectangle.X -= CameraPosition.X;
destinationRectangle.Y -= CameraPosition.Y;