Beispiel #1
0
 public KeyFrame(Frame frameRef, float duration, KeyFrameScript[] scripts)
 {
     this.frameRef = frameRef;
     this.duration = duration;
     this.scripts = scripts;
     editorScripts = new string[0];
 }
Beispiel #2
0
 public KeyFrame(Frame frameRef, float duration, string[] editorscripts, KeyFrameScript[] scripts)
 {
     this.frameRef = frameRef;
     this.duration = duration;
     this.editorScripts = editorscripts;
     this.scripts = scripts;
 }
Beispiel #3
0
 public void DrawLerped(SpriteBatch sb, Vector2 position, Frame nextFrame, float process, bool flipped)
 {
     for (int i = 0; i < parts.Count; i++)
     {
         parts[i].DrawLerped(sb, texture, position, nextFrame.parts[i], process, flipped);
     }
 }
Beispiel #4
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;
            }
        }
Beispiel #5
0
 public void SetFrame(Frame frame)
 {
     this.frame = frame;
     if (frame != null)
     {
         selectedPart = frame.parts.Count - 1;
     }
     else
     {
         selectedPart = -1;
     }
 }
Beispiel #6
0
 void frameList_OnDoubleClickedEvent(Frame item)
 {
     textBox.Show(item);
 }
Beispiel #7
0
 void frameList_OnClickedEvent(Frame item)
 {
     frameContainer.SetFrame(item);
 }
Beispiel #8
0
 void btnNewFrame_OnClickedEvent()
 {
     Frame f = new Frame(texContainer.texture, new List<FramePart>() { new FramePart(Vector2.Zero, 0f, 1f) }) { Name = "f" };
     if (frameList.selected != -1)
     {
         f = frameList.items[frameList.selected].Clone();
     }
     frameList.AddNew(f);
     frameContainer.SetFrame(f);
 }