/// <summary> /// Constructs the Game. Creates the graphics manager and engine component. Then calls SetupEngineComponent, SetupGraphics, and SetupGame, /// in that order. This constructor should be called from your game's Main function or from a function in the same Assembly as Main. /// </summary> public TorqueGame() { // locate the calling assembly. The torque engine component will need it. Assembly executingAssembly = Assembly.GetCallingAssembly(); // make sure it is not Torque bool isTorque = executingAssembly == typeof(TorqueGame).Assembly; Assert.Fatal(!isTorque, "TorqueGame Constructor - Found Torque as calling assembly, this is not expected. Construct the TorqueGame class from your game's Main function or from a function in the same Assembly as Main"); // create graphics and engine component _graphicsManager = new Microsoft.Xna.Framework.GraphicsDeviceManager(this); this._engineComponent = new GarageGames.Torque.XNA.TorqueEngineComponent(this, this._graphicsManager); this._engineComponent.ExecutableAssembly = executingAssembly; // add engine component this.Components.Add(this._engineComponent); // setup engine component SetupEngineComponent(); if (TorqueEngineComponent.Instance.Settings.EnableAntiAliasing) { _graphicsManager.PreferMultiSampling = true; _graphicsManager.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(OnPrepDeviceSettings); } // setup graphics - do this after engine component so that code can override engine component settings SetupGraphics(); // setup game SetupGame(); // We need to allow the schema export to happen before we start running the game if (ExportSchema) LoadEngineFrameworks(); }
///<summary> ///Initialize the library using delegates to hook back to the ///application ///</summary> ///<param name="engine">Torque engine component</param> ///<param name="soundBank">sound bank</param> ///<param name="exit">game exit</param> ///<param name="gamePausedGetter"> ///getter for <see cref="GamePaused"/> property ///</param> ///<param name="gamePausedSetter"> ///setter for <see cref="GamePaused"/> property ///</param> public static void Initialize( TorqueEngineComponent engine, SoundBank soundBank, ExitDelegate exit, Getter<bool> gamePausedGetter, Setter<bool> gamePausedSetter) { _engine = engine; _soundBank = soundBank; _exit = exit; _gamePausedGetter = gamePausedGetter; _gamePausedSetter = gamePausedSetter; }
/// <summary> /// Constructs the engine component. Initializes the engine component with default settings, as defined /// in TorqueEngineSettings. Settings can be overridden be calling LoadSettings on the component. This /// constructor should be called either from the TorqueGame class or from the main assembly of your game. /// Note that only one TorqueEngineComponent is allowed to exist at one time. /// </summary> /// <param name="game">The XNA game object.</param> /// <param name="manager">The XNA graphics manager.</param> public TorqueEngineComponent(Game game, GraphicsDeviceManager manager) : base(game) { Assert.Fatal(_instance == null, "TorqueEngineComponent - Only one TorqueEngineComponent is allowed!"); _instance = this; // create default settings object _settings = new TorqueEngineSettings(); _graphicsManager = manager; // Set the default executable assembly to the calling assembly. This should be the assembly containing the game's Main function. // Note that if the engine component is created from TorqueGame, the calling assembly is actually Torque, which is wrong, but // TorqueGame corrects for this. The code here is only needed for games that do not use TorqueGame. ExecutableAssembly = Assembly.GetCallingAssembly(); }
///<summary> ///Initialize the library using delegates to hook back to the ///application ///</summary> ///<param name="engine">Torque engine component</param> public static void Initialize(TorqueEngineComponent engine) { _engine = engine; }