diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs index 813c583..3b9707d 100644 --- a/ZoFo/GameCore/GameObjects/GameObject.cs +++ b/ZoFo/GameCore/GameObjects/GameObject.cs @@ -1,5 +1,8 @@  using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.ZoFo_graphics; namespace ZoFo.GameCore.GameObjects; @@ -7,9 +10,65 @@ namespace ZoFo.GameCore.GameObjects; public abstract class GameObject { public Vector2 position; - public Vector2 rotation; - + public Vector2 rotation; //вектор направления объекта protected abstract GraphicsComponent graphicsComponent { get; } - public void Draw() { } + #region ServerSide + public GameObject(Vector2 position) + { + this.position = position; + } + + + /// + /// Это вызывается в логике игры, которая на сервере, здесь будет вызываться уведомление об анимации + /// + public void PlayAnimation_OnServer() + { + //TODO + } + + #endregion + + + #region Client Side + + /// + /// Это вызывается в клиентской части игры + /// + public void PlayAnimation_OnClient() + { + graphicsComponent.Update(); + } + public void LoadContent() + { + graphicsComponent.LoadContent(); + } + + public virtual void Update(GameTime gameTime) + { + //PlayAnimation(); + } + + public virtual void Draw(SpriteBatch spriteBatch) + { + graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch); + //debug + if (AppManager.Instance.InputManager.CollisionsCheat) + DrawDebugRectangle(spriteBatch, graphicsComponent.ObjectDrawRectangle); + + } + public void DrawDebugRectangle(SpriteBatch spriteBatch, Rectangle _rectangle, Nullable color = null) + { + if (color is null) color = new Color(1, 0, 0, 0.25f); + if (color.Value.A == 255) color = new Color(color.Value, 0.25f); + //spriteBatch.Draw(debugTexture, + // new Rectangle((_rectangle.X - GraphicsComponent.CameraPosition.X) * GraphicsComponent.scaling, + // (_rectangle.Y - GraphicsComponent.CameraPosition.Y) * GraphicsComponent.scaling, + // _rectangle.Width * GraphicsComponent.scaling, + // _rectangle.Height * GraphicsComponent.scaling), color.Value); + + //TODO: debugTexture + } + #endregion } \ No newline at end of file diff --git a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs new file mode 100644 index 0000000..1dc14cf --- /dev/null +++ b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs @@ -0,0 +1,26 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers; +using ZoFo.GameCore.ZoFo_graphics; + +namespace ZoFo.GameCore.GameObjects.MapObjects +{ + internal class MapObject : GameObject + { + public virtual bool IsColliderOn { get; protected set; } = true; + private Rectangle _sourceRectangle; + protected override GraphicsComponent graphicsComponent => new("tiles"); + + public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle) : base(position) + { + _sourceRectangle = sourceRectangle; + graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0, (int)size.X, (int)size.Y); + } + + } +} diff --git a/ZoFo/GameCore/GameObjects/MapObjects/StopObjects/StopObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/StopObjects/StopObject.cs new file mode 100644 index 0000000..e914310 --- /dev/null +++ b/ZoFo/GameCore/GameObjects/MapObjects/StopObjects/StopObject.cs @@ -0,0 +1,13 @@ +using Microsoft.Xna.Framework; +using System; +using ZoFo.GameCore.ZoFo_graphics; + +namespace ZoFo.GameCore.GameObjects.MapObjects.StopObjects; + +public abstract class StopObject : GameObject +{ + protected StopObject(Vector2 position) : base(position) + { + //TODO + } +} diff --git a/ZoFo/GameCore/GameObjects/MapObjects/Tiles/Tile.cs b/ZoFo/GameCore/GameObjects/MapObjects/Tiles/Tile.cs new file mode 100644 index 0000000..eb166b8 --- /dev/null +++ b/ZoFo/GameCore/GameObjects/MapObjects/Tiles/Tile.cs @@ -0,0 +1,8 @@ +using System; + +namespace ZoFo.GameCore.GameObjects.MapObjects.Tiles; + +public class Tile +{ + +} diff --git a/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs b/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs index a60cee1..b6ab88a 100644 --- a/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs +++ b/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs @@ -15,6 +15,10 @@ namespace ZoFo.GameCore.ZoFo_graphics public class GraphicsComponent { + public Rectangle ObjectDrawRectangle { get; set; } + + + public event Action actionOfAnimationEnd; private List animations; private List textures;