Beispiel #1
0
        public Animation(BinaryReader reader)
        {
            int spriteSheetsCount = reader.ReadByte();

            SpriteSheets = new List <string>(spriteSheetsCount);
            while (spriteSheetsCount-- > 0)
            {
                SpriteSheets.Add(StringEncoding.GetString(reader));
            }

            var animationsCount = reader.ReadByte();

            Animations = new List <AnimationEntry>(animationsCount);
            while (animationsCount-- > 0)
            {
                Animations.Add(new AnimationEntry(reader));
            }

            var collisionBoxesCount = reader.ReadByte();

            Hitboxes = new List <HitboxEntry>(collisionBoxesCount);
            while (collisionBoxesCount-- > 0)
            {
                Hitboxes.Add(new HitboxEntry(reader));
            }
        }
Beispiel #2
0
        public void SaveChanges(BinaryWriter writer)
        {
            var spriteSheetsCount = (byte)Math.Min(SpriteSheets.Count, byte.MaxValue);

            writer.Write(spriteSheetsCount);
            for (int i = 0; i < spriteSheetsCount; i++)
            {
                var item = SpriteSheets[i];
                writer.Write(StringEncoding.GetBytes(item));
            }

            var animationsCount = (byte)Math.Min(Animations.Count, byte.MaxValue);

            writer.Write(animationsCount);
            for (int i = 0; i < animationsCount; i++)
            {
                Animations[i].SaveChanges(writer);
            }

            var collisionBoxesCount = (byte)Math.Min(Hitboxes.Count, byte.MaxValue);

            writer.Write(collisionBoxesCount);
            for (int i = 0; i < collisionBoxesCount; i++)
            {
                Hitboxes[i].SaveChanges(writer);
            }
        }
 public void Write(BinaryWriter writer)
 {
     writer.Write(StringEncoding.GetBytes(Name));
     writer.Write((byte)Frames.Count);
     writer.Write((byte)Speed);
     writer.Write((byte)Loop);
     writer.Write((byte)Flags);
     foreach (var entry in Frames)
     {
         entry.Write(writer);
     }
 }
        public void Read(BinaryReader reader)
        {
            Name = StringEncoding.GetString(reader);

            var framesCount = reader.ReadByte();

            Speed = reader.ReadByte();
            Loop  = reader.ReadByte();
            Flags = reader.ReadByte();
            for (int i = 0; i < framesCount; i++)
            {
                var frame = new Frame();
                frame.Read(reader);
                Frames.Add(frame);
            }
        }