コード例 #1
0
ファイル: AnimationSet.cs プロジェクト: pvmm/Pixel3D
        /// <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
ファイル: Animation.cs プロジェクト: rosebud667/Pixel3D
        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
ファイル: AnimationFrame.cs プロジェクト: zcxxv1213/Pixel3D
        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
ファイル: AnimationFrame.cs プロジェクト: zcxxv1213/Pixel3D
 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();
        }