Esempio n. 1
0
        /// <summary>
        /// Frame renewal
        /// </summary>
        /// <param name="gameTime">Snapshot of Timing values</param>
        /// <param name="otherScreenHasFocus"></param>
        /// <param name="coveredByOtherScreen"></param>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            if ((_popupScreen != null && (_popupScreen.ScreenState == Services.ScreenState.Active || _popupScreen.IsTransitioning)) ||
                otherScreenHasFocus)
            {
                return;
            }

            if (_isRewinding)
            {
                _timeline.RewindFrame();
                if (_timeline.CurrentTime <= 0.01)
                {
                    _timeline.Start();
                    _isRewinding = false;

                    _field.ResetBlockGenerator();
                }
            }

            _field.Update(gameTime);
            _controller.Update(gameTime);

            _spriteField.Update(gameTime);
            _spriteFallingBlock.Update(gameTime);
            _spriteGhostBlock.Update(gameTime);
            _spriteNextBlock.Update(gameTime);
            _spriteNextBlockBoundary.Update(gameTime);
            _spriteHoldBlock.Update(gameTime);
            _spriteHoldBlockBoundary.Update(gameTime);

            var removablePopups = new List <SpriteScorePopup>();

            _spriteScorePopups.ForEach(a => { a.Update(gameTime); if (a.IsFinished)
                                              {
                                                  removablePopups.Add(a);
                                              }
                                       });
            removablePopups.ForEach(a => _spriteScorePopups.Remove(a));

            var deltaScore = Math.Min((_field.Score - _displayScore),
                                      Math.Max((Single)(100 * gameTime.ElapsedGameTime.TotalSeconds),
                                               (Single)((_field.Score - _displayScore) * gameTime.ElapsedGameTime.TotalSeconds)));

            _displayScore   = _displayScore + deltaScore;
            _scoreIncrement = Math.Min(_scoreIncrement, (_field.Score - _displayScore));
        }