public Frame(float duration, int spriteX, int spriteY, SpriteSheetAnimations parent, Dictionary <string, BoxCollision> colliders)
 {
     Duration      = duration;
     FrameLocation = new Rectangle(spriteX * (parent.Width + parent.Spacing) + parent.Margin,
                                   spriteY * (parent.Height + parent.Spacing) + parent.Margin,
                                   parent.Width, parent.Height);
     Colliders = colliders;
 }
        private void loadFromTileSet(Tileset tileset)
        {
            for (int i = 0; i < tileset.Count; i++)
            {
                SpriteSheetAnimations spriteSheetAnimation = new SpriteSheetAnimations();
                spriteSheetAnimation.Width   = tileset[i].Width;
                spriteSheetAnimation.Height  = tileset[i].Height;
                spriteSheetAnimation.Margin  = tileset[i].Margin;
                spriteSheetAnimation.Spacing = tileset[i].Spacing;

                AnimationTracker animationTracker = new AnimationTracker(spriteSheetAnimation);

                string name = tileset[i].Animation.Name;

                foreach (TilesetFrame frame in tileset[i].Animation.Frames)
                {
                    Dictionary <string, BoxCollision> colliders = new Dictionary <string, BoxCollision>();
                    foreach (KeyValuePair <string, List <BoxCol> > collider in tileset[frame.Id].BoxColliders)
                    {
                        BoxCollision collision = new BoxCollision();
                        collision.World = SceneManager.GetCurrentScene().World;
                        for (int j = 0; j < collider.Value.Count; j++)
                        {
                            BoxData box = new BoxData();
                            box.Position = new Vector(collider.Value[j].Rectangle.X / (float)tileset[frame.Id].Width,
                                                      collider.Value[j].Rectangle.Y / (float)tileset[frame.Id].Height);
                            box.Scale = new Vector(collider.Value[j].Rectangle.Width / (float)tileset[frame.Id].Width,
                                                   collider.Value[j].Rectangle.Height / (float)tileset[frame.Id].Height);
                            box.TriggerOnly = collider.Value[j].TriggerOnly;

                            IBox ibox = collision.World.Create(0, 0, box.Scale.X, box.Scale.Y).AddTags(box.Layer);
                            ibox.Data = box;
                            collision.World.Remove(ibox);

                            collision.Boxes.Add(ibox);
                        }
                        colliders.Add(collider.Key, collision);
                    }

                    animationTracker.AddFrame(frame.Duration, frame.Source.X, frame.Source.Y, colliders);
                }

                animationData[name] = animationTracker;
            }
        }
 public AnimationTracker(SpriteSheetAnimations parent)
 {
     this.Parent = parent;
     Frames      = new List <Frame>();
 }