private void AttemptToPlaceDefender(Vector2 gridPos) { if (!selectedDefenderPrefab) { return; } var energyManager = FindObjectOfType <EnergyManager>(); int defenderCost = selectedDefenderPrefab.GetEnergyCost(); if (energyManager.SpendEnergy(defenderCost)) { SpawnDefender(gridPos); } else { // TODO Display "Not enough energy" message } }
private void SetCostLabel() { TextMeshProUGUI costLabel = GetComponentInChildren <TextMeshProUGUI>(); costLabel.text = defenderPrefab.GetEnergyCost().ToString(); }