コード例 #1
0
    public virtual void LevelUp()
    {
        if (!CheckIfItsAvailable())
        {
            return;
        }

        OutlineObject oo = GetCurrentTower().GetComponent <OutlineObject>();

        if (oo != null)
        {
            Color mix = (4 * oo.GetCurrentColor() + 1 * oo.GetGlowColor()) / 5;
            oo.SetCurrentColor(mix);
        }

        // Set childs callables
        foreach (Perk p in childs)
        {
            p.TurnCallable();
            p.GetButton().interactable = true;
        }

        // Upgrade perk
        level++;

        // Upgrade stats
        Text[] aux = gameObject.GetComponentsInChildren <Text>();

        foreach (Text t in aux)
        {
            if (t.gameObject.name == "Level")
            {
                t.text = "Level: " + level.ToString() + "/" + maxLevel.ToString();
            }
        }

        // Consume souls to level up
        soulsCounter.SetSouls(soulsCounter.GetSouls() - cost);

        // Add score
        scoreCounter.SetScore(scoreCounter.GetScore() + addScore);

        // Call a default function on skill gameObject to alter values
        Debug.Log(name + " level up to level " + level + " on tower " + GetCurrentTower().name);
    }