Beispiel #1
0
 protected internal virtual void Draw(DeltaGameTime time, SpriteBatch spriteBatch)
 {
     if (TintEnabled)
     {
         spriteBatch.Draw(G.PixelTexture, G.ScreenArea, Tint);
     }
     if (_flashDuration > _flashElapsed)
     {
         Color temp = _flashColor *= _flashElapsed / _flashDuration;
         spriteBatch.Draw(G.PixelTexture, G.ScreenArea, temp);
     }
 }
Beispiel #2
0
        internal virtual void Update(DeltaGameTime time)
        {
            // are we following the tracking entity, the player, or the goal position?
            if (IsTracking && Mode != CameraMode.FollowPlayer)
            {
                _position.X = MathHelper.SmoothStep(_position.X, Tracking.Position.X, _translationRate);
                _position.Y = MathHelper.SmoothStep(_position.Y, Tracking.Position.Y, _translationRate);
            }
            else if (!IsTracking && _moveDuration > 0.0f)
            {
                if (_moveElapsed > _moveDuration)
                {
                    _moveElapsed     = 0;
                    _moveDuration    = 0;
                    _desiredPosition = Vector2.Zero;
                }
                else
                {
                    _moveElapsed += time.ElapsedSeconds;
                    float amount = MathHelper.Clamp(_moveElapsed / _moveDuration, 0.0f, 1.0f);
                    _position.X = MathHelper.SmoothStep(_position.X, _desiredPosition.X, amount);
                    _position.Y = MathHelper.SmoothStep(_position.Y, _desiredPosition.Y, amount);
                }
            }

            UpdateShake(time.ElapsedSeconds);
            UpdateScale(time.ElapsedSeconds);

            if (BoundsEnabled)
            {
                _position.X = MathHelper.Clamp(_position.X + _shakeOffset.X, BoundedArea.Left + ViewingArea.Width / 2, BoundedArea.Right - ViewingArea.Width / 2);
                _position.Y = MathHelper.Clamp(_position.Y + _shakeOffset.Y, BoundedArea.Top + ViewingArea.Height / 2, BoundedArea.Bottom - ViewingArea.Height / 2);
            }

            if (_flashDuration > _flashElapsed)
            {
                _flashElapsed += time.ElapsedSeconds;
            }
            else
            {
                _flashDuration = 0;
                _flashElapsed  = 0;
            }

            UpdateView();
            UpdateProjection();
            UpdateWorld();
        }