public void AddAnimation(Animation.AnimationType animationName, int numFrames, float numSecondsPerFrame, bool isLooping) { Animation newAnimation = new Animation(numFrames, numSecondsPerFrame, isLooping); AnimationsList.Add(newAnimation); }
public void PlayAnimation(Animation.AnimationType animationToPlay) { // if character is dying, can't change to new animation; don't restart animation if currently playing if (currentAnimation != Animation.AnimationType.DYING && currentAnimation != animationToPlay) { // reset all animations to frame 0 prior to starting new animation foreach (Animation anim in AnimationsList) { anim.ResetAnimation(); } // trigger animation to play, by specifying enum AnimationType currentAnimation = animationToPlay; AnimationsList[(int)currentAnimation].PlayAnimation(); switch (currentAnimation) { case Animation.AnimationType.DYING: break; case Animation.AnimationType.RUNNING: soundEffect = Content.Load<SoundEffect>("kaboom2"); break; case Animation.AnimationType.CLIMBING: soundEffect = Content.Load<SoundEffect>("kaboom2"); break; case Animation.AnimationType.IDLING: soundEffect = Content.Load<SoundEffect>("kaboom2"); break; case Animation.AnimationType.PANTING: soundEffect = Content.Load<SoundEffect>("kaboom2"); break; case Animation.AnimationType.SHOOTING: soundEffect = Content.Load<SoundEffect>("gun_shoot_02"); break; case Animation.AnimationType.SPAWNING: break; default: break; } soundEffect.Play(); } }