コード例 #1
0
    private void LabelButtonWithCost()
    {
        Text costText = GetComponentInChildren <Text>();

        if (!costText)
        {
            Debug.LogError(name + " has no cost text, add some!");
        }
        else
        {
            costText.text = defenderPref.GetManaCost().ToString();
        }
    }
コード例 #2
0
    private void AttemptToSpawnDefender(Vector2 gridPos)
    {
        var manaDisplay  = FindObjectOfType <ManaDisplay>();
        int defenderCost = defender.GetManaCost();

        if (manaDisplay.HaveEnoughMana(defenderCost))
        {
            SpawnDefender(gridPos);
            manaDisplay.RemoveMana(defenderCost);
        }
        else
        {
            return;
        }
    }
コード例 #3
0
    private void AttemtToPlaceDefenderAt(Vector2 gridPos)
    {
        if (!defender)
        {
            return;
        }

        var manaDisplay  = FindObjectOfType <ManaDisplay>();
        int defenderCost = defender.GetManaCost();

        if (manaDisplay.HaveEnoughMana(defenderCost))
        {
            manaDisplay.SpendMana(defenderCost);
            SpawnDefender(gridPos);
        }
    }
コード例 #4
0
    private void AddCostText()
    {
        Text costText = GetComponentInChildren <Text>();

        costText.text = defenderPrefab.GetManaCost().ToString();
    }