- Home /
Question by
patrickdib007 · Mar 01, 2020 at 08:47 PM ·
stats
Character stats by level
Hi i'm doing an RPG game (following tutorials) and i want to get different stats at different levels. I don't know if i should use a "Foreach" or something else. In the tutorials they do it differently so i can't follow them. Example: I want to fetch maxHealth from different levels.
Thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "NewStat", menuName = "Character/Stats", order = 1)]
public class CharacterStats_SO : ScriptableObject
{
[SerializeField] CharacterClass characterClass;
[Range(1, 50)]
public int charLevel = 1;
[System.Serializable]
public class CharLevelUps
{
public int maxHealth;
public int baseAttack;
public int baseDefense;
public float baseCriticalAttack;
public float baseCriticalDefense;
public float baseDodge;
public float basePowerUp;
}
region
public int maxHealth = 0;
public int currentHealth = 0;
public int baseAttack = 0;
public int currentAttack = 0;
public int baseDefense = 0;
public int currentDefense = 0;
public float baseCriticalAttack = 0f;
public float currentCriticalAttack = 0f;
public float baseCriticalDefense = 0f;
public float currentCriticalDefense = 0f;
public float baseDodge = 0f;
public float currentDodge = 0f;
public float basePowerUp = 0f;
public float currentPowerUp = 0f;
public int charExperience = 0;
public CharLevelUps[] charLevelUps;
#endregion
public void LevelUp()
{
charLevel += 1;
//Display level up animation
maxHealth = charLevelUps[charLevel - 1].maxHealth;
baseAttack = charLevelUps[charLevel - 1].baseAttack;
baseDefense = charLevelUps[charLevel - 1].baseDefense;
baseCriticalAttack = charLevelUps[charLevel - 1].baseCriticalAttack;
baseCriticalDefense = charLevelUps[charLevel - 1].baseCriticalDefense;
baseDodge = charLevelUps[charLevel - 1].baseDodge;
basePowerUp = charLevelUps[charLevel - 1].basePowerUp;
}
#endregion
#region Get Stats By Level
#endregion
Comment