Beispiel #1
0
 public Shape(string name, string image, ShapeStatus status, string description)
 {
     Name        = name;
     Image       = image;
     Status      = status;
     Description = description;
 }
Beispiel #2
0
        /// <summary>
        /// Updates this sub-sprite.
        /// </summary>
        /// <param name="drawRec">The rectangle to draw in.</param>
        /// <param name="shapeStatus">The shape that the full sprite should take.</param>
        /// <param name="movementStatus">The direction the sprite is moving.</param>
        /// <param name="gameTime">For animation timers.</param>
        public void Update(Rectangle drawRec, ShapeStatus shapeStatus, MovementStatus movementStatus, GameTime gameTime)
        {
            // update and animate the base
            base.Update(drawRec, shapeStatus, gameTime);
            base.Animate(gameTime);

            // run animations
            Animate(movementStatus, gameTime);
        }
Beispiel #3
0
        /// <summary>
        /// Method to update this sub-sprite (including animations)
        /// </summary>
        /// <param name="drawRec">The draw rectangle (for the position for movement).</param>
        /// <param name="shapeStatus">The shape to draw.</param>
        public void Update(Rectangle drawRec, ShapeStatus shapeStatus, GameTime gameTime)
        {
            // updating some drawRectangle position
            drawRectangle = drawRec;
            charShapeStatusHold = shapeStatus;
            if (!runShiftingAnimation && charShapeStatusHold != charShapeStatus)
            {
                runShiftingAnimation = true;
                shiftingTimer = 0;
            }

            // run animations
            Animate(gameTime);
        }
Beispiel #4
0
        /// <summary>
        /// Animate the shape (wiggle when moving, shape shift animation).
        /// </summary>
        /// <param name="movementStatus">The direction the shape is moving.</param>
        /// <param name="gameTime">For the ellapsed game time.</param>
        protected void Animate(GameTime gameTime)
        {
            // Check if a shape shift should occurr or if one is in progress.
            if (runShiftingAnimation)
            {
                // update the gametime
                shiftingTimer += gameTime.ElapsedGameTime.Milliseconds;

                // if the actual shape status is different than the hold, shrink
                if (charShapeStatus != charShapeStatusHold)
                {
                    int newWidth = (int)((1 - (double)shiftingTimer / (double)SHIFTING_UPDATE_TIME) * normalWidth);

                    if (newWidth < 0)
                    {
                        newWidth = 0;
                        charShapeStatus = charShapeStatusHold;
                        shiftingTimer = 0;
                    }

                    int shift = (int)((float)(drawRectangle.Width - newWidth) / 2.0);
                    drawRectangle.Width = newWidth;
                    drawRectangle.Height = newWidth;
                    drawRectangle.X += shift;
                    drawRectangle.Y += shift;
                }
                else
                {
                    int newWidth = (int)((double)shiftingTimer / (double)SHIFTING_UPDATE_TIME * normalWidth);

                    if (newWidth > normalWidth)
                    {
                        newWidth = normalWidth;
                        runShiftingAnimation = false;
                    }

                    int shift = (int)((float)(newWidth - drawRectangle.Width) / 2.0);
                    drawRectangle.Width = newWidth;
                    drawRectangle.Height = newWidth;
                    drawRectangle.X -= shift;
                    drawRectangle.Y -= shift;
                }
            }
        }