示例#1
0
        void loadTilesetsFromFile()
        {
            tilesetList = new Dictionary <string, Tileset>();

            string  name;
            Vector2 origin;
            int     spriteWidth, tileWidth, tileHeight;
            Func <String[, ], Vector2, string> mapParse;

            ScriptState state = Scripting.parse(modulePath + "/areas/tilesets.txt");

            for (int i = 0; i < state.Variables.Count(); i++)
            {
                ScriptVariable v = state.Variables[i];

                name   = (string)Scripting.getScriptValue("name", v);
                origin = (Vector2)Scripting.getScriptValue("origin", v);

                spriteWidth = (int)Scripting.getScriptValue("spriteWidth", v);
                tileWidth   = (int)Scripting.getScriptValue("tileWidth", v);
                tileHeight  = (int)Scripting.getScriptValue("tileHeight", v);

                mapParse = (Func <String[, ], Vector2, string>)Scripting.getScriptValue("mapParse", v);

                tilesetList.Add(name, new Tileset(name, origin, spriteWidth,
                                                  tileWidth, tileHeight, mapParse));
            }
        }
示例#2
0
        void loadSongsFromFile()
        {
            songList = new Dictionary <string, Song>();

            ScriptState state = Scripting.parse("Content/music/songs.txt");

            ScriptVariable v = state.Variables[0];

            PropertyInfo[] p = v.Value.GetType().GetProperties();

            for (int i = 0; i < p.GetLength(0); i++)
            {
                string s = (string)Scripting.getScriptValue(p[i].Name, v);
                songList.Add(p[i].Name, Content.Load <Song>(s));
            }
        }