Пример #1
0
        public static AnimationCollection Load(string path)
        {
            List<Frame> frames = new List<Frame>();
            List<Animation> animations = new List<Animation>();

            using(StreamReader r = new StreamReader(path))
            {
                // frames
                int frameCount = int.Parse(r.ReadLine());
                for (int i = 0; i < frameCount; i++)
                {
                    string fName = r.ReadLine();
                    List<FramePart> fps = new List<FramePart>();
                    int fpCount = int.Parse(r.ReadLine());
                    for (int j = 0; j < fpCount; j++)
                    {
                        string[] pos = r.ReadLine().Split(',');
                        Vector2 position = new Vector2(float.Parse(pos[0], CultureInfo.InvariantCulture), float.Parse(pos[1], CultureInfo.InvariantCulture));
                        string[] src = r.ReadLine().Split(',');
                        Rectangle source = new Rectangle(int.Parse(src[0]), int.Parse(src[1]), int.Parse(src[2]),int.Parse(src[3]));
                        float rotation = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture);
                        float scale = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture);
                        fps.Add(new FramePart(position, rotation, scale) { Source = source });
                    }

                    Frame f = new Frame(null, fps) { Name = fName };
                    frames.Add(f);
                }

                int animCount = int.Parse(r.ReadLine());
                for (int i = 0; i < animCount; i++)
                {
                    string animName = r.ReadLine();
                    List<KeyFrame> keyFrames = new List<KeyFrame>();
                    int kfCount = int.Parse(r.ReadLine());
                    for (int j = 0; j < kfCount; j++)
                    {
                        float duration = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture);
                        int fIndex = int.Parse(r.ReadLine());
                        string[] scripts = new string[int.Parse(r.ReadLine())];
                        for (int x = 0; x < scripts.Length; x++)
                        {
                            scripts[x] = r.ReadLine();
                        }
                        List<KeyFrameScript> s = new List<KeyFrameScript>();
                        KeyFrame kf = new KeyFrame(frames[fIndex], duration, scripts);
                        keyFrames.Add(kf);
                    }

                    Animation a = new Animation(keyFrames) { Name = animName };
                    animations.Add(a);
                }

                AnimationCollection collection = new AnimationCollection(frames, animations);
                return collection;
            }
        }
Пример #2
0
 public void SetAnimation(Animation anim)
 {
     this.anim = anim;
 }
Пример #3
0
 void btnNewAnimClicked()
 {
     Animation ani = new Animation(new List<NibLib.Frames.KeyFrame>()) { Name = "a" };
     animList.AddNew(ani);
     AnimChanged(ani);
 }
Пример #4
0
 void animList_OnDoubleClickedEvent(Animation item)
 {
     textBox.Show(item);
 }
Пример #5
0
 void animList_OnClickedEvent(Animation item)
 {
     animCompo.SetAnimation(item);
     AnimChanged(item);
 }
Пример #6
0
 void AnimChanged(Animation ani)
 {
     if (ani == null)
     {
         kfList.items = new List<KeyFrame>();
     }
     else
     {
         kfList.items = ani.Keyframes;
     }
 }