Main class of Sharpcraft, this is the game itself.
Most documentation in this class comes from XNA.
Inheritance: Microsoft.Xna.Framework.Game
示例#1
0
 /// <summary>
 /// Runs the game.
 /// </summary>
 private void RunGame()
 {
     _log.Debug("RunGame();");
     _game = new Sharpcraft(_user);
     _log.Debug("Registering to Game.Exiting event.");
     _game.Exiting += GameExit;
     _gameRunning   = true;
     _log.Info("Running game...");
     SetState(false);
     try
     {
         _game.Run();
     }
     catch (System.Net.Sockets.SocketException ex)            // This should be catched/checked somewhere else.
     {
         _log.Warn("Failed to connect to server. " + ex.GetType() + " thrown: " + ex.Message);
         _log.Warn("Stack Trace:\n" + ex.StackTrace);
         MessageBox.Show("Failed to connect to server! " + ex.GetType() + " thrown with message: " + ex.Message,
                         "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         _game.Exiting -= GameExit;
         if (_game.IsActive)
         {
             _game.Exit();
         }
         _gameRunning = false;
         _game        = null;
         SetState(true);
     }
     _log.Debug("RunGame(); ## END ##");
 }
示例#2
0
 /// <summary>
 /// Close the game and unload components.
 /// </summary>
 private void CloseGame()
 {
     _log.Info("Unloading game components...");
     _game.Dispose();
     if (_game.IsActive)
     {
         _game.Exit();
     }
     //_gameThread.Abort(); // Causes application to freeze indefinately.
     //_gameThread.Join();
     if (_game != null)
     {
         _game.Exiting -= GameExit;
     }
     _game        = null;
     _gameRunning = false;
     _log.Info("Game components unloaded!");
 }
示例#3
0
 /// <summary>
 /// Runs the game.
 /// </summary>
 private void RunGame()
 {
     _log.Debug("RunGame();");
     _game = new Sharpcraft(_user);
     _log.Debug("Registering to Game.Exiting event.");
     _game.Exiting += GameExit;
     _gameRunning = true;
     _log.Info("Running game...");
     SetState(false);
     try
     {
         _game.Run();
     }
     catch(System.Net.Sockets.SocketException ex) // This should be catched/checked somewhere else.
     {
         _log.Warn("Failed to connect to server. " + ex.GetType() + " thrown: " + ex.Message);
         _log.Warn("Stack Trace:\n" + ex.StackTrace);
         MessageBox.Show("Failed to connect to server! " + ex.GetType() + " thrown with message: " + ex.Message,
                         "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         _game.Exiting -= GameExit;
         if (_game.IsActive)
             _game.Exit();
         _gameRunning = false;
         _game = null;
         SetState(true);
     }
     _log.Debug("RunGame(); ## END ##");
 }
示例#4
0
 /// <summary>
 /// Close the game and unload components.
 /// </summary>
 private void CloseGame()
 {
     _log.Info("Unloading game components...");
     _game.Dispose();
     if (_game.IsActive)
         _game.Exit();
     //_gameThread.Abort(); // Causes application to freeze indefinately.
     //_gameThread.Join();
     if (_game != null)
         _game.Exiting -= GameExit;
     _game = null;
     _gameRunning = false;
     _log.Info("Game components unloaded!");
 }