Ejemplo n.º 1
0
 private static void loadMainline(XmlNode mainline
                                  , com.discobeard.spriter.dom.Animation animation)
 {
     com.discobeard.spriter.dom.MainLine main = new com.discobeard.spriter.dom.MainLine
                                                    ();
     animation.setMainline(main);
     loadMainlineKeys(XmlReader.getChildrenByName(mainline, "key"), main);
 }
Ejemplo n.º 2
0
 /// <summary>Searches for the animation index with the given name and returns the right one
 ///     </summary>
 /// <param name="name">name of the animation.</param>
 /// <returns>index of the animation if the given name was found, otherwise it returns -1
 ///     </returns>
 public virtual int getAnimationIndexByName(string name)
 {
     com.discobeard.spriter.dom.Animation anim = this.getAnimationByName(name);
     if (this.getAnimationByName(name) == null)
     {
         return(-1);
     }
     else
     {
         return(anim.getId());
     }
 }
Ejemplo n.º 3
0
 private static void loadTimelines(List <XmlNode
                                         > timelines, com.discobeard.spriter.dom.Animation animation)
 {
     for (int i = 0; i < timelines.Count; i++)
     {
         com.discobeard.spriter.dom.TimeLine timeline = new com.discobeard.spriter.dom.TimeLine
                                                            ();
         timeline.setId(XmlReader.getInt(timelines[i], "id"));
         animation.getTimeline().Add(timeline);
         loadTimelineKeys(XmlReader.getChildrenByName(timelines[i], "key"), timeline);
     }
 }
Ejemplo n.º 4
0
 private static void loadAnimations(List <XmlNode
                                          > animations, com.discobeard.spriter.dom.Entity entity)
 {
     for (int i = 0; i < animations.Count; i++)
     {
         XmlNode a = animations[i];
         com.discobeard.spriter.dom.Animation animation = new com.discobeard.spriter.dom.Animation
                                                              ();
         animation.setId(XmlReader.getInt(a, "id"));
         animation.setName(XmlReader.getAttribute(a, "name"));
         animation.setLength(XmlReader.getInt(a, "length"));
         animation.setLooping(XmlReader.getBool(a, "looping"));
         entity.getAnimation().Add(animation);
         loadMainline(XmlReader.getChildByName(a, "mainline"), animation);
         loadTimelines(XmlReader.getChildrenByName(a, "timeline"), animation);
     }
 }
Ejemplo n.º 5
0
        private static void loadAnimations(List<XmlNode
			> animations, com.discobeard.spriter.dom.Entity entity)
        {
            for (int i = 0; i < animations.Count; i++)
            {
                XmlNode a = animations[i];
                com.discobeard.spriter.dom.Animation animation = new com.discobeard.spriter.dom.Animation
                    ();
                animation.setId(XmlReader.getInt(a,"id" ));
                animation.setName(XmlReader.getAttribute(a,"name" ));
                animation.setLength(XmlReader.getInt(a,"length" ));
                animation.setLooping(XmlReader.getBool(a,"looping"));
                entity.getAnimation().Add(animation);
                loadMainline(XmlReader.getChildByName(a,"mainline"), animation);
                loadTimelines(XmlReader.getChildrenByName(a,"timeline"), animation);
            }
        }
Ejemplo n.º 6
0
 //import com.brashmonkey.spriter.converters.SpriterObjectConverter;
 //import com.discobeard.spriter.dom.AnimationObject;
 //final private SpriterObjectConverter objectConverter = new SpriterObjectConverter();
 public virtual com.brashmonkey.spriter.animation.SpriterAnimation buildAnimation(
     com.discobeard.spriter.dom.Animation animation)
 {
     com.discobeard.spriter.dom.MainLine mainline = animation.getMainline();
     System.Collections.Generic.IList <com.discobeard.spriter.dom.TimeLine> timeLines =
         animation.getTimeline();
     System.Collections.Generic.IList <com.discobeard.spriter.dom.Key> keyFrames = mainline
                                                                                   .getKey();
     bonesToTween = new System.Collections.Generic.Dictionary <com.brashmonkey.spriter.objects.SpriterBone
                                                               , int>();
     objectsToTween = new System.Collections.Generic.Dictionary <com.brashmonkey.spriter.objects.SpriterObject
                                                                 , int>();
     com.brashmonkey.spriter.animation.SpriterAnimation spriterAnimation = new com.brashmonkey.spriter.animation.SpriterAnimation
                                                                               (animation.getId(), animation.getName(), animation.getLength());
     for (int k = 0; k < keyFrames.Count; k++)
     {
         com.discobeard.spriter.dom.Key mainlineKey = keyFrames[k];
         System.Collections.Generic.IList <com.brashmonkey.spriter.objects.SpriterObject> tempObjects
             = new System.Collections.Generic.List <com.brashmonkey.spriter.objects.SpriterObject
                                                    >();
         System.Collections.Generic.IList <com.brashmonkey.spriter.objects.SpriterBone> tempBones
             = new System.Collections.Generic.List <com.brashmonkey.spriter.objects.SpriterBone
                                                    >();
         com.brashmonkey.spriter.animation.SpriterKeyFrame frame = new com.brashmonkey.spriter.animation.SpriterKeyFrame
                                                                       ();
         frame.setTime(mainlineKey.getTime());
         frame.setId(mainlineKey.getId());
         foreach (com.discobeard.spriter.dom.BoneRef boneRef in mainlineKey.getBoneRef())
         {
             com.discobeard.spriter.dom.TimeLine         timeline    = timeLines[boneRef.getTimeline()];
             com.discobeard.spriter.dom.Key              timelineKey = timeline.getKey()[boneRef.getKey()];
             com.brashmonkey.spriter.objects.SpriterBone bone        = boneMerger.merge(boneRef, timelineKey
                                                                                        );
             bone.setName(timeline.getName());
             if (mainlineKey.getTime() != timelineKey.getTime())
             {
                 bonesToTween.Add(bone, k);
             }
             else
             {
                 tempBones.Add(bone);
             }
         }
         //}
         foreach (com.discobeard.spriter.dom.AnimationObjectRef objectRef in mainlineKey.getObjectRef
                      ())
         {
             com.discobeard.spriter.dom.TimeLine timeline    = timeLines[objectRef.getTimeline()];
             com.discobeard.spriter.dom.Key      timelineKey = timeline.getKey()[objectRef.getKey()
                                                               ];
             com.brashmonkey.spriter.objects.SpriterObject @object = objectMerger.merge(objectRef
                                                                                        , timelineKey);
             @object.setName(timeline.getName());
             if (mainlineKey.getTime() != timelineKey.getTime())
             {
                 objectsToTween.Add(@object, k);
             }
             else
             {
                 tempObjects.Add(@object);
             }
         }
         //}
         frame.setObjects(Sharpen.Collections.ToArray(tempObjects, new com.brashmonkey.spriter.objects.SpriterObject
                                                      [tempObjects.Count]));
         frame.setBones(Sharpen.Collections.ToArray(tempBones, new com.brashmonkey.spriter.objects.SpriterBone
                                                    [tempBones.Count]));
         spriterAnimation.frames.Add(frame);
     }
     this.tweenBones(spriterAnimation);
     this.tweenObjects(spriterAnimation);
     return(spriterAnimation);
 }