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 MonogameLibrary.UI.Base;
|
||||
using System.Diagnostics;
|
||||
using DangerousD.GameCore.Network;
|
||||
|
||||
namespace DangerousD.GameCore.GUI
|
||||
{
|
||||
|
@ -56,6 +57,9 @@ namespace DangerousD.GameCore.GUI
|
|||
};
|
||||
hostButton.LeftButtonPressed += () => {
|
||||
|
||||
AppManager.Instance.NetworkManager.HostInit("");
|
||||
|
||||
|
||||
};
|
||||
|
||||
Button refreshButton = new ButtonText(Manager)
|
||||
|
|
|
@ -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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace DangerousD.GameCore
|
|||
{
|
||||
public class GameManager
|
||||
{
|
||||
|
||||
public List<GameObject> GetAllGameObjects { get; private set; }
|
||||
public List<LivingEntity> livingEntities;
|
||||
public List<Entity> entities;
|
||||
public List<MapObject> mapObjects;
|
||||
|
@ -22,6 +22,7 @@ namespace DangerousD.GameCore
|
|||
public Player GetPlayer1 { get; private set; }
|
||||
public GameManager()
|
||||
{
|
||||
GetAllGameObjects = new List<GameObject>();
|
||||
livingEntities = new List<LivingEntity>();
|
||||
mapObjects = new List<MapObject>();
|
||||
entities = new List<Entity>();
|
||||
|
@ -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)
|
||||
|
|
|
@ -206,5 +206,22 @@ namespace DangerousD.GameCore.Managers
|
|||
}
|
||||
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.Play();
|
||||
PlayingSounds.Add(sound);
|
||||
AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(sound.Position, soundName));
|
||||
}
|
||||
public void StopAllSounds() // остановка всех звуков
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue