Esempio n. 1
0
File: Crack.cs Progetto: Arce11/Dome
    public override void _Ready()
    {
        resourceList = new List <string>();
        sprites      = new List <Sprite>();
        Random random        = new Random();
        int    resourceCount = random.Next(1, 3);

        _resourcesPanel = GetNode <Node2D>("ResourcesNeeded");

        for (int i = 0; i < resourceCount; i++)
        {
            sprites.Add(new Sprite());
            resourceList.Add(AssetFinder.getRandomResourceName());
            sprites[i].Texture = ResourceLoader.Load <Texture>(AssetFinder.GetPathByResourceName(resourceList[i]));
            sprites[i].Scale   = new Vector2(0.7f, 0.7f);
            _resourcesPanel.AddChild(sprites[i]);
            sprites[i].Position = new Vector2(iconMargin + (iconSize + iconMargin) * i, iconMargin);
        }

        (GetNode <Area2D>("Area2D") as RepareInfo).crack = this; //pasarle la info a el objeto que colisiona para que la comparta
        //en el evento
    }