Exemple #1
0
 public void Clear()
 {
     selectedFrame = null;
     animations = null;
     selectedPart = -1;
     selectedAnimation = -1;
     textureOffset = Vector2.Zero;
     currentTexture = null;
 }
Exemple #2
0
 public Frame Clone()
 {
     List<Entity> fps = new List<Entity>();
     foreach (Entity e in parts)
     {
         fps.Add(e.Clone());
     }
     Frame f = new Frame(fps, name);
     return f;
 }
Exemple #3
0
 public void SelectFrame(Frame f)
 {
     selectedFrame = f;
     selectedPart = -1;
 }
Exemple #4
0
 /// <summary>
 /// Resets the game
 /// </summary>
 public void Reset()
 {
     selectedAnimation = -1;
     selectedPart = -1;
     selectedFrame = null;
 }
Exemple #5
0
 public KeyFrame NewKeyFrame(Animation ani, Frame frame)
 {
     KeyFrame kf = new KeyFrame(frame, 300, new string[]{"#add script"});
     ani.KeyFrames.Add(kf);
     return kf;
 }
Exemple #6
0
        public Frame NewFrame()
        {
            selectedPart = -1;
            //Clone if selected
            Frame f = new Frame();
            if (selectedFrame != null)
            {
                f = selectedFrame.Clone();
            }

            f.SetTexture(currentTexture);
            animations.allFrames.Add(f);
            return f;
        }
Exemple #7
0
        public static AnimationCollection Load(string path)
        {
            string name = "";
            List<Frame> allFrames = new List<Frame>();
            List<Animation> animations = new List<Animation>();
            string texture = "";

            using (StreamReader r = new StreamReader(path))
            {
                //Metadata separate by |
                string[] line = r.ReadLine().Split('|');
                name = line[0];
                texture = line[1];

                //1. Framecount
                int frameCount = int.Parse(r.ReadLine());

                //2. Frames
                for (int i = 0; i < frameCount; i++)
                {
                    string fName = r.ReadLine();
                    List<Entity> frameParts = new List<Entity>();
                    int fpCount = int.Parse(r.ReadLine());
                    for (int j = 0; j < fpCount; j++)
                    {
                        string[] xy = r.ReadLine().Split('|');
                        Vector2 pos = new Vector2(float.Parse(xy[0], CultureInfo.InvariantCulture), float.Parse(xy[1], CultureInfo.InvariantCulture));
                        float rotation = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture);
                        float scale = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture);
                        bool flipped = bool.Parse(r.ReadLine());
                        string[] rect = r.ReadLine().Split('|');
                        Rectangle source = new Rectangle(int.Parse(rect[0]), int.Parse(rect[1]), int.Parse(rect[2]), int.Parse(rect[3]));
                        Entity fp = new Entity()
                        {
                            position = pos,
                            rotation = rotation,
                            scale = scale,
                            flipped = flipped,
                            Source = source
                        };
                        frameParts.Add(fp);
                    }
                    Frame f = new Frame(frameParts, fName);
                    allFrames.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++)
                    {
                        int frameIdx = int.Parse(r.ReadLine());
                        float duration = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture);
                        int scriptCount = int.Parse(r.ReadLine());
                        string[] scripts = new string[scriptCount];
                        for (int x = 0; x < scriptCount; x++)
                        {
                            scripts[x] = r.ReadLine();
                        }
                        keyframes.Add(new KeyFrame(allFrames[frameIdx], duration, scripts));
                    }

                    animations.Add(new Animation(keyframes, animName));
                }
            }

            return new AnimationCollection(name, allFrames, animations, texture);
        }
Exemple #8
0
 public KeyFrame(Frame frameRef, float duration, string[] scripts)
 {
     this.frame = frameRef;
     this.duration = duration;
     this.scripts = scripts;
 }