예제 #1
0
        public void AddTileset(string name, string texturePath, Point sourceSize, Point offset)
        {
            // Get the texture resource.
            int id = texturePath.GetHashCode();

            Texture2D texture = null;

            // Either load it from a file or just get a reference to it.
            if (TextureManager.ContainsResource(id))
            {
                // Get reference.
                texture = TextureManager.GetReference(id);
            }
            else
            {
                // Load from file and give it to resource manager.
                texture = LoadTextureFromFile(texturePath);

                TextureManager.AddResource(texturePath, texture);
            }

            // TODO: only adds textured tile sets.
            TexturedTileset tileset = new TexturedTileset(name, texture, sourceSize, offset);

            tilesets.AddTileset(tileset);

            // Add new brush bucket for this tileset.
            brushBuckets.Add(tileset, new BrushBucket(tileset));
        }