- visual update on riftraids - ability unlock system through ability tomes - (possible) bugfix sprite issue - player reputation level
85 lines
2.9 KiB
C#
85 lines
2.9 KiB
C#
using Kryz.CharacterStats.Examples;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class BuildLibrary : MonoBehaviour
|
|
{
|
|
#region Singleton
|
|
private static BuildLibrary _instance;
|
|
|
|
// Public reference to the singleton instance
|
|
public static BuildLibrary Instance
|
|
{
|
|
get
|
|
{
|
|
// If the instance doesn't exist, try to find it in the scene
|
|
if (_instance == null)
|
|
{
|
|
_instance = FindObjectOfType<BuildLibrary>();
|
|
|
|
// If it's still null, create a new GameObject and add the component
|
|
if (_instance == null)
|
|
{
|
|
GameObject singletonObject = new GameObject(typeof(BuildLibrary).Name);
|
|
_instance = singletonObject.AddComponent<BuildLibrary>();
|
|
}
|
|
}
|
|
return _instance;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
[SerializeField] private GameEvent_Int onAbilityTomePageLearned;
|
|
|
|
[SerializeField] private Item abilityTomePageTemplate;
|
|
|
|
public List<ClassBuildLibrary> classBuildLibraries = new List<ClassBuildLibrary>();
|
|
|
|
public List<AbilityTomePageInstance> abilityTomeInstances = new List<AbilityTomePageInstance>();
|
|
|
|
private List<AbilityTomePageInstance> stillLockedAbilityTomePages = new List<AbilityTomePageInstance>();
|
|
|
|
private void Start()
|
|
{
|
|
for (int i = 0; i < classBuildLibraries.Count; i++)
|
|
{
|
|
for (int j = 0; j < classBuildLibraries[i].possibleClassAbilities.Count; j++)
|
|
{
|
|
if(j == 0)
|
|
{
|
|
PlayerDataHandler.Instance.SaveAbilityTomeProgress(PlayerDataHandler.Instance.currentPlayerName.Value, AbilityIndexer.Instance.Abilities.IndexOf(classBuildLibraries[i].possibleClassAbilities[j]), 10);
|
|
}
|
|
abilityTomeInstances.Add(new AbilityTomePageInstance(classBuildLibraries[i].possibleClassAbilities[j], abilityTomePageTemplate, onAbilityTomePageLearned));
|
|
}
|
|
}
|
|
}
|
|
|
|
public AbilityTomePageInstance GetRandomLockedAbilityTomePageInstance()
|
|
{
|
|
for (int i = 0; i < abilityTomeInstances.Count; i++)
|
|
{
|
|
if(PlayerDataHandler.Instance.AbilityTomeUnlocked(PlayerDataHandler.Instance.currentPlayerName.Value, abilityTomeInstances[i].abilityIndex))
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
stillLockedAbilityTomePages.Add(abilityTomeInstances[i]);
|
|
}
|
|
}
|
|
|
|
return stillLockedAbilityTomePages[Random.Range(0, stillLockedAbilityTomePages.Count)];
|
|
}
|
|
|
|
public List<BaseAbility> GetBaseAbilities(GameTag characterClass)
|
|
{
|
|
for (int i = 0; i < classBuildLibraries.Count; i++)
|
|
{
|
|
if (classBuildLibraries[i].characterClass == characterClass)
|
|
return classBuildLibraries[i].possibleClassAbilities;
|
|
}
|
|
return null;
|
|
}
|
|
}
|