public void Update(GameTime gameTime, Direction direction) { // Don't do anything if the sprite is not animating if (bAnimating) { // If there is not a currently active animation if (CurrentMoveAnimation == null) { // Make sure we have an animation associated with this sprite if (animations.Count > 0) { // Set the active animation to the first animation // associated with this sprite string[] sKeys = new string[animations.Count]; animations.Keys.CopyTo(sKeys, 0); CurrentAnimation = sKeys[0]; } else { return; } } // Run the Animation's update method CurrentMoveAnimation.Update(gameTime); Hitbox info = CurrentMoveAnimation.CurrentHitboxInfo; // Ready hitbox info // if (info != null) { hitbox = info.getHitboxRectangle(hurtbox, direction, v2Position, CurrentMoveAnimation.FrameWidth); } else { hitbox = new Rectangle(); } Hitbox hurtboxInfo = CurrentMoveAnimation.CurrentHurtboxInfo; // Set up the hurtbox for the move // if (hurtboxInfo != null) { hurtbox = hurtboxInfo.getHitboxRectangle(hurtbox, direction, v2Position, CurrentMoveAnimation.FrameWidth); } else { hurtbox = new Rectangle(); } // Calculate where our bounding box is. Calculating this every cycle hopefully doesn't add too much overhead // if (BoundingBoxHeight != null) { boundingBox.Height = boundingBoxHeight; boundingBox.Width = boundingBoxWidth; boundingBox.X = CenterX - boundingBoxWidth / 2; boundingBox.Y = (int)v2Position.Y + Height - boundingBoxHeight; } else { boundingBox = new Rectangle(); } // Check to see if there is a "followup" animation named for this animation // if (!String.IsNullOrEmpty(CurrentMoveAnimation.NextAnimation)) { // If there is, see if the currently playing animation has // completed a full animation loop // if (CurrentMoveAnimation.IsDone) { Console.WriteLine("SWITCHING TO " + CurrentMoveAnimation.NextAnimation); // If it has, set up the next animation CurrentAnimation = CurrentMoveAnimation.NextAnimation; } } } }
public Boolean isLastFrameOfAnimation() { return(CurrentMoveAnimation.isLastFrameOfAnimation()); }