Inheritance: System.Windows.Controls.ContentControl, IDisposable
Ejemplo n.º 1
0
 void IInternalGameModule.Prepare(DrawingSurface drawingSurface, IServiceProvider provider)
 {
     _drawingSurface = drawingSurface;
     GraphicsDevice = drawingSurface.GraphicsDevice;
     SpriteBatch = new SpriteBatch((GraphicsDevice)provider.GetService(typeof(GraphicsDevice)));
     Content = new ContentManager(provider, _contentDirectory);
     _updater = new GameUpdater(Update, drawingSurface.Invalidate);
 }
Ejemplo n.º 2
0
        private void OnGameModuleChanged()
        {
            if (_game != null)
                throw new InvalidOperationException();

            _game = GameModule;
            _internalModule = (IInternalGameModule)GameModule;

            _drawingSurface = new DrawingSurface();
            _drawingSurface.Loaded += OnDrawingSurfaceLoaded;
            _drawingSurface.Unloaded += OnDrawingSurfaceUnloaded;

            _drawingSurface.LoadContent += OnLoadContent;
            _drawingSurface.Draw += OnDraw;
            _drawingSurface.MouseMove += OnMouseMove;
            _drawingSurface.MouseDown += OnMouseDown;

            KeyDown += OnKeyDown;
            Content = _drawingSurface;
        }
Ejemplo n.º 3
0
        private void OnGameModuleChanged()
        {
            if (_game != null)
            {
                throw new InvalidOperationException();
            }

            _game           = GameModule;
            _internalModule = (IInternalGameModule)GameModule;

            _drawingSurface           = new DrawingSurface();
            _drawingSurface.Loaded   += OnDrawingSurfaceLoaded;
            _drawingSurface.Unloaded += OnDrawingSurfaceUnloaded;

            _drawingSurface.LoadContent += OnLoadContent;
            _drawingSurface.Draw        += OnDraw;
            _drawingSurface.MouseMove   += OnMouseMove;
            _drawingSurface.MouseDown   += OnMouseDown;

            KeyDown += OnKeyDown;
            Content  = _drawingSurface;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new GameModule's instance.
        /// </summary>
        public GameModule()
        {
            this.IsFixedTimeStep = true;

            // Initialize mouse and keyboard parent game module
            WPFMouse.PrimaryGameModule = this;
            WPFKeyboard.PrimaryGameModule = this;
            
            // Initialize drawing surface
            this.drawingSurface = new DrawingSurface();
            this.drawingSurface.Loaded += DrawingSurface_Loaded;
            this.drawingSurface.Unloaded += DrawingSurface_Unloaded;
            this.drawingSurface.LoadContent += this.DrawingSurface_LoadContent;
            this.drawingSurface.Draw += this.DrawingSurface_Draw;

            // Initialize mouse and keyboard events handlers
            this.MouseMove += this.UpdateMouse;
            this.MouseDown += this.UpdateMouse;
            this.MouseUp += this.UpdateMouse;
            this.MouseWheel += this.UpdateMouse;
            this.KeyDown += this.UpdateKeyboard;
            this.KeyUp += this.UpdateKeyboard;

            // Initialize game updater
            this.updater = new GameModuleUpdater(this, this.Update);

            // Set the drawing surface as the GameModule's content
            this.Content = this.drawingSurface;
        }
Ejemplo n.º 5
0
 public DrawEventArgs(DrawingSurface drawingSurface, GraphicsDevice graphicsDevice)
     : base(graphicsDevice)
 {
     _drawingSurface = drawingSurface;
 }