コード例 #1
0
ファイル: Stats.cs プロジェクト: 1017280/GAD170_Brief1
    /// <summary>
    /// A function used to handle actions associated with levelling up.
    /// </summary>
    private void LevelUp()
    {
        // Increase the player level, subtract the threshold value from xp and
        // increase the threshold for the next level
        level++;
        currentXp  -= xpThreshold;
        xpThreshold = Mathf.RoundToInt((xpThreshold * (1 + xpThresholdIncreaseRate)));

        Debug.Log(gameObject.name + " Leveled up to " + level + ", new threshhold: " + xpThreshold + ", currentXp: " + currentXp);

        if (GetComponent <Player>())
        {
            // plays the level up sound effect.
            sfxHandler.LevelUp();
            // emits a particle effect to show we have levelled up
            particleHandler.Emit();
            // Displays a UI Message to the player we have levelled up
            uIManager.ShowLevelUI();
        }

        AssignSkillPointsOnLevelUp(3);
    }