Esempio n. 1
0
        /// <summary>
        /// Gets the specified tileset.
        /// </summary>
        /// <param name="name">The name of the tileset.</param>
        /// <returns>Returns the specified tileset if found; otherwise, <c>null</c>.</returns>
        public OgmoTileset GetTileset(string name)
        {
            OgmoTileset value = null;

            if (tilesets.TryGetValue(name, out value))
            {
                return(value);
            }
            return(null);
        }
Esempio n. 2
0
File: Tile.cs Progetto: endy/OgmoXNA
 public Tile(OgmoTile tile, bool useSourceIndex)
 {
     this.Tint = Color.White;
     this.Position = tile.Position;
     tileset = tile.Tileset;
     this.Texture = tileset.Texture;
     if (useSourceIndex)
         this.Source = tileset.Sources[tile.SourceIndex];
     else
         this.Source = new Rectangle(tile.TextureOffset.X,
             tile.TextureOffset.Y,
             tileset.TileWidth,
             tileset.TileHeight);
 }
Esempio n. 3
0
        internal OgmoProject(ContentReader reader)
        {
            // Name
            this.Name = reader.ReadString();
            // Settings
            this.Settings = new OgmoProjectSettings(reader);
            // Values
            int valueCount = reader.ReadInt32();

            if (valueCount > 0)
            {
                for (int i = 0; i < valueCount; i++)
                {
                    OgmoValueTemplate ogmoValue = OgmoValueTemplateReader.Read(reader);
                    if (ogmoValue != null)
                    {
                        values.Add(ogmoValue.Name, ogmoValue);
                    }
                }
            }
            // Tilesets
            int tilesetCount = reader.ReadInt32();

            if (tilesetCount > 0)
            {
                for (int i = 0; i < tilesetCount; i++)
                {
                    OgmoTileset tileset = new OgmoTileset(reader);
                    if (tileset != null)
                    {
                        tilesets.Add(tileset.Name, tileset);
                    }
                }
            }
            // Objects
            int objectCount = reader.ReadInt32();

            if (objectCount > 0)
            {
                for (int i = 0; i < objectCount; i++)
                {
                    OgmoObjectTemplate obj = new OgmoObjectTemplate(reader);
                    if (obj != null)
                    {
                        objects.Add(obj.Name, obj);
                    }
                }
            }
            // Layer Settings
            int layerSettingsCount = reader.ReadInt32();

            if (layerSettingsCount > 0)
            {
                for (int i = 0; i < layerSettingsCount; i++)
                {
                    OgmoLayerSettings layerSettings = OgmoLayerSettingsReader.Read(reader);
                    if (layerSettings != null)
                    {
                        this.layerSettings.Add(layerSettings.Name, layerSettings);
                    }
                }
            }
        }