diff --git a/DangerousD/DangerousD.csproj b/DangerousD/DangerousD.csproj index dc5c07f..467b684 100644 --- a/DangerousD/DangerousD.csproj +++ b/DangerousD/DangerousD.csproj @@ -21,7 +21,7 @@ - + \ No newline at end of file diff --git a/DangerousD/GameCore/AppManager.cs b/DangerousD/GameCore/AppManager.cs index 8e611a4..53dfd39 100644 --- a/DangerousD/GameCore/AppManager.cs +++ b/DangerousD/GameCore/AppManager.cs @@ -9,14 +9,13 @@ using DangerousD.GameCore.HUD; namespace DangerousD.GameCore { - enum GameState { Menu, Options, Lobby, Game } + public enum GameState { Menu, Options, Lobby, Game } public class AppManager : Game { private GraphicsDeviceManager _graphics; private SpriteBatch _spriteBatch; GameState gameState; - GameManager GameManager; IHUD MenuGUI; IHUD OptionsGUI; IHUD LobbyGUI; @@ -39,7 +38,9 @@ namespace DangerousD.GameCore { _spriteBatch = new SpriteBatch(GraphicsDevice); - // TODO: use this.Content to load your game content here + TextureManager.contentManager = Content; + TextureManager.graphicsDevice = GraphicsDevice; + MenuGUI = new HUD.MenuHUD(); } protected override void Update(GameTime gameTime) @@ -94,7 +95,10 @@ namespace DangerousD.GameCore base.Draw(gameTime); } - + public void ChangeGameState(GameState gameState) + { + this.gameState = gameState; + } } } diff --git a/DangerousD/GameCore/GameManager.cs b/DangerousD/GameCore/GameManager.cs index 59a7663..dce6424 100644 --- a/DangerousD/GameCore/GameManager.cs +++ b/DangerousD/GameCore/GameManager.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using DangerousD.GameCore.GameObjects; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -6,13 +7,28 @@ using System.Text; namespace DangerousD.GameCore { - class GameManager + static class GameManager { - public void Draw(SpriteBatch _spriteBatch) + static List livingEntities; + static List MapObjects; + internal static void Register(GameObject gameObject) + { + if (gameObject is LivingEntity) + livingEntities.Add(gameObject as LivingEntity); + if (gameObject is MapObject) + MapObjects.Add(gameObject as MapObject); + } + public static void Start() + { + livingEntities = new List(); + MapObjects = new List(); + } + + public static void Draw(SpriteBatch _spriteBatch) { } - public void Update(GameTime gameTime) + public static void Update(GameTime gameTime) { } diff --git a/DangerousD/GameCore/GameObjects/Entity.cs b/DangerousD/GameCore/GameObjects/Entity.cs new file mode 100644 index 0000000..a4305fa --- /dev/null +++ b/DangerousD/GameCore/GameObjects/Entity.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace DangerousD.GameCore.GameObjects +{ + class Entity + { + } +} diff --git a/DangerousD/GameCore/GameObjects/GameObject.cs b/DangerousD/GameCore/GameObjects/GameObject.cs index 6a62f36..3e5dfa4 100644 --- a/DangerousD/GameCore/GameObjects/GameObject.cs +++ b/DangerousD/GameCore/GameObjects/GameObject.cs @@ -6,5 +6,9 @@ namespace DangerousD.GameCore { class GameObject { + public GameObject() + { + GameManager.Register(this); + } } } diff --git a/DangerousD/GameCore/GameObjects/LivingEntity.cs b/DangerousD/GameCore/GameObjects/LivingEntity.cs new file mode 100644 index 0000000..f5625c9 --- /dev/null +++ b/DangerousD/GameCore/GameObjects/LivingEntity.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace DangerousD.GameCore.GameObjects +{ + class LivingEntity : GameObject + { + } +} diff --git a/DangerousD/GameCore/GameObjects/MapObject.cs b/DangerousD/GameCore/GameObjects/MapObject.cs new file mode 100644 index 0000000..db4beab --- /dev/null +++ b/DangerousD/GameCore/GameObjects/MapObject.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace DangerousD.GameCore.GameObjects +{ + class MapObject : GameObject + { + } +} diff --git a/DangerousD/GameCore/GraphicsComponent.cs b/DangerousD/GameCore/GraphicsComponent.cs index 2ae348b..ecff3d8 100644 --- a/DangerousD/GameCore/GraphicsComponent.cs +++ b/DangerousD/GameCore/GraphicsComponent.cs @@ -1,4 +1,5 @@ -using System; +using Microsoft.Xna.Framework.Content; +using System; using System.Collections.Generic; using System.Text; diff --git a/DangerousD/GameCore/HUD/MenuHUD.cs b/DangerousD/GameCore/HUD/MenuHUD.cs new file mode 100644 index 0000000..8ec611f --- /dev/null +++ b/DangerousD/GameCore/HUD/MenuHUD.cs @@ -0,0 +1,27 @@ +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Text; + +namespace DangerousD.GameCore.HUD +{ + class MenuHUD : IHUD + { + MonogameLibrary.UI.Base.MonoClassManagerUI managerUI = new MonogameLibrary.UI.Base.MonoClassManagerUI(); + public MenuHUD() + { + managerUI.InitManager(""); + var lab = new MonogameLibrary.UI.Elements.CheckBox(managerUI) { rectangle = new Microsoft.Xna.Framework.Rectangle(10, 10, 50, 50)}; + lab.LoadTexture(); + } + public void Draw(SpriteBatch _spriteBatch) + { + managerUI.Draw(_spriteBatch); + } + + public void Update() + { + managerUI.Update(null); + } + } +} diff --git a/DangerousD/GameCore/TextureManager.cs b/DangerousD/GameCore/TextureManager.cs new file mode 100644 index 0000000..708507a --- /dev/null +++ b/DangerousD/GameCore/TextureManager.cs @@ -0,0 +1,14 @@ +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.Graphics; +using System; +using System.Collections.Generic; +using System.Text; + +namespace DangerousD.GameCore +{ + static class TextureManager + { + public static ContentManager contentManager; + public static GraphicsDevice graphicsDevice; + } +} diff --git a/DangerousD/GameCore/UI/Base/MonoClassManagerUI.cs b/DangerousD/GameCore/UI/Base/MonoClassManagerUI.cs index dc0931a..56c5d6c 100644 --- a/DangerousD/GameCore/UI/Base/MonoClassManagerUI.cs +++ b/DangerousD/GameCore/UI/Base/MonoClassManagerUI.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using DangerousD.GameCore; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; @@ -20,13 +21,13 @@ namespace MonogameLibrary.UI.Base static GraphicsDevice _graphicsDevice; static ContentManager _content; static SpriteFont _baseFont; - public void InitManager(GraphicsDevice graphicsDevice, ContentManager content, string font) + public void InitManager(string font) { - _graphicsDevice = graphicsDevice; - _content = content; + _graphicsDevice = TextureManager.graphicsDevice; + _content = TextureManager.contentManager; try { - _baseFont = _content.Load(font); + //_baseFont = _content.Load(font); } catch { diff --git a/DangerousD/GameCore/UI/Compounds/BasicDrawableCompound.cs b/DangerousD/GameCore/UI/Compounds/BasicDrawableCompound.cs index 338def8..1798ac5 100644 --- a/DangerousD/GameCore/UI/Compounds/BasicDrawableCompound.cs +++ b/DangerousD/GameCore/UI/Compounds/BasicDrawableCompound.cs @@ -17,6 +17,9 @@ namespace MonogameLibrary.UI.Compounds public enum BasicDrawableCompound_Type { Vertical, Horizontal }; public class BasicDrawableCompound : MonoDrawableTextedUI { + public BasicDrawableCompound(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex) + { + } Dictionary drawables = new Dictionary(); public Vector2 lastPos; Vector2 offset = new Vector2(10, 10); diff --git a/DangerousD/GameCore/UI/Elements/CheckBox.cs b/DangerousD/GameCore/UI/Elements/CheckBox.cs index 2fdf3bf..62ff42a 100644 --- a/DangerousD/GameCore/UI/Elements/CheckBox.cs +++ b/DangerousD/GameCore/UI/Elements/CheckBox.cs @@ -12,6 +12,9 @@ namespace MonogameLibrary.UI.Elements { public class CheckBox : MonoDrawableTextedUI, IInteractable { + public CheckBox(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex) + { + } public delegate void OnCheck(bool checkState); public event OnCheck? Checked; private bool isChecked; diff --git a/DangerousD/GameCore/UI/Elements/Label.cs b/DangerousD/GameCore/UI/Elements/Label.cs index 4657bbc..eacce3c 100644 --- a/DangerousD/GameCore/UI/Elements/Label.cs +++ b/DangerousD/GameCore/UI/Elements/Label.cs @@ -14,6 +14,9 @@ namespace MonogameLibrary.UI.Elements public class Label : MonoDrawableTextedUI { + public Label(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex) + { + } protected HoverState hoverState = HoverState.None; public virtual bool InteractUpdate(MouseState mouseState, MouseState prevmouseState) diff --git a/DangerousD/GameCore/UI/Elements/Slider.cs b/DangerousD/GameCore/UI/Elements/Slider.cs index 7656f64..aa7031d 100644 --- a/DangerousD/GameCore/UI/Elements/Slider.cs +++ b/DangerousD/GameCore/UI/Elements/Slider.cs @@ -12,6 +12,9 @@ namespace MonogameLibrary.UI.Elements { public class Slider : MonoDrawableTextedUI, IInteractable { + public Slider(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex) + { + } public delegate void OnSliderChanges(float value); public event OnSliderChanges? SliderChanged; diff --git a/DangerousD/GameCore/UI/Elements/TextBox.cs b/DangerousD/GameCore/UI/Elements/TextBox.cs index 1661942..8969b00 100644 --- a/DangerousD/GameCore/UI/Elements/TextBox.cs +++ b/DangerousD/GameCore/UI/Elements/TextBox.cs @@ -14,6 +14,9 @@ namespace MonogameLibrary.UI.Elements { public class TextBox : MonoDrawableTextedUI, IInteractable { + public TextBox(MonoClassManagerUI MyUIManager = null, int layerIndex = 0) : base(MyUIManager, layerIndex) + { + } public delegate void OnTextChange(string text); public event OnTextChange? TextChanged; public event OnTextChange? StopChanging; @@ -34,7 +37,7 @@ namespace MonogameLibrary.UI.Elements { if (isSelected == IsSelected.Selected) { - if (MonoClassManagerUI.GetKeyboardState.IsKeyDown(Keys.Enter)) + if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { OnEnter?.Invoke(text); if (shouldEndOnEnter) @@ -110,7 +113,7 @@ namespace MonogameLibrary.UI.Elements public static void GetInput(ref string text) { - var state = MonoClassManagerUI.GetKeyboardState; + var state = Keyboard.GetState(); var keys = state.GetPressedKeys(); isShiftPressed = state.IsKeyDown(Keys.LeftShift) || state.IsKeyDown(Keys.RightShift); isCTRLPressed = state.IsKeyDown(Keys.LeftControl) || state.IsKeyDown(Keys.RightControl); diff --git a/DangerousD/Program.cs b/DangerousD/Program.cs index a36e5d1..b6f0be5 100644 --- a/DangerousD/Program.cs +++ b/DangerousD/Program.cs @@ -1,4 +1,5 @@ -using System; +using DangerousD.GameCore; +using System; namespace DangerousD {