Esempio n. 1
0
    public void SetHeight(int height)
    {
        // add more
        if (this.height < height)
        {
            for (int i = width * this.height; i < width * height; i++)
            {
                ColorRect rect = new ColorRect();
                rect.SetFrameColor(wallColour);

                rect.SetCustomMinimumSize(blockSize);
                container.AddChild(rect);

                map.Add(false);
            }
        }
        // remove more
        else
        {
            for (int i = width * height; i < width * this.height; i++)
            {
                container.GetChild(i).QueueFree();
            }
            map.RemoveRange(width * height, (this.height - height) * width);
        }

        this.height = height;
    }
Esempio n. 2
0
    public void SetWidth(int width)
    {
        container.Columns = width;

        // add more
        if (this.width < width)
        {
            for (int i = this.width * height; i < width * height; i++)
            {
                ColorRect rect = new ColorRect();
                rect.SetFrameColor(wallColour);

                rect.SetCustomMinimumSize(blockSize);
                container.AddChild(rect);

                map.Add(false);
            }
        }
        // remove more
        else
        {
            for (int i = width * height; i < this.width * height; i++)
            {
                container.GetChild(i).QueueFree();
            }
            map.RemoveRange(width * height, height * (this.width - width));
        }

        this.width = width;
    }
Esempio n. 3
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        width  = 79;
        height = 45;
        map    = new List <bool>();
        timer  = new Timer();
        AddChild(timer);
        AddUserSignal("finished");
        AddUserSignal("finished_generating");
        AddUserSignal("finished_pathfinding", new Godot.Collections.Array {
            this, new Godot.Collections.Array <int> (), new Godot.Collections.Array <int>()
        });

        container = GetNode("GridContainer") as GridContainer;
        container.SetColumns(width);

        for (int i = 0; i < width * height; i++)
        {
            ColorRect rect = new ColorRect();
            rect.SetFrameColor(wallColour);

            rect.SetCustomMinimumSize(blockSize);
            container.AddChild(rect);

            map.Add(false);
        }

        ResizeBlock();
    }