Exemple #1
0
        protected override void OnExiting(object sender, EventArgs args)
        {
            base.OnExiting(sender, args);

            lastInstance = null;

            if (flagFirstDraw)
            {
                //Game terminated before calling Draw once
                //  This is most likely bad behaviour

                //Note: Maybe not with ApplicationContext, but with Application

                // This functionality was implemented for NUnit tests.
                // When multiple test of NUnit are run, creating XNAGame instances, only the first XNAGame runs, the latter shutdown
                // before the first run.
                // NUnit tests using XNA need the [RequiresThread( System.Threading.ApartmentState.STA )] attribute
                // in order to work properly. This exception will warn the user that the test in fact failed/was not run.
                throw new Exception(
                          "This game terminated before drawing once! Most likely there is something wrong with this threads ApplicationContext. It is also not allowed to terminated the game in the first update call!");
            }

            gameObjects = null;

            // This is again for unit testing, assuring that the XNADevice is cleaned up before executing next test
            System.Threading.Thread.Sleep(500);
        }
Exemple #2
0
        public XNAGame()
        {
#if NCRUNCH
            AutoShutdown         = 1;
            DefaultInputDisabled = true;
#endif

            lastInstance = this;

            graphics = new GraphicsDeviceManager(this);
            graphics.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);
            Content.RootDirectory             = Application.StartupPath + "\\";

            //Content.RootDirectory = "Content";

            rootDirectory = System.Windows.Forms.Application.StartupPath + "\\";

            keyboard    = new TWKeyboard();
            mouse       = new TWMouse(this);
            engineFiles = new XNAGameFiles();
            engineFiles.LoadDefaults(rootDirectory);

            spectaterCamera = new SpectaterCamera(this);
            SetCamera(spectaterCamera);

            guiService = new GuiServiceXNA(this);

            averageFPSCalculater = new AverageFPSCalculater();
            //cursor = new Cursor( this, EngineFiles.DefaultCursor, new Vector2( 10, 10 ) );

            AllowF3InputToggle = true;

            InputDisabled = DefaultInputDisabled;

            Wpf = new XNAGameWpf();
            AddXNAObject(Wpf);
        }