From bca2a30c65e5af891be5794942dce1b627794be8 Mon Sep 17 00:00:00 2001 From: SergoDobro Date: Sat, 17 Aug 2024 01:11:08 +0300 Subject: [PATCH] minor fixes --- ZoFo/GameCore/Client.cs | 8 +------- ZoFo/GameCore/GUI/HUD.cs | 8 +------- .../NetworkManager/ServerNetworkManager.cs | 11 +++++++++-- ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs | 13 ++++++++++--- ZoFo/GameCore/Server.cs | 2 +- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index ad153d7..81b4166 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -32,13 +32,7 @@ namespace ZoFo.GameCore // тут будет switch foreach (var item in updateDatas) { - /* switch (item.UpdateType) Здесь нужно отлавливать и регистрировать - { - case "Tile": - MapObject map = new MapObject(); - - break; - }*/ + GotData(item); } } diff --git a/ZoFo/GameCore/GUI/HUD.cs b/ZoFo/GameCore/GUI/HUD.cs index 2a65222..a2b1892 100644 --- a/ZoFo/GameCore/GUI/HUD.cs +++ b/ZoFo/GameCore/GUI/HUD.cs @@ -13,13 +13,7 @@ using MonogameLibrary.UI.Elements; namespace ZoFo.GameCore.GUI; public class HUD : AbstractGUI -{ - protected UIManager Manager = new(); - protected List Elements = new(); - private List ActiveElements; - protected DrawableUIElement SelectedElement; - private bool isStartedPrint = false; - private bool isPressed = false; +{ private GraphicsDevice graphicsDevice; public virtual void Initialize() diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs index 46d8281..658605e 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics.PackedVector; using System; using System.Collections.Generic; @@ -57,12 +58,18 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager updates.Clear(); return; //TODO TODO REMOVE TO ADD NETWORK TODO REMOVE TO ADD NETWORK TODO REMOVE TO ADD NETWORK TODO REMOVE TO ADD NETWORK - string data = JsonSerializer.Serialize(updates); + //по 10 паков за раз TODO FIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXITFIXIT + List datasToSend = new List(); + for (int i = 0; i < 5 && i diff --git a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs index ae7b8b1..5a5748c 100644 --- a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs +++ b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs @@ -14,12 +14,19 @@ namespace ZoFo.GameCore.GameObjects.MapObjects public class MapObject : GameObject { public virtual bool IsColliderOn { get; protected set; } = true;//Who added that? - public Rectangle _sourceRectangle; + public Rectangle sourceRectangle; public override GraphicsComponent graphicsComponent { get; } = new(); + /// + /// Создается простой объект на карте - no animations, только где, насколько крупно рисовать, по какой сорс ректанглу рисовать и из какой текстуры + /// + /// + /// + /// + /// public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName) : base(position) { - _sourceRectangle = sourceRectangle; + this.sourceRectangle = sourceRectangle; graphicsComponent.ObjectDrawRectangle = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y); graphicsComponent.BuildComponent(textureName); @@ -28,7 +35,7 @@ namespace ZoFo.GameCore.GameObjects.MapObjects } public override void Draw(SpriteBatch spriteBatch) { - graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch, _sourceRectangle); + graphicsComponent.DrawAnimation(graphicsComponent.ObjectDrawRectangle, spriteBatch, sourceRectangle); } } diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs index 0834835..f844da2 100644 --- a/ZoFo/GameCore/Server.cs +++ b/ZoFo/GameCore/Server.cs @@ -117,7 +117,7 @@ namespace ZoFo.GameCore AddData(new UpdateTileCreated() { Position = (gameObject as MapObject).position, - sourceRectangle = (gameObject as MapObject)._sourceRectangle, + sourceRectangle = (gameObject as MapObject).sourceRectangle, Size = (gameObject as MapObject).graphicsComponent.ObjectDrawRectangle.Size, tileSetName = (gameObject as MapObject).graphicsComponent.mainTextureName });//TODO