Fix
This commit is contained in:
parent
fb2366c03c
commit
bd25894407
8 changed files with 32 additions and 5 deletions
|
@ -12,7 +12,7 @@ namespace ZoFo.GameCore.GameObjects.Entities
|
||||||
{
|
{
|
||||||
|
|
||||||
//public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "тут пишите название анимации" }, "сдублируйте " +
|
//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)
|
public EntittyForAnimationTests(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,16*12, 16 * 16);
|
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,16*12, 16 * 16);
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
|
||||||
|
|
||||||
public class Wood : Collectable
|
public class Wood : Collectable
|
||||||
{
|
{
|
||||||
public override StaticGraphicsComponent graphicsComponent { get; } = new("Wood");
|
public override AnimatedGraphicsComponent graphicsComponent { get; } = new("Wood");
|
||||||
|
|
||||||
public Wood(Vector2 position) : base(position)
|
public Wood(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class Door : Interactable
|
||||||
{
|
{
|
||||||
public bool isOpened;
|
public bool isOpened;
|
||||||
|
|
||||||
public override StaticGraphicsComponent graphicsComponent { get; } = new("DoorClosed");
|
public override AnimatedGraphicsComponent graphicsComponent { get; } = new("DoorClosed");
|
||||||
|
|
||||||
public Door(Vector2 position) : base(position)
|
public Door(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.Interactables;
|
||||||
|
|
||||||
public class Interactable : Entity
|
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)
|
public Interactable(Vector2 position) : base(position)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace ZoFo.GameCore.GameObjects.MapObjects
|
||||||
{
|
{
|
||||||
public virtual bool IsColliderOn { get; protected set; } = true;//Who added that?
|
public virtual bool IsColliderOn { get; protected set; } = true;//Who added that?
|
||||||
public Rectangle sourceRectangle;
|
public Rectangle sourceRectangle;
|
||||||
public override StaticGraphicsComponent graphicsComponent { get; } = new();
|
public override AnimatedGraphicsComponent graphicsComponent { get; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Создается простой объект на карте - no animations, только где, насколько крупно рисовать, по какой сорс ректанглу рисовать и из какой текстуры
|
/// Создается простой объект на карте - no animations, только где, насколько крупно рисовать, по какой сорс ректанглу рисовать и из какой текстуры
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using ZoFo.GameCore.GameManagers;
|
using ZoFo.GameCore.GameManagers;
|
||||||
|
using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.Graphics
|
namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
|
@ -202,6 +203,7 @@ namespace ZoFo.GameCore.Graphics
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
|
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
|
||||||
|
|
||||||
float scale;
|
float scale;
|
||||||
if (currentAnimation.Offset.X != 0)
|
if (currentAnimation.Offset.X != 0)
|
||||||
{
|
{
|
||||||
|
@ -223,10 +225,14 @@ namespace ZoFo.GameCore.Graphics
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
_spriteBatch.Draw(texture,
|
_spriteBatch.Draw(texture,
|
||||||
destinationRectangle, sourceRectangle, Color.White);
|
destinationRectangle, sourceRectangle, Color.White);
|
||||||
|
DebugHUD.Instance.Log(texture.Name);
|
||||||
|
|
||||||
}
|
}
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||||
{
|
{
|
||||||
|
|
||||||
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
|
Texture2D texture = textures[texturesNames.FindIndex(x => x == currentAnimation.TextureName)];
|
||||||
|
|
||||||
float scale;
|
float scale;
|
||||||
if (currentAnimation.Offset.X != 0)
|
if (currentAnimation.Offset.X != 0)
|
||||||
{
|
{
|
||||||
|
|
16
ZoFo/GameCore/Graphics/IGraphicsComponent.cs
Normal file
16
ZoFo/GameCore/Graphics/IGraphicsComponent.cs
Normal 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);
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using ZoFo.GameCore.GameManagers;
|
using ZoFo.GameCore.GameManagers;
|
||||||
|
using ZoFo.GameCore.GUI;
|
||||||
|
|
||||||
namespace ZoFo.GameCore.Graphics
|
namespace ZoFo.GameCore.Graphics
|
||||||
{
|
{
|
||||||
|
@ -42,6 +43,8 @@ namespace ZoFo.GameCore.Graphics
|
||||||
|
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch)
|
||||||
{
|
{
|
||||||
|
DebugHUD.Instance.Log("draw ");
|
||||||
|
|
||||||
destinationRectangle.X -= CameraPosition.X;
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
destinationRectangle = Scaling(destinationRectangle);
|
destinationRectangle = Scaling(destinationRectangle);
|
||||||
|
@ -50,6 +53,8 @@ namespace ZoFo.GameCore.Graphics
|
||||||
|
|
||||||
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
public override void Draw(Rectangle destinationRectangle, SpriteBatch _spriteBatch, Rectangle sourceRectangle)
|
||||||
{
|
{
|
||||||
|
DebugHUD.Instance.Log("draw ");
|
||||||
|
|
||||||
destinationRectangle.X -= CameraPosition.X;
|
destinationRectangle.X -= CameraPosition.X;
|
||||||
destinationRectangle.Y -= CameraPosition.Y;
|
destinationRectangle.Y -= CameraPosition.Y;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue