Sharpcraft.Sharpcraft.Sharpcraft C# (CSharp) Method

Sharpcraft() public method

Initializes a new instance of Sharpcraft.
public Sharpcraft ( User user ) : System
user User
return System
        public Sharpcraft(User user)
        {
            _log = LogManager.GetLogger(this);
            _settings = new GameSettings(Constants.GameSettings);
            _user = user;
            if (File.Exists(Constants.GameSettings))
            {
                _log.Info("Loading game settings from file...");
                var reader = new StreamReader(Constants.GameSettings);
                _settings = new JsonSerializer().Deserialize<GameSettings>(new JsonTextReader(reader));
                _log.Info("Game settings loaded successfully!");
                reader.Close();
            }
            else
            {
                _settings = new GameSettings(Constants.GameSettings) {Size = new Point(1280, 720)};
            }
            _log.Debug("Initializing graphics device.");
            _graphics = new GraphicsDeviceManager(this);
            if (_settings.Fullscreen)
            {
                _graphics.IsFullScreen = true;
                _settings.Size = new Point(SystemInformation.PrimaryMonitorSize.Width, SystemInformation.PrimaryMonitorSize.Height);
            }
            _graphics.PreferredBackBufferWidth = _settings.Size.X;
            _graphics.PreferredBackBufferHeight = _settings.Size.Y;
            _log.Debug("Setting content directory.");
            Content.RootDirectory = Constants.ContentDirectory;
            _log.Debug("Creating DebugDisplay...");
            Components.Add(new DebugDisplay(this, _graphics));
            #if DEBUG
            _gameMenuOpen = true;
            #endif
        }