/// <summary> /// Add an animation data to the list of avalaible ADs. /// </summary> /// <param name="name">The unique name that identifies this data.</param> /// <param name="data">The data that is linked to that name.</param> public void AddAnimationData(string name, ComplexAnimData data) { // Check to see if identifier already exists. ComplexAnimData value; if (_animationData.TryGetValue(name, out value)) { throw new Exception("Identifier for this animation data already exists."); } _animationData.Add(name, data); }
/// <summary> /// Change the current animation to the specified animation. /// </summary> /// <param name="name">The unique identifier of the animation.</param> private void ChangeAnimation(string name) { ComplexAnimData animData; if (!_animationData.TryGetValue(name, out animData)) { throw new Exception("Animation not found."); } if (name == _currentName) return; // Reset animation and change current animation being used. _currentFrame = 0; _frameTimer.Reset(); _currentAnimationData = animData; _currentName = name; // Switch to the new texture and size. _texture = _currentAnimationData.Texture; _sourceRectangle.Width = _currentAnimationData.Width; _sourceRectangle.Height = _currentAnimationData.Height; _sourceRectangle.Y = _currentAnimationData.StartingY; if (AnimationStateChanged != null) AnimationStateChanged(); }