public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            _position += _velocity;

            if (_panelState == PanelState.Waiting && Condition != null && Condition(gameTime))
            {
                IsVisible = true;
                Velocity  = new Vector2(0, 0.75f);
                changeState(PanelState.Sliding);
            }

            if (_panelState == PanelState.Sliding && Position.Y > 0)
            {
                Velocity = Vector2.Zero;
                if (AchievementEarned != null)
                {
                    AchievementEarned(this, EventArgs.Empty);
                }
                changeState(PanelState.Fading);
            }

            if (_panelState == PanelState.Fading)
            {
                TintColor = new Color(TintColor.ToVector4() - (Vector4.One / _colorDeteriorationfactor));
                _colorDeteriorationfactor *= 0.98f;

                if (TintColor.R <= 0 && TintColor.G <= 0 && TintColor.B <= 0 && TintColor.A <= 0)
                {
                    IsVisible = false;
                    TintColor = Color.White;
                    changeState(PanelState.Done);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Draws all of the subsprites of this <see cref="ComplexSprite"/> to the specified <see cref="SpriteBatch"/>.
        /// </summary>
        /// <param name="spriteBatch">The <see cref="SpriteBatch"/> to render objects to.</param>
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!_isVisible)
            {
                return;
            }

            foreach (var drawable in Subsprites)
            {
                if (!drawable.IsVisible)
                {
                    continue;
                }

                Vector2       pos    = drawable.Position;
                Vector2       origin = drawable.Origin;
                SpriteEffects effect = drawable.Effects;
                float         rotate = drawable.Rotation;
                Vector2       scale  = drawable.Scale;
                Color         tint   = drawable.TintColor;

                drawable.Effects  |= _effects;
                drawable.Origin   += Origin;
                drawable.Position += Position;
                drawable.Rotation += Rotation;
                drawable.Scale    *= Scale;
                drawable.TintColor = new Color(TintColor.ToVector4() * drawable.TintColor.ToVector4());

                drawable.Draw(spriteBatch);

                drawable.Effects   = effect;
                drawable.Origin    = origin;
                drawable.Position  = pos;
                drawable.Rotation  = rotate;
                drawable.Scale     = scale;
                drawable.TintColor = tint;
            }
        }