// Called when the inventory enters the scene tree for the first time. public override void _Ready() { cellGuiScene = GD.Load <PackedScene>("res://scenes/CellGui.tscn"); for (int i = 0; i < this.NumCells; i++) { CellGui cell = (CellGui)cellGuiScene.Instance(); this.AddChild(cell); cell.SetPosition(new Vector2(64 * i, 0)); cell.Connect("CellClicked", this, "OnCellClicked"); this.cells.Add(cell); } this.SetSize(new Vector2(64 * NumCells, 64)); }
private void OnCellClicked(CellGui cellClicked) { Player.EquipGun(cellClicked.gun); }
void OnCellClicked(CellGui cell) { // Emit Inventory's signal. this.EmitSignal("CellClicked", cell); }