Example #1
0
    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
        }
    }
Example #2
0
    private void SetCostLabel()
    {
        TextMeshProUGUI costLabel = GetComponentInChildren <TextMeshProUGUI>();

        costLabel.text = defenderPrefab.GetEnergyCost().ToString();
    }