Beispiel #1
0
        protected virtual void Update(GameTime gameTime)
        {
            if (_initialized)
            {
                foreach (GameComponent gc in _gameComponentCollection)
                {
                    if (gc.Enabled)
                    {
                        gc.Update(gameTime);
                    }
                }
            }
            else
            {
                if (!_initializing)
                {
                    _initializing = true;

                    // Use OpenGLES context switching as described here
                    // http://developer.apple.com/iphone/library/qa/qa2010/qa1612.html
                    InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate(InitializeGameComponents);

                    // Invoke on thread from the pool
                    initD.BeginInvoke(
                        delegate(IAsyncResult iar)
                    {
                        // We must have finished initialising, so set our flag appropriately
                        // So that we enter the Update loop
                        _initialized  = true;
                        _initializing = false;
                    },
                        initD);
                }
            }
        }
Beispiel #2
0
        protected virtual void Update(GameTime gameTime)
        {
            if (_initialized /* TODO && !Guide.IsVisible */)
            {
                foreach (GameComponent gc in _gameComponentCollection)
                {
                    if (gc.Enabled)
                    {
                        gc.Update(gameTime);
                    }
                }
            }
            else
            {
                if (!_initializing)
                {
                    _initializing = true;

                    // Use OpenGL context locking in delegate function
                    InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate(InitializeGameComponents);

                    // Invoke on thread from the pool
                    initD.BeginInvoke(
                        delegate(IAsyncResult iar)
                    {
                        // We must have finished initialising, so set our flag appropriately
                        // So that we enter the Update loop
                        _initialized  = true;
                        _initializing = false;
                    },
                        initD);
                }
            }
        }
Beispiel #3
0
        protected virtual void Update(GameTime gameTime)
        {
            if (_initialized /* TODO && !Guide.IsVisible */)
            {
//				foreach (GameComponent gc in _gameComponentCollection) {
//					if (gc.Enabled) {
//						gc.Update (gameTime);
//					}
//				}

                // Changed from foreach to for loop in case the GameComponents's Update method
                //   modifies the component collection.  With a foreach it causes an error:
                //  "Collection was modified; enumeration operation may not execute."
                //  .Net 4.0 I thought got around this but in Mono 2.10.2 we still get this error.
                for (int x = 0; x < _gameComponentCollection.Count; x++)
                {
                    var gc = (GameComponent)_gameComponentCollection[x];
                    if (gc.Enabled)
                    {
                        gc.Update(gameTime);
                    }
                }
            }
            else
            {
                if (!_initializing)
                {
                    _initializing = true;

                    // Use OpenGL context locking in delegate function
                    InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate(InitializeGameComponents);

                    // Invoke on thread from the pool
                    initD.BeginInvoke(
                        delegate(IAsyncResult iar)
                    {
                        // We must have finished initialising, so set our flag appropriately
                        // So that we enter the Update loop
                        _initialized  = true;
                        _initializing = false;
                    },
                        initD);
                }
            }
        }
Beispiel #4
0
        protected virtual void Update(GameTime gameTime)
        {
            if (_initialized && !Guide.IsVisible)
            {
                // Changed from foreach to for loop in case the GameComponents's Update method
                //   modifies the component collection.  With a foreach it causes an error:
                //  "Collection was modified; enumeration operation may not execute."
                //  .Net 4.0 I thought got around this but in Mono 2.10.2 we still get this error.
                for (int x = 0; x < _gameComponentCollection.Count; x++)
                {
                    var gc = (GameComponent)_gameComponentCollection[x];
                    if (gc.Enabled)
                    {
                        gc.Update(gameTime);
                    }
                }
            }
            else
            {
                if (!_initializing)
                {
                    _initializing = true;

                    // Use OpenGLES context switching as described here
                    // http://developer.apple.com/iphone/library/qa/qa2010/qa1612.html
                    InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate(InitializeGameComponents);

                    // Invoke on thread from the pool
                    initD.BeginInvoke(
                        delegate(IAsyncResult iar)
                    {
                        // We must have finished initialising, so set our flag appropriately
                        // So that we enter the Update loop
                        _initialized  = true;
                        _initializing = false;
                    },
                        initD);
                }
            }
        }
Beispiel #5
0
        protected virtual void Update(GameTime gameTime)
        {
            if ( _initialized  && !Guide.IsVisible )
            {
                foreach (GameComponent gc in _gameComponentCollection)
                {
                    if (gc.Enabled)
                    {
                        gc.Update(gameTime);
                    }
                }
            }
            else
            {
                if (!_initializing)
                {
                    _initializing = true;

                    // Use OpenGLES context switching as described here
                    // http://developer.apple.com/iphone/library/qa/qa2010/qa1612.html
                    InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate(InitializeGameComponents);

                    // Invoke on thread from the pool
                    initD.BeginInvoke(
                        delegate (IAsyncResult iar)
                        {
                            // We must have finished initialising, so set our flag appropriately
                            // So that we enter the Update loop
                            _initialized = true;
                            _initializing = false;
                        },
                    initD);
                }
            }
        }
Beispiel #6
0
        protected virtual void Update(GameTime gameTime)
        {
            if (_initialized) { // && !Guide.IsVisible ) {

                // Changed from foreach to for loop in case the GameComponents's Update method
                //   modifies the component collection.  With a foreach it causes an error:
                //  "Collection was modified; enumeration operation may not execute."
                //  .Net 4.0 I thought got around this but in Mono 2.10.2 we still get this error.
                for (int x = 0; x < _gameComponentCollection.Count; x++) {
                    var gc = (GameComponent)_gameComponentCollection[x];
                    if (gc.Enabled) {
                        gc.Update (gameTime);
                    }
                }

            } else {

                // TODO: We can probably take this out but will wait until the next round
                //  of code checking.
                //  This should have all been moved to the Run method for initialization
                if (!_initializing) {
                    _initializing = true;

                    // Use OpenGL context locking in delegate function
                    InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate (InitializeGameComponents);

                    // Invoke on thread from the pool
                    initD.BeginInvoke (
                        delegate (IAsyncResult iar)
                        {
                            // We must have finished initialising, so set our flag appropriately
                            // So that we enter the Update loop
                            _initialized = true;
                            _initializing = false;
                        },
                    initD);
                }
            }
Beispiel #7
0
        protected virtual void Update(GameTime gameTime)
        {
            if ( _initialized  && !Guide.IsVisible )
            {
                // Changed from foreach to for loop in case the GameComponents's Update method
                //   modifies the component collection.  With a foreach it causes an error:
                //  "Collection was modified; enumeration operation may not execute."
                //  .Net 4.0 I thought got around this but in Mono 2.10.2 we still get this error.
                for (int x = 0; x < _gameComponentCollection.Count; x++) {
                    var gc = (GameComponent)_gameComponentCollection[x];
                    if (gc.Enabled) {
                        gc.Update (gameTime);
                    }
                }
            }
            else
            {
                if (!_initializing)
                {
                    _initializing = true;

                    // Use OpenGLES context switching as described here
                    // http://developer.apple.com/iphone/library/qa/qa2010/qa1612.html
                    InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate(InitializeGameComponents);

                    // Invoke on thread from the pool
                    initD.BeginInvoke(
                        delegate (IAsyncResult iar)
                        {
                            // We must have finished initialising, so set our flag appropriately
                            // So that we enter the Update loop
                            _initialized = true;
                            _initializing = false;
                        },
                    initD);
                }
            }
        }
Beispiel #8
0
        protected virtual void Update(GameTime gameTime)
        {
            if (_initialized  /* TODO && !Guide.IsVisible */) {
                foreach (GameComponent gc in _gameComponentCollection) {
                    if (gc.Enabled) {
                        gc.Update (gameTime);
                    }
                }
            } else {
                if (!_initializing) {
                    _initializing = true;

                    // Use OpenGL context locking in delegate function
                    InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate (InitializeGameComponents);

                    // Invoke on thread from the pool
                    initD.BeginInvoke (
                        delegate (IAsyncResult iar)
                        {
                            // We must have finished initialising, so set our flag appropriately
                            // So that we enter the Update loop
                            _initialized = true;
                            _initializing = false;
                        },
                    initD);
                }
            }
        }
Beispiel #9
0
        internal void DoUpdate(GameTime aGameTime)
        {
            if (_isActive)
            {
                if (_initialized)
                {
                    Update(aGameTime);
                }
                else
                {
                    if (!_initializing)
                    {
                        _initializing = true;

                        // Use OpenGLES context switching as described here
                        // http://developer.apple.com/iphone/library/qa/qa2010/qa1612.html
                        InitialiseGameComponentsDelegate initD = new InitialiseGameComponentsDelegate(InitializeGameComponents);

                        // Invoke on thread from the pool
                        initD.BeginInvoke(
                            delegate (IAsyncResult iar)
                            {
                                // We must have finished initialising, so set our flag appropriately
                                // So that we enter the Update loop
                                _initialized = true;
                                _initializing = false;
                            },
                        initD);
                    }
                }
            }
        }