diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs index 94e27a0..ad153d7 100644 --- a/ZoFo/GameCore/Client.cs +++ b/ZoFo/GameCore/Client.cs @@ -66,7 +66,7 @@ namespace ZoFo.GameCore } } - internal void GotData(IUpdateData update) + internal void GotData(UpdateData update) { if (update is UpdateTileCreated) { diff --git a/ZoFo/GameCore/GUI/SelectModeMenu.cs b/ZoFo/GameCore/GUI/SelectModeMenu.cs index 2ddf7f4..af3dad0 100644 --- a/ZoFo/GameCore/GUI/SelectModeMenu.cs +++ b/ZoFo/GameCore/GUI/SelectModeMenu.cs @@ -41,12 +41,9 @@ public class SelectModeMenu : AbstractGUI // single Server server = new Server(); Client client = new Client(); -<<<<<<< HEAD server.CreateRoom(1); client.JoinYourself(); -======= ->>>>>>> e9698a8669e52b8738987a7a6ccb79c6726f91ac AppManager.Instance.SetServer(server); AppManager.Instance.SetClient(client); AppManager.Instance.ChangeState(GameState.HostPlaying); diff --git a/ZoFo/GameCore/GameManagers/InputManager.cs b/ZoFo/GameCore/GameManagers/InputManager.cs index 0dfbc1b..4ee0980 100644 --- a/ZoFo/GameCore/GameManagers/InputManager.cs +++ b/ZoFo/GameCore/GameManagers/InputManager.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; namespace ZoFo.GameCore.GameManagers { public enum ScopeState { Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight } + public class InputManager { public delegate void Delegat(); diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs index 0686800..46d8281 100644 --- a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs +++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Net; +using System.Net.Http; using System.Net.Sockets; using System.Text; using System.Text.Json; @@ -21,7 +22,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager private IPEndPoint endPoint; private Socket socket; private List clients; - public List updates; + public List updates; public delegate void OnDataSend(string data); public event OnDataSend GetDataSend; // event Dictionary managerThread; diff --git a/ZoFo/GameCore/GameObjects/Entities/Entity.cs b/ZoFo/GameCore/GameObjects/Entities/Entity.cs index ae903a2..a9e8670 100644 --- a/ZoFo/GameCore/GameObjects/Entities/Entity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/Entity.cs @@ -16,8 +16,10 @@ namespace ZoFo.GameCore.GameObjects.Entities protected Entity(Vector2 position) : base(position) { } - + public virtual void Update() + { + } } } diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs index 05a27ec..1d73ead 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/LivingEntity.cs @@ -3,20 +3,26 @@ using Microsoft.Xna.Framework.Graphics; using System; using ZoFo.GameCore.GameObjects.Entities; using ZoFo.GameCore.ZoFo_graphics; +using ZoFo.GameCore.GameManagers; namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities; public class LivingEntity : Entity { public Vector2 velocity; + private InputManager inputManager; + public LivingEntity(Vector2 position) : base(position) { + inputManager = new InputManager(); } - public void TextureLoad(SpriteBatch spriteBatch) + #region Server side + /*public override void Update() { - - } + + }*/ + #endregion } diff --git a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs index 744b2c4..20bbe18 100644 --- a/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs +++ b/ZoFo/GameCore/GameObjects/Entities/LivingEntities/Player/Player.cs @@ -1,25 +1,27 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player; + public class Player : LivingEntity { + public Vector2 InputWeaponRotation{ get; set; } + public Vector2 InputPlayerRotation{ get; set;} + public bool IsTryingToShoot{get;set;} + Texture2D texture; + private float speed; private int health; - Server server = new Server(); - public Player(Vector2 position) : base(position) { + //InputWeaponRotation = new Vector2(0, 0); + //InputPlayerRotation = new Vector2(0, 0); } public void Update(GameTime gameTime) { - // server.AddData(); - } - - public void TextureLoad(SpriteBatch spriteBatch) - { - + } } diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs index 6305674..01dce1b 100644 --- a/ZoFo/GameCore/GameObjects/GameObject.cs +++ b/ZoFo/GameCore/GameObjects/GameObject.cs @@ -4,12 +4,15 @@ using Microsoft.Xna.Framework.Graphics; using System; using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.ZoFo_graphics; +using ZoFo.GameCore; namespace ZoFo.GameCore.GameObjects; public abstract class GameObject { public Vector2 position; + + private Server server; public Vector2 rotation; //вектор направления объекта public abstract GraphicsComponent graphicsComponent { get; } @@ -17,6 +20,8 @@ public abstract class GameObject public GameObject(Vector2 position) { this.position = position; + server = new Server(); + server.RegisterGameObject(this); graphicsComponent.LoadContent(); } diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs index 72329d9..0834835 100644 --- a/ZoFo/GameCore/Server.cs +++ b/ZoFo/GameCore/Server.cs @@ -29,7 +29,7 @@ namespace ZoFo.GameCore //TODO Comment pls public void OnDataSend(string data) { - List updateDatas = JsonSerializer.Deserialize>(data); + List updateDatas = JsonSerializer.Deserialize>(data); for (int i = 0; i < updateDatas.Count; i++) { ProcessIUpdateData(updateDatas[i]); @@ -39,7 +39,7 @@ namespace ZoFo.GameCore /// Обработка апдейтсов, которые нам прислал клиент /// /// - public void ProcessIUpdateData(IUpdateData updateData) + public void ProcessIUpdateData(UpdateData updateData) { //ТУТ Switch case будет честное слово @@ -87,8 +87,7 @@ namespace ZoFo.GameCore networkManager.AddData(gameEnded); networkManager.CloseConnection(); } - #endregion - private List gameObjects; + private List gameObjects = new List(); private List entities; //entity public void Update(GameTime gameTime) { @@ -125,4 +124,5 @@ namespace ZoFo.GameCore } } } + #endregion }