diff --git a/DangerousD/GameCore/GUI/LobbyGUI.cs b/DangerousD/GameCore/GUI/LobbyGUI.cs index f782750..7ebc2db 100644 --- a/DangerousD/GameCore/GUI/LobbyGUI.cs +++ b/DangerousD/GameCore/GUI/LobbyGUI.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using DangerousD.GameCore.Managers; using MonogameLibrary.UI.Base; using System.Diagnostics; +using DangerousD.GameCore.Network; namespace DangerousD.GameCore.GUI { @@ -55,7 +56,10 @@ namespace DangerousD.GameCore.GUI fontName = "font2" }; hostButton.LeftButtonPressed += () => { - + + AppManager.Instance.NetworkManager.HostInit(""); + + }; Button refreshButton = new ButtonText(Manager) diff --git a/DangerousD/GameCore/Managers/AppManager.cs b/DangerousD/GameCore/Managers/AppManager.cs index dc44ba9..f4c7a78 100644 --- a/DangerousD/GameCore/Managers/AppManager.cs +++ b/DangerousD/GameCore/Managers/AppManager.cs @@ -14,12 +14,14 @@ using DangerousD.GameCore.Managers; namespace DangerousD.GameCore { public enum GameState { Menu, Options, Lobby, Game, Login } + public enum MultiPlayerStatus { SinglePlayer, Host, Client } public class AppManager : Game { public static AppManager Instance { get; private set; } private GraphicsDeviceManager _graphics; - private SpriteBatch _spriteBatch; - GameState gameState; + private SpriteBatch _spriteBatch; + public GameState gameState { get; private set; } + public MultiPlayerStatus multiPlayerStatus { get; private set; } IDrawableObject MenuGUI; IDrawableObject OptionsGUI; IDrawableObject LoginGUI; @@ -45,6 +47,8 @@ namespace DangerousD.GameCore SettingsManager = new SettingsManager(); SettingsManager.LoadSettings(); + NetworkManager.GetReceivingMessages += NetworkSync; + resolution = SettingsManager.Resolution; _graphics.PreferredBackBufferWidth = resolution.X; _graphics.PreferredBackBufferHeight = resolution.Y; @@ -167,5 +171,13 @@ namespace DangerousD.GameCore } } + public void NetworkSync(NetworkTask networkTask) + { + + } + public void SetMultiplayerState(MultiPlayerStatus multiPlayerStatus) + { + this.multiPlayerStatus = multiPlayerStatus; + } } } diff --git a/DangerousD/GameCore/Managers/GameManager.cs b/DangerousD/GameCore/Managers/GameManager.cs index f017120..65d9d06 100644 --- a/DangerousD/GameCore/Managers/GameManager.cs +++ b/DangerousD/GameCore/Managers/GameManager.cs @@ -12,7 +12,7 @@ namespace DangerousD.GameCore { public class GameManager { - + public List GetAllGameObjects { get; private set; } public List livingEntities; public List entities; public List mapObjects; @@ -22,6 +22,7 @@ namespace DangerousD.GameCore public Player GetPlayer1 { get; private set; } public GameManager() { + GetAllGameObjects = new List(); livingEntities = new List(); mapObjects = new List(); entities = new List(); @@ -33,6 +34,7 @@ namespace DangerousD.GameCore internal void Register(GameObject gameObject) { + GetAllGameObjects.Add(gameObject); if (gameObject is LivingEntity) livingEntities.Add(gameObject as LivingEntity); if (gameObject is Entity) diff --git a/DangerousD/GameCore/Managers/PhysicsManager.cs b/DangerousD/GameCore/Managers/PhysicsManager.cs index 7ae99f9..f376c3c 100644 --- a/DangerousD/GameCore/Managers/PhysicsManager.cs +++ b/DangerousD/GameCore/Managers/PhysicsManager.cs @@ -206,5 +206,22 @@ namespace DangerousD.GameCore.Managers } return null; } + + public List CheckRectangle(Rectangle rectangle, Type type) + { + var gameObjects = AppManager.Instance.GameManager.GetAllGameObjects; + List intersected = new List(); + for (int i = 0; i < gameObjects.Count; i++) + { + if (gameObjects[i].GetType() == type) + { + if (gameObjects[i].Rectangle.Intersects(rectangle)) + { + intersected.Add(gameObjects[i]); + } + } + } + return intersected; + } } } \ No newline at end of file diff --git a/DangerousD/GameCore/Managers/SoundManager.cs b/DangerousD/GameCore/Managers/SoundManager.cs index 9021fa8..b32ab35 100644 --- a/DangerousD/GameCore/Managers/SoundManager.cs +++ b/DangerousD/GameCore/Managers/SoundManager.cs @@ -42,6 +42,7 @@ namespace DangerousD.GameCore sound.SoundEffect.Volume = (float)sound.GetDistance(playerPos) / MaxSoundDistance; sound.SoundEffect.Play(); PlayingSounds.Add(sound); + AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(sound.Position, soundName)); } public void StopAllSounds() // остановка всех звуков {