示例#1
0
        /// <summary>Create a default animation that is just a single Cel</summary>
        public void AddStaticDefaultAnimation(Cel cel)
        {
            Animation animation = new Animation(true);

            animation.Frames.Add(new AnimationFrame(cel, 1));
            AddAnimation(TagSet.Empty, animation);
        }
示例#2
0
        public static Animation CreateSingleSprite(Sprite sprite)
        {
            Animation animation = new Animation();
            Cel       cel       = new Cel(sprite);

            animation.Frames.Add(new AnimationFrame(cel, 1));
            return(animation);
        }
示例#3
0
        public AnimationFrame(AnimationDeserializeContext context)
        {
            delay         = context.br.ReadInt32();
            positionDelta = context.br.ReadPosition();
            shadowOffset  = context.br.ReadPosition();

            SnapToGround = context.br.ReadBoolean();

            int layersCount = context.br.ReadInt32();

            if (layersCount > 0)
            {
                Cel currentCel = null;
                this.firstLayer = currentCel = new Cel(context);
                for (int i = 1; i < layersCount; i++)
                {
                    currentCel.next = new Cel(context);
                    currentCel      = currentCel.next;
                }
            }

            masks = new TagLookup <Mask>(context, () => new Mask(context));

            outgoingAttachments = new TagLookup <OutgoingAttachment>(context, () => new OutgoingAttachment(context));
            incomingAttachments = new TagLookup <Position>(context, () => context.br.ReadPosition());

            int triggerCount = context.br.ReadInt32();

            if (triggerCount > 0)
            {
                triggers = new List <string>(triggerCount);
                for (int i = 0; i < triggerCount; i++)
                {
                    triggers.Add(context.br.ReadString());
                }
            }

            attachAtLayer = context.br.ReadInt32();
            canDrawLayersAboveSortedAttachees = context.br.ReadBoolean();

            cue = context.br.ReadNullableString();
        }
示例#4
0
 public AnimationFrame(Cel cel, int delay) : this()
 {
     this.layers.Add(cel);
     this.delay = delay;
 }
示例#5
0
        public AnimationFrame(AnimationDeserializeContext context)
        {
            delay         = context.br.ReadInt32();
            positionDelta = context.br.ReadPosition();
            shadowOffset  = context.br.ReadPosition();

            SnapToGround = context.br.ReadBoolean();

            int layersCount = context.br.ReadInt32();

            if (layersCount > 0)
            {
                Cel currentCel;
                firstLayer = currentCel = new Cel(context);
                for (var i = 1; i < layersCount; i++)
                {
                    currentCel.next = new Cel(context);
                    currentCel      = currentCel.next;
                }
            }

            if (context.Version >= 39)
            {
                masks = context.DeserializeOrderedDictionary(() => new Mask(context));
                outgoingAttachments = context.DeserializeOrderedDictionary(() => new OutgoingAttachment(context));
            }
            else
            {
                //
                // Masks:
                {
                    var legacy = context.DeserializeTagLookup(() => new Mask(context));
                    masks = new OrderedDictionary <string, Mask>();
                    foreach (var mask in legacy)
                    {
                        Debug.Assert(mask.Key.Count < 2, "we don't support multi-tags yet");
                        masks.Add(mask.Key.ToString(), mask.Value);
                    }
                }

                //
                // Outgoing Attachments:
                {
                    var legacy = context.DeserializeTagLookup(() => new OutgoingAttachment(context));
                    outgoingAttachments = new OrderedDictionary <string, OutgoingAttachment>();
                    foreach (var outgoingAttachment in legacy)
                    {
                        Debug.Assert(outgoingAttachment.Key.Count < 2, "we don't support multi-tags yet");
                        outgoingAttachments.Add(outgoingAttachment.Key.ToString(),
                                                outgoingAttachment.Value);
                    }
                }
            }

            incomingAttachments = context.DeserializeTagLookup(() => context.br.ReadPosition());

            int triggerCount = context.br.ReadInt32();

            if (triggerCount > 0)
            {
                triggers = new List <string>(triggerCount);
                for (var i = 0; i < triggerCount; i++)
                {
                    triggers.Add(context.br.ReadString());
                }
            }

            attachAtLayer = context.br.ReadInt32();
            canDrawLayersAboveSortedAttachees = context.br.ReadBoolean();

            cue = context.br.ReadNullableString();
        }