private void OnItemUpdated(int idx) { ClearCell(idx); var cell = _gridContainer.GetChild <InventoryCell>(idx); var item = PlayerInventory.Items[idx]; cell.SetInventoryItem(item); }
public void HighlightCell(int cellIndex) { ClearCellHighlights(); var outlineShader = ResourceLoader.Load <ShaderMaterial>("res://Shaders/Outline2d_outer.tres"); var cell = cellIndex == -1 ? _weaponCell : _gridContainer.GetChild <ItemCell>(cellIndex); cell.Material = outlineShader; }
public void HighlightCell(int cellIndex) { ClearCellHighlights(); var outlineShader = ResourceLoader.Load <ShaderMaterial>("res://Shaders/Outline2d_outer.tres"); var cell = _gridContainer.GetChild <TextureRect>(cellIndex); cell.Material = outlineShader; }
private void UpdateChestUI() { if (_chestInstance == null) { GD.PushError("Chest instance not found"); return; } for (var i = 0; i < _chestInstance.contents.Count; i++) { var itemName = _chestInstance.contents[i]; _chestContents.GetChild <ChestItems>(i).ItemName = itemName; } }
private async void UpdateInventoryUI() { if (_chestInstance == null) { GD.PushError("Chest instance not found"); return; } var movableInventory = new List <string>(_playerInstance.Inventory); movableInventory.Remove(_playerInstance.EquippedWeapon); movableInventory.Remove(_playerInstance.EquippedArmor); foreach (Node child in _inventoryContents.GetChildren()) { child.QueueFree(); } var childCount = _inventoryContents.GetChildCount(); if (childCount > 0) { await ToSignal(_inventoryContents.GetChild(childCount - 1), "tree_exited"); } foreach (var itemName in movableInventory) { var inventoryItem = (ChestItems)ChestItemResource.Instance(); inventoryItem.ItemName = itemName; _inventoryContents.AddChild(inventoryItem); } for (var i = 0; i < 8; i++) { var inventoryItem = (ChestItems)ChestItemResource.Instance(); _inventoryContents.AddChild(inventoryItem); } foreach (ChestItems inventoryItems in _inventoryContents.GetChildren()) { inventoryItems.Connect(nameof(ChestItems.LeftClicked), this, nameof(OnInventoryItem_LeftClicked)); } }
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; }