diff --git a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs index c552101..e55976d 100644 --- a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs +++ b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs @@ -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(); /// /// Создается простой объект на карте - no animations, только где, насколько крупно рисовать, по какой сорс ректанглу рисовать и из какой текстуры @@ -27,10 +28,11 @@ namespace ZoFo.GameCore.GameObjects.MapObjects /// 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) diff --git a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs index 7de06b9..d590462 100644 --- a/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs +++ b/ZoFo/GameCore/Graphics/AnimatedGraphicsComponent.cs @@ -16,8 +16,7 @@ namespace ZoFo.GameCore.Graphics public List animations; private List textures; private List 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(); diff --git a/ZoFo/GameCore/Graphics/AnimationComponent.cs b/ZoFo/GameCore/Graphics/AnimationComponent.cs deleted file mode 100644 index 084b912..0000000 --- a/ZoFo/GameCore/Graphics/AnimationComponent.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ZoFo.GameCore.Graphics; - -public class AnimationComponent -{ - -} \ No newline at end of file diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs index cfa5a6f..686cb96 100644 --- a/ZoFo/GameCore/Server.cs +++ b/ZoFo/GameCore/Server.cs @@ -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; }