first steps
This commit is contained in:
parent
a12a7bad36
commit
ea4a2f31fc
5 changed files with 40 additions and 4 deletions
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||||
using DangerousD.GameCore.Managers;
|
using DangerousD.GameCore.Managers;
|
||||||
using MonogameLibrary.UI.Base;
|
using MonogameLibrary.UI.Base;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using DangerousD.GameCore.Network;
|
||||||
|
|
||||||
namespace DangerousD.GameCore.GUI
|
namespace DangerousD.GameCore.GUI
|
||||||
{
|
{
|
||||||
|
@ -55,7 +56,10 @@ namespace DangerousD.GameCore.GUI
|
||||||
fontName = "font2"
|
fontName = "font2"
|
||||||
};
|
};
|
||||||
hostButton.LeftButtonPressed += () => {
|
hostButton.LeftButtonPressed += () => {
|
||||||
|
|
||||||
|
AppManager.Instance.NetworkManager.HostInit("");
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Button refreshButton = new ButtonText(Manager)
|
Button refreshButton = new ButtonText(Manager)
|
||||||
|
|
|
@ -14,12 +14,14 @@ using DangerousD.GameCore.Managers;
|
||||||
namespace DangerousD.GameCore
|
namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public enum GameState { Menu, Options, Lobby, Game, Login }
|
public enum GameState { Menu, Options, Lobby, Game, Login }
|
||||||
|
public enum MultiPlayerStatus { SinglePlayer, Host, Client }
|
||||||
public class AppManager : Game
|
public class AppManager : Game
|
||||||
{
|
{
|
||||||
public static AppManager Instance { get; private set; }
|
public static AppManager Instance { get; private set; }
|
||||||
private GraphicsDeviceManager _graphics;
|
private GraphicsDeviceManager _graphics;
|
||||||
private SpriteBatch _spriteBatch;
|
private SpriteBatch _spriteBatch;
|
||||||
GameState gameState;
|
public GameState gameState { get; private set; }
|
||||||
|
public MultiPlayerStatus multiPlayerStatus { get; private set; }
|
||||||
IDrawableObject MenuGUI;
|
IDrawableObject MenuGUI;
|
||||||
IDrawableObject OptionsGUI;
|
IDrawableObject OptionsGUI;
|
||||||
IDrawableObject LoginGUI;
|
IDrawableObject LoginGUI;
|
||||||
|
@ -45,6 +47,8 @@ namespace DangerousD.GameCore
|
||||||
SettingsManager = new SettingsManager();
|
SettingsManager = new SettingsManager();
|
||||||
SettingsManager.LoadSettings();
|
SettingsManager.LoadSettings();
|
||||||
|
|
||||||
|
NetworkManager.GetReceivingMessages += NetworkSync;
|
||||||
|
|
||||||
resolution = SettingsManager.Resolution;
|
resolution = SettingsManager.Resolution;
|
||||||
_graphics.PreferredBackBufferWidth = resolution.X;
|
_graphics.PreferredBackBufferWidth = resolution.X;
|
||||||
_graphics.PreferredBackBufferHeight = resolution.Y;
|
_graphics.PreferredBackBufferHeight = resolution.Y;
|
||||||
|
@ -167,5 +171,13 @@ namespace DangerousD.GameCore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void NetworkSync(NetworkTask networkTask)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public void SetMultiplayerState(MultiPlayerStatus multiPlayerStatus)
|
||||||
|
{
|
||||||
|
this.multiPlayerStatus = multiPlayerStatus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace DangerousD.GameCore
|
||||||
{
|
{
|
||||||
public class GameManager
|
public class GameManager
|
||||||
{
|
{
|
||||||
|
public List<GameObject> GetAllGameObjects { get; private set; }
|
||||||
public List<LivingEntity> livingEntities;
|
public List<LivingEntity> livingEntities;
|
||||||
public List<Entity> entities;
|
public List<Entity> entities;
|
||||||
public List<MapObject> mapObjects;
|
public List<MapObject> mapObjects;
|
||||||
|
@ -22,6 +22,7 @@ namespace DangerousD.GameCore
|
||||||
public Player GetPlayer1 { get; private set; }
|
public Player GetPlayer1 { get; private set; }
|
||||||
public GameManager()
|
public GameManager()
|
||||||
{
|
{
|
||||||
|
GetAllGameObjects = new List<GameObject>();
|
||||||
livingEntities = new List<LivingEntity>();
|
livingEntities = new List<LivingEntity>();
|
||||||
mapObjects = new List<MapObject>();
|
mapObjects = new List<MapObject>();
|
||||||
entities = new List<Entity>();
|
entities = new List<Entity>();
|
||||||
|
@ -33,6 +34,7 @@ namespace DangerousD.GameCore
|
||||||
|
|
||||||
internal void Register(GameObject gameObject)
|
internal void Register(GameObject gameObject)
|
||||||
{
|
{
|
||||||
|
GetAllGameObjects.Add(gameObject);
|
||||||
if (gameObject is LivingEntity)
|
if (gameObject is LivingEntity)
|
||||||
livingEntities.Add(gameObject as LivingEntity);
|
livingEntities.Add(gameObject as LivingEntity);
|
||||||
if (gameObject is Entity)
|
if (gameObject is Entity)
|
||||||
|
|
|
@ -206,5 +206,22 @@ namespace DangerousD.GameCore.Managers
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<GameObject> CheckRectangle(Rectangle rectangle, Type type)
|
||||||
|
{
|
||||||
|
var gameObjects = AppManager.Instance.GameManager.GetAllGameObjects;
|
||||||
|
List<GameObject> intersected = new List<GameObject>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,6 +42,7 @@ namespace DangerousD.GameCore
|
||||||
sound.SoundEffect.Volume = (float)sound.GetDistance(playerPos) / MaxSoundDistance;
|
sound.SoundEffect.Volume = (float)sound.GetDistance(playerPos) / MaxSoundDistance;
|
||||||
sound.SoundEffect.Play();
|
sound.SoundEffect.Play();
|
||||||
PlayingSounds.Add(sound);
|
PlayingSounds.Add(sound);
|
||||||
|
AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(sound.Position, soundName));
|
||||||
}
|
}
|
||||||
public void StopAllSounds() // остановка всех звуков
|
public void StopAllSounds() // остановка всех звуков
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue