IGameObject

This commit is contained in:
Ivan Filipenkov 2023-08-14 18:13:48 +03:00
parent 42023d71cc
commit 4188745eed
3 changed files with 13 additions and 11 deletions

View file

@ -1,11 +1,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using MonogameLibrary.UI.Base; using MonogameLibrary.UI.Base;
namespace DangerousD.GameCore.GUI; namespace DangerousD.GameCore.GUI;
public abstract class AbstractGui : IGui public abstract class AbstractGui : IGameObject
{ {
protected UIManager Manager = new(); protected UIManager Manager = new();
protected List<DrawableUIElement> Elements = new(); protected List<DrawableUIElement> Elements = new();
@ -27,7 +28,7 @@ public abstract class AbstractGui : IGui
Manager.LoadContent(content); Manager.LoadContent(content);
} }
public virtual void Update() public virtual void Update(GameTime gameTime)
{ {
Manager.Update(); Manager.Update();
} }

View file

@ -1,13 +1,14 @@
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
namespace DangerousD.GameCore.GUI namespace DangerousD.GameCore.GUI
{ {
interface IGui interface IGameObject
{ {
void Initialize(GraphicsDevice graphicsDevice); void Initialize(GraphicsDevice graphicsDevice);
void LoadContent(ContentManager content); void LoadContent(ContentManager content);
void Update(); void Update(GameTime gameTime);
void Draw(SpriteBatch spriteBatch); void Draw(SpriteBatch spriteBatch);
} }
} }

View file

@ -16,9 +16,9 @@ namespace DangerousD.GameCore
private SpriteBatch _spriteBatch; private SpriteBatch _spriteBatch;
GameState gameState; GameState gameState;
IGui MenuGUI; IGameObject MenuGUI;
IGui OptionsGUI; IGameObject OptionsGUI;
IGui LobbyGUI; IGameObject LobbyGUI;
public AppManager() public AppManager()
{ {
_graphics = new GraphicsDeviceManager(this); _graphics = new GraphicsDeviceManager(this);
@ -50,13 +50,13 @@ namespace DangerousD.GameCore
switch (gameState) switch (gameState)
{ {
case GameState.Menu: case GameState.Menu:
MenuGUI.Update(); MenuGUI.Update(gameTime);
break; break;
case GameState.Options: case GameState.Options:
OptionsGUI.Update(); OptionsGUI.Update(gameTime);
break; break;
case GameState.Lobby: case GameState.Lobby:
LobbyGUI.Update(); LobbyGUI.Update(gameTime);
break; break;
case GameState.Game: case GameState.Game:
GameManager.Update(gameTime); GameManager.Update(gameTime);