Fixed graphics partially
This commit is contained in:
parent
600411cd55
commit
b9c015455d
4 changed files with 12 additions and 24 deletions
|
@ -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)
|
||||
|
|
|
@ -16,8 +16,7 @@ namespace ZoFo.GameCore.Graphics
|
|||
public List<AnimationContainer> animations;
|
||||
private List<Texture2D> textures;
|
||||
private List<string> texturesNames;
|
||||
private AnimationContainer currentAnimation;
|
||||
static public int scaling = 6;
|
||||
private AnimationContainer currentAnimation;
|
||||
static public int Camera_XW=800;
|
||||
static public int Camera_YH = 400;
|
||||
static public Vector2 CameraSize = new Vector2(1800, 960);
|
||||
|
@ -215,15 +214,7 @@ namespace ZoFo.GameCore.Graphics
|
|||
destinationRectangle = Scaling(destinationRectangle);
|
||||
_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();
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
namespace ZoFo.GameCore.Graphics;
|
||||
|
||||
public class AnimationComponent
|
||||
{
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue