Hi,
I’m getting this weird issue. My damage progression progress by the Heallth levels, not the Damage levels.
Here is code for progression:
using System.Collections.Generic;
using UnityEngine;
namespace RPG.Stats
{
[CreateAssetMenu(fileName = "Progression", menuName = "Stats/New Progression", order = 0)]
public class Progression : ScriptableObject
{
[SerializeField] ProgressionCharacterClass[] characterClasses = null;
Dictionary<CharacterClass, Dictionary<Stat, float[]>> lookupTable = null;
public float GetStat(Stat stat, CharacterClass characterClass, int level)
{
BuildLookup();
float[] levels = lookupTable[characterClass][stat];
if (levels.Length < level) return 0;
return levels[level - 1];
}
public int GetLevels(Stat stat, CharacterClass characterClass)
{
BuildLookup();
float[] levels = lookupTable[characterClass][stat];
return levels.Length;
}
private void BuildLookup()
{
if (lookupTable != null) return;
lookupTable = new Dictionary<CharacterClass, Dictionary<Stat, float[]>>();
foreach (ProgressionCharacterClass progressionCharacterClass in characterClasses)
{
var statLookupTable = new Dictionary<Stat, float[]>();
foreach (ProgressionStat progressionStat in progressionCharacterClass.stats)
{
statLookupTable[progressionStat.stat] = progressionStat.levels;
}
lookupTable[progressionCharacterClass.characterClass] = statLookupTable;
}
}
[System.Serializable]
class ProgressionCharacterClass
{
[SerializeField] public CharacterClass characterClass;
public ProgressionStat[] stats;
}
[System.Serializable]
class ProgressionStat
{
public Stat stat;
public float[] levels;
}
}
}
And code for Hit() in Fighter.cs
void Hit()
{
if (target == null) return;
float damage = GetComponent<BaseStats>().GetStat(Stat.Damage);
if (currentWeapon.HasProjectile())
{
currentWeapon.LaunchProjectile(
rightHandTransform,
leftHandTransform,
target.GetComponent<Health>(),
gameObject,
damage);
}
else
{
target.GetComponent<Health>().TakeDamage(gameObject, damage);
}
}
I’ve tried to create new Progression SO and assigning it to base character prefab. Didn’t work.