Exemple #1
0
        protected async override void Update(GameTime gameTime)
        {
            if (IsPaused)
            {
                return;
            }
            Touch.Update(gameTime);
            Mouse.Update(gameTime);
            UnifiedInput.Update(gameTime);
            KeyboardInput.Update(gameTime);
            //TODO Update Code

            foreach (var backgroundParticle in _backgroundParticles)
            {
                backgroundParticle.Update(gameTime);
            }


            if (_fade1Xin)
            {
                FadeX1 += 0.025f;
                if (FadeX1 >= 1f)
                {
                    _fade1Xin = false;
                }
            }
            else
            {
                FadeX1 -= 0.025f;
                if (FadeX1 <= .5f)
                {
                    _fade1Xin = true;
                }
            }
            if (_fade2Xin)
            {
                FadeX2 += 0.05f;
                if (FadeX2 >= 1f)
                {
                    _fade2Xin = false;
                }
            }
            else
            {
                FadeX2 -= 0.05f;
                if (FadeX2 <= 0.5f)
                {
                    _fade2Xin = true;
                }
            }

            if ((_currentComponent ?? this).Transition >= 1f)
            {
                NextComponent = (_currentComponent ?? this).Update(gameTime, this);
            }

            if (_currentComponent != null)
            {
                _currentComponent.Transition += 0.05f;
                if (_currentComponent.HasPrevious && _taps.Any(t => new Rectangle((int)Width - 64, 0, 64, 64).Contains(t)))
                {
                    Audio.Play(Cues.Fail);
                    _currentComponent.Back();
                }


                if (_currentComponent.HasPrevious && KeyboardInput.TypedKey(Keys.Escape))
                {
                    Audio.Play(Cues.Fail);
                    _currentComponent.Back();
                }
            }
            if (_previousComponent != null)
            {
                _previousComponent.Transition -= 0.05f;
            }

            if (NextComponent != null && NextComponent != _currentComponent)
            {
                GameData.Save();
                _previousComponent = _currentComponent;
                _currentComponent  = NextComponent;
            }

            _taps.Clear();
            base.Update(gameTime);
        }