示例#1
0
        /// <summary>
        /// Saves the entity, embedding it into a file stream.
        /// </summary>
        /// <param name="binwrite">The System.IO.BinaryWriter to use.</param>
        public void Save(BinaryWriter binwrite)
        {
            // Header Data //
            binwrite.Write(X);
            binwrite.Write(Y);
            binwrite.Write(Layer);
            binwrite.Write((short)Type);
            binwrite.Write(new byte[8]);

            // Type Data //
            if (Type == EntityType.Person)
            {
                binwrite.Write((short)Name.Length);
                binwrite.Write(Name.ToCharArray());
                binwrite.Write((short)Spriteset.Length);
                binwrite.Write(Spriteset.ToCharArray());

                binwrite.Write((short)Scripts.Count);
                foreach (string s in Scripts)
                {
                    binwrite.Write((short)s.Length);
                    binwrite.Write(s.ToCharArray());
                }
                binwrite.Write(new byte[16]);
            }
            else
            {
                binwrite.Write((short)Function.Length);
                binwrite.Write(Function.ToCharArray());
            }
        }
示例#2
0
 /// <summary>
 /// Gets a list of sprite directions fgor this person object:
 /// </summary>
 /// <param name="rootpath">The root path to find the spriteset with.</param>
 /// <returns>A list of spriteset directions.</returns>
 public string[] GetSpriteDirections(string rootpath)
 {
     using (Spriteset s = new Spriteset())
     {
         if (s.Load(rootpath + "/spritesets/" + Spriteset))
         {
             return(s.GetDirections());
         }
     }
     return(null);
 }
示例#3
0
        /// <summary>
        /// Takes the images of a spriteset and creates a ileset representation of it.
        /// </summary>
        /// <param name="set">The spriteset to use.</param>
        /// <returns>A tileset of the spritesets images.</returns>
        public static Tileset FromSpriteset(Spriteset set)
        {
            Tileset tileset = new Tileset();

            foreach (Bitmap image in set.Images)
            {
                tileset.Tiles.Add(new Tile(image));
            }

            tileset.TileWidth  = set.SpriteWidth;
            tileset.TileHeight = set.SpriteHeight;

            return(tileset);
        }
示例#4
0
 /// <summary>
 /// Get an image representation of this trigger / person
 /// </summary>
 /// <param name="rootpath">The root path of the project to find the spriteset.</param>
 /// <returns>A System.Draw.Bitmap representing the entity.</returns>
 public Image GetSSImage(string rootpath)
 {
     if (Type == EntityType.Trigger)
     {
         return(Resources.TriggerIcon);
     }
     using (var s = new Spriteset())
     {
         if (s.Load(rootpath + "/spritesets/" + Spriteset))
         {
             Image img = s.GetImage("south");
             if (img == null && s.Images.Count > 0)
             {
                 img = s.Images[0];
             }
             if (img != null)
             {
                 return(s.Images.Count == 0 ? Resources.PersonIcon : new Bitmap(img));
             }
         }
         return(Resources.PersonIcon);
     }
 }