Пример #1
0
    public override void _Ready()
    {
        var path = "res://art";

        dir.Open(path);
        dir.ListDirBegin();
        var fileName = dir.GetNext();

        while (fileName != "")
        {
            if ((fileName.Contains("board")) && (!fileName.Contains(".import")))
            {
                tabuleiro.Add((Texture)ResourceLoader.Load("res://art/" + fileName));
                GD.Print("lol = " + fileName);
            }
            if ((fileName.Contains("circulo")) && (!fileName.Contains(".import")))
            {
                circulo.Add((Texture)ResourceLoader.Load("res://art/" + fileName));
                GD.Print("bol = " + fileName);
            }
            if ((fileName.Contains("xis")) && (!fileName.Contains(".import")))
            {
                xis.Add((Texture)ResourceLoader.Load("res://art/" + fileName));
                GD.Print("gez = " + fileName);
            }
            fileName = dir.GetNext();
        }
        dir.ListDirEnd();
    }
Пример #2
0
        /// <summary>
        /// Enumerate through all objects in a directory.
        /// </summary>
        public static IEnumerable <string> EnumerateDirectory(string rootpath)
        {
            List <string> ret = new List <string>();
            var           dir = new Godot.Directory();

            dir.Open(rootpath);
            dir.ListDirBegin();
            for (string path = dir.GetNext(); !string.IsNullOrEmpty(path); path = dir.GetNext())
            {
                if (path[0] != '.')
                {
                    ret.Add(dir.GetCurrentDir() + "/" + path);
                }
            }
            dir.ListDirEnd();
            return(ret);
        }
Пример #3
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        _items = new Godot.Collections.Array <ItemResource>();
        Godot.Directory directory = new Godot.Directory();
        directory.Open("res://items");
        directory.ListDirBegin();

        String fileName = directory.GetNext();

        while (fileName != null && fileName.Length != 0)
        {
            if (!directory.CurrentIsDir() && fileName.Contains(".tres") && !fileName.Contains("ItemResource.tres") && !fileName.Contains("Pickup"))
            {
                ItemResource itemResource = ((ItemResource)GD.Load("res://items/" + fileName));

                _items.Add(itemResource);
            }
            fileName = directory.GetNext();
        }
        directory.ListDirEnd();
    }