//========================================================================================= /// <summary> /// Makes a copy of the given animation as the basis for this animation. Use to avoid /// re-loading animation data from the disk. /// </summary> /// <param name="file"> Name of the xml file containing the animations for the object </param> //========================================================================================= public Animation( Animation animation ) { // Only do if the other animation is not null: if ( animation != null ) { // Copy bounding box and ellipse dimensions: m_animation_bounding_box = animation.m_animation_bounding_box; m_animation_bounding_ellipse = animation.m_animation_bounding_ellipse; // See if it has any parts: if ( animation.m_parts != null ) { // Run through all the parts in the other animation and copy: Dictionary<string,AnimationPart>.Enumerator e = animation.m_parts.GetEnumerator(); // Run through all parts: while ( e.MoveNext() ) { // Copy this part: m_parts[e.Current.Key] = new AnimationPart( e.Current.Value ); } } } }
//========================================================================================= /// <summary> /// Each character should implement this function and load it's own animation in this function. /// </summary> //========================================================================================= public override void LoadAnimation() { // Load the animation for the player ninja: Animation = new Animation( "Content\\Animations\\Ninja.xml" ); }
//========================================================================================= /// <summary> /// Each character should implement this function and load it's own animation in this function. /// </summary> //========================================================================================= public override void LoadAnimation() { // See if we pre-cahced our animations or not: if ( s_cached_animations == null ) { // No animation cache: load one of the four enemy ninja animations: switch ( Core.Random.Next() & 3 ) { case 0: Animation = new Animation( "Content\\Animations\\EnemyNinjaColor1.xml" ); break; case 1: Animation = new Animation( "Content\\Animations\\EnemyNinjaColor2.xml" ); break; case 2: Animation = new Animation( "Content\\Animations\\EnemyNinjaColor3.xml" ); break; default: Animation = new Animation( "Content\\Animations\\EnemyNinjaColor4.xml" ); break; } } else { // Got a cache: make our animation from one of the cached items switch ( Core.Random.Next() & 3 ) { case 0: Animation = new Animation( s_cached_animations[0] ); break; case 1: Animation = new Animation( s_cached_animations[1] ); break; case 2: Animation = new Animation( s_cached_animations[2] ); break; default: Animation = new Animation( s_cached_animations[3] ); break; } } }