RiftMayhem/Assets/Scripts/Game/ClassUnlockProgressionHandler.cs
Pedro Gomes 614f4d92c5 Improvements on some aspects
- Bonus 5% xp per rep level
- Relative power level values and respective ranks (E-S+)
- small bugfix on ability/class unlock info message
- added less bright light when class is unlocked on character creation screen
- Removed base slashes of other classes from the human possible builds
- New human class specific autocast ability "Sword Art"
- New knight ability "shining light"
2025-01-20 18:49:07 +00:00

95 lines
3.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class ClassUnlockProgressionHandler : MonoBehaviour
{
[SerializeField] private GameEventListener_Int onAbilityUnlocked;
[SerializeField] private GameEventListener_Int onAbilityTomeLearned;
[SerializeField] private TMP_Text unlockAbilityTextWarning;
[SerializeField] private TMP_Text unlockClassTextWarning;
BaseAbility unlockedAbility;
GameTag classTag;
private const string abilityPageLearnedText = " Pages learned: ";
private const string abilityUnlockedText = "New ability learned: ";
private const string classUnlockedText = "New Class Unlocked: ";
float pageEndTime;
float classEndTime;
private void Awake()
{
onAbilityUnlocked.Response.AddListener(CheckForUnlockedClass);
onAbilityTomeLearned.Response.AddListener(HandleInfo);
unlockAbilityTextWarning.gameObject.SetActive(false);
unlockClassTextWarning.gameObject.SetActive(false);
}
int count;
private void HandleInfo(int abilityIndex)
{
count = PlayerDataHandler.Instance.LoadAbilityTomeProgress(PlayerDataHandler.Instance.currentPlayerName.Value, abilityIndex);
pageEndTime = Time.time + GameConstants.GameBalancing.PermaDeathInfoTime;
StartCoroutine(DelayedPageInfo(AbilityIndexer.Instance.Abilities[abilityIndex].displayName, count.ToString(), GameConstants.GameBalancing.TotalPagesPerAbilityTome.ToString()));
}
private void CheckForUnlockedClass(int abilityIndex)
{
unlockedAbility = AbilityIndexer.Instance.Abilities[abilityIndex];
pageEndTime = Time.time + GameConstants.GameBalancing.PermaDeathInfoTime;
StartCoroutine(DelayedUnlockInfo(unlockedAbility.displayName));
classTag = BuildLibrary.Instance.GetClassBasedOnAbility(unlockedAbility);
if (classTag == null) return;
if (!PlayerDataHandler.Instance.ClassUnlocked(PlayerDataHandler.Instance.currentPlayerName.Value, classTag.name.ToLower()))
{
classEndTime = Time.time + GameConstants.GameBalancing.PermaDeathInfoTime;
StartCoroutine(DelayedClassUnlockInfo(classTag.name.ToUpper()));
}
PlayerDataHandler.Instance.SaveClassUnlockedProgress(PlayerDataHandler.Instance.currentPlayerName.Value, classTag.name.ToLower());
}
IEnumerator DelayedPageInfo(string abilityName, string count, string total)
{
unlockAbilityTextWarning.text = abilityName + abilityPageLearnedText + count + "/" + total;
unlockAbilityTextWarning.gameObject.SetActive(true);
while (Time.time < pageEndTime)
yield return null;
unlockAbilityTextWarning.gameObject.SetActive(false);
}
IEnumerator DelayedUnlockInfo(string abilityName)
{
unlockAbilityTextWarning.text = abilityUnlockedText + abilityName;
unlockAbilityTextWarning.gameObject.SetActive(true);
while (Time.time < pageEndTime)
yield return null;
unlockAbilityTextWarning.gameObject.SetActive(false);
}
IEnumerator DelayedClassUnlockInfo(string classname)
{
unlockClassTextWarning.text = classUnlockedText + classname;
unlockClassTextWarning.gameObject.SetActive(true);
while (Time.time < classEndTime)
yield return null;
unlockClassTextWarning.gameObject.SetActive(false);
}
}