diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb index cdcfaeb..00506e5 100644 --- a/ZoFo/Content/Content.mgcb +++ b/ZoFo/Content/Content.mgcb @@ -82,8 +82,6 @@ /processorParam:Quality=Best /build:sounds/Zombi stoit.wav -#begin Textures/GUI/checkboxs_off.png - #begin Textures/GUI/background/base.png /importer:TextureImporter /processor:TextureProcessor @@ -142,9 +140,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Textures/GUI/checkboxs_off.png +/build:Textures/GUI/checkboxs_off-on.png -#begin Textures/GUI/checkboxs_off-on.png +#begin Textures/GUI/checkboxs_off.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -154,7 +152,7 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Textures/GUI/checkboxs_off-on.png +/build:Textures/GUI/checkboxs_off.png #begin Textures/GUI/checkboxs_on.png /importer:TextureImporter @@ -192,18 +190,6 @@ /processorParam:TextureFormat=Color /build:Textures/GUI/mouse.png -#begin Textures/GUI/switch.png -/importer:TextureImporter -/processor:TextureProcessor -/processorParam:ColorKeyColor=255,0,255,255 -/processorParam:ColorKeyEnabled=True -/processorParam:GenerateMipmaps=False -/processorParam:PremultiplyAlpha=True -/processorParam:ResizeToPowerOfTwo=False -/processorParam:MakeSquare=False -/processorParam:TextureFormat=Color -/build:Textures/GUI/switch.png - #begin Textures/GUI/Switch_backgrownd.png /importer:TextureImporter /processor:TextureProcessor @@ -216,3 +202,27 @@ /processorParam:TextureFormat=Color /build:Textures/GUI/Switch_backgrownd.png +#begin Textures/GUI/switch.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/GUI/switch.png + +#begin Textures/TileSets/TilesetFloor.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/TileSets/TilesetFloor.png;Textures/TileSets/TileSet 1.png + diff --git a/ZoFo/Content/Textures/TileSets/TilesetFloor.png b/ZoFo/Content/Textures/TileSets/TilesetFloor.png new file mode 100644 index 0000000..abba7bf Binary files /dev/null and b/ZoFo/Content/Textures/TileSets/TilesetFloor.png differ diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index bb33c14..85429f1 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -50,6 +50,7 @@ namespace ZoFo.GameCore } internal void Draw(SpriteBatch spriteBatch) { + } } } \ No newline at end of file diff --git a/ZoFo/GameCore/GUI/HUD.cs b/ZoFo/GameCore/GUI/HUD.cs index c20ead1..2a65222 100644 --- a/ZoFo/GameCore/GUI/HUD.cs +++ b/ZoFo/GameCore/GUI/HUD.cs @@ -12,7 +12,7 @@ using MonogameLibrary.UI.Elements; namespace ZoFo.GameCore.GUI; -public class HUD +public class HUD : AbstractGUI { protected UIManager Manager = new(); protected List Elements = new(); @@ -39,6 +39,10 @@ public class HUD public virtual void Draw(SpriteBatch spriteBatch) { - Manager.Draw(spriteBatch); + //Manager.Draw(spriteBatch); + } + + protected override void CreateUI() + { } } \ No newline at end of file diff --git a/ZoFo/GameCore/GUI/SelectModeMenu.cs b/ZoFo/GameCore/GUI/SelectModeMenu.cs index f192252..db075bb 100644 --- a/ZoFo/GameCore/GUI/SelectModeMenu.cs +++ b/ZoFo/GameCore/GUI/SelectModeMenu.cs @@ -41,11 +41,14 @@ public class SelectModeMenu : AbstractGUI // single Server server = new Server(); //Server Logic SinglePlayer Client client = new Client(); - server.CreateRoom(1); - client.JoinYourself(); AppManager.Instance.SetServer(server); AppManager.Instance.SetClient(client); AppManager.Instance.ChangeState(GameState.HostPlaying); + AppManager.Instance.SetGUI(new HUD()); + + //server.CreateRoom(1); + //client.JoinYourself(); + server.StartGame(); string key = client.IsConnected.ToString(); AppManager.Instance.debugHud.Set(key,"SinglePlayer"); diff --git a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs index 880c0e8..a1c7799 100644 --- a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs +++ b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs @@ -91,8 +91,12 @@ namespace ZoFo.GameCore.GameManagers.MapManager { using (StreamReader reader = new StreamReader(path)) { + var options = new JsonSerializerOptions //TODO Remove + { + PropertyNameCaseInsensitive = true + }; string data = reader.ReadToEnd(); - return JsonSerializer.Deserialize(data); + return JsonSerializer.Deserialize(data, options); } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/Entity.cs b/ZoFo/GameCore/GameObjects/Entities/Entity.cs index a1ab30b..ae903a2 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Entity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Entity.cs @@ -10,7 +10,7 @@ namespace ZoFo.GameCore.GameObjects.Entities { public abstract class Entity : GameObject { - protected override GraphicsComponent graphicsComponent => null; + public override GraphicsComponent graphicsComponent => null; public CollisionComponent collisionComponent { get; protected set; } public int Id { get; set; } protected Entity(Vector2 position) : base(position) diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs index d309bf9..09c1369 100644 --- a/ZoFo/GameCore/GameObjects/GameObject.cs +++ b/ZoFo/GameCore/GameObjects/GameObject.cs @@ -11,12 +11,13 @@ public abstract class GameObject { public Vector2 position; public Vector2 rotation; //вектор направления объекта - protected abstract GraphicsComponent graphicsComponent { get; } + public abstract GraphicsComponent graphicsComponent { get; } #region ServerSide public GameObject(Vector2 position) { this.position = position; + AppManager.Instance.server.RegisterGameObject(this); } public virtual void UpdateLogic(GameTime gameTime) { diff --git a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs index 642b8fb..d2767d9 100644 --- a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs +++ b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs @@ -14,12 +14,13 @@ namespace ZoFo.GameCore.GameObjects.MapObjects { public virtual bool IsColliderOn { get; protected set; } = true; private Rectangle _sourceRectangle; - protected override GraphicsComponent graphicsComponent => new("tiles"); + public override GraphicsComponent graphicsComponent => new(); public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName) : base(position) { _sourceRectangle = sourceRectangle; graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0, (int)size.X, (int)size.Y); + graphicsComponent.BuildComponent("Textures\\TileSets\\"+textureName); } public override void Draw(SpriteBatch spriteBatch) { diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs index 5fcb39c..143b07a 100644 --- a/ZoFo/GameCore/Server.cs +++ b/ZoFo/GameCore/Server.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Text.Json; using System.Threading.Tasks; +using ZoFo.GameCore.GameManagers.MapManager; using ZoFo.GameCore.GameManagers.NetworkManager; using ZoFo.GameCore.GameManagers.NetworkManager.Updates; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; @@ -21,18 +22,33 @@ namespace ZoFo.GameCore { networkManager = new ServerNetworkManager(); networkManager.GetDataSend += OnDataSend; + } + #region server logic as App + //TODO Comment pls public void OnDataSend(string data) { List updateDatas = JsonSerializer.Deserialize>(data); - - //ТУТ Switch case будет честное слово + for (int i = 0; i < updateDatas.Count; i++) { + ProcessIUpdateData(updateDatas[i]); + } } + /// + /// Обработка апдейтсов, которые нам прислал клиент + /// + /// + public void ProcessIUpdateData(IUpdateData updateData) + { + + //ТУТ Switch case будет честное слово + } + /// /// Для красоты) Отдел Серверов + /// добавляет в лист updates новую data /// /// - public void AddData(IUpdateData data)//добавляет в лист updates новую data + public void AddData(IUpdateData data) { networkManager.AddData(data); } @@ -46,7 +62,18 @@ namespace ZoFo.GameCore networkManager.Start(players); } - // public void StartGame() { } принудительный запуск + /// + /// Запуск игры в комнате + /// + public void StartGame() { + + //TODO начинает рассылку и обмен пакетами игры + //Грузит карту + + gameObjects = new List(); + entities = new List(); + new MapManager().LoadMap(); + } /// /// Добавляет UpdateGameEnded и отключает игроков @@ -57,7 +84,7 @@ namespace ZoFo.GameCore networkManager.AddData(gameEnded); networkManager.CloseConnection(); } - + #endregion private List gameObjects; private List entities; //entity public void Update(GameTime gameTime) @@ -80,9 +107,10 @@ namespace ZoFo.GameCore /// Регистрирует игровой объект /// /// - public void RegisterEntity(GameObject gameObject) + public void RegisterGameObject(GameObject gameObject) { - gameObjects.Add(gameObject); + gameObjects.Add(gameObject); + AddData(new UpdateTileCreated());//TODO } } } diff --git a/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs b/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs index b6ab88a..bd97d7e 100644 --- a/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs +++ b/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs @@ -66,6 +66,14 @@ namespace ZoFo.GameCore.ZoFo_graphics public GraphicsComponent(string textureName) { + BuildComponent(textureName); + } + public GraphicsComponent() + { + } + public void BuildComponent(string textureName) + { + animations = new List(); textures = new List(); var texture = AppManager.Instance.Content.Load(textureName); @@ -141,6 +149,10 @@ namespace ZoFo.GameCore.ZoFo_graphics public void Update() { + if (currentAnimation is null) + { + return; + } if (interval == 0) { currentFrame++;