Example #1
0
    private void AttemptToPlaceDefenderAt(Vector2 gridPosition)
    {
        var donutDisplay = FindObjectOfType <DonutDisplay>();
        int defenderCost = defender.GetDonutCost();

        if (donutDisplay.HaveEnoughDonuts(defenderCost) && PreventSpawnOverlap(gridPosition))
        {
            StartCoroutine(WaitAndSpawn(gridPosition));
            donutDisplay.SpendDonuts(defenderCost);
        }
    }
Example #2
0
    private void LabelButtonWithCost()
    {
        TextMeshProUGUI costText = GetComponentInChildren <TextMeshProUGUI>();

        if (!costText)
        {
            Debug.LogError(name + " has no cost text.");
        }
        else
        {
            costText.text = defenderPrefab.GetDonutCost().ToString();
        }
    }