Character Stats Revamp (WIP)
- created secondary stats - added characterStatsBalancing constants
This commit is contained in:
parent
aff066813c
commit
4a7430533a
@ -120,3 +120,5 @@ namespace Kryz.CharacterStats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,12 +7,23 @@ namespace Kryz.CharacterStats.Examples
|
|||||||
{
|
{
|
||||||
public class CharacterStats : MonoBehaviour
|
public class CharacterStats : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
//Primary
|
||||||
public CharacterStat Strength;
|
public CharacterStat Strength;
|
||||||
public CharacterStat Agility;
|
public CharacterStat Agility;
|
||||||
public CharacterStat Intelligence;
|
public CharacterStat Intelligence;
|
||||||
public CharacterStat Spirit;
|
public CharacterStat Spirit;
|
||||||
public CharacterStat Vitality;
|
public CharacterStat Vitality;
|
||||||
|
|
||||||
|
//Secondary
|
||||||
|
public CharacterStat CritChance;
|
||||||
|
public CharacterStat CritDamage;
|
||||||
|
public CharacterStat AttackDamage;
|
||||||
|
public CharacterStat SpellDamage;
|
||||||
|
public CharacterStat MaxHealth;
|
||||||
|
public CharacterStat Armor;
|
||||||
|
public CharacterStat MagicResistance;
|
||||||
|
|
||||||
|
|
||||||
public Dictionary<string, CharacterStat> statsDictionary = new Dictionary<string, CharacterStat>();
|
public Dictionary<string, CharacterStat> statsDictionary = new Dictionary<string, CharacterStat>();
|
||||||
|
|
||||||
public UnityEvent onUpdateStatValues = new UnityEvent();
|
public UnityEvent onUpdateStatValues = new UnityEvent();
|
||||||
@ -24,6 +35,19 @@ namespace Kryz.CharacterStats.Examples
|
|||||||
statsDictionary.Add(nameof(Intelligence).ToLower(), Intelligence);
|
statsDictionary.Add(nameof(Intelligence).ToLower(), Intelligence);
|
||||||
statsDictionary.Add(nameof(Spirit).ToLower(), Spirit);
|
statsDictionary.Add(nameof(Spirit).ToLower(), Spirit);
|
||||||
statsDictionary.Add(nameof(Vitality).ToLower(), Vitality);
|
statsDictionary.Add(nameof(Vitality).ToLower(), Vitality);
|
||||||
|
|
||||||
|
|
||||||
|
statsDictionary.Add(nameof(CritChance).ToLower(), CritChance);
|
||||||
|
statsDictionary.Add(nameof(CritDamage).ToLower(), CritDamage);
|
||||||
|
|
||||||
|
statsDictionary.Add(nameof(AttackDamage).ToLower(), AttackDamage);
|
||||||
|
statsDictionary.Add(nameof(SpellDamage).ToLower(), SpellDamage);
|
||||||
|
|
||||||
|
statsDictionary.Add(nameof(MaxHealth).ToLower(), MaxHealth);
|
||||||
|
statsDictionary.Add(nameof(Armor).ToLower(), Armor);
|
||||||
|
statsDictionary.Add(nameof(MagicResistance).ToLower(), MagicResistance);
|
||||||
|
|
||||||
|
onUpdateStatValues.AddListener(UpdateSecondaryStatsBasedOnPrimaryStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncreaseAllStatPoints(int amount)
|
public void IncreaseAllStatPoints(int amount)
|
||||||
@ -36,5 +60,23 @@ namespace Kryz.CharacterStats.Examples
|
|||||||
|
|
||||||
onUpdateStatValues.Invoke();
|
onUpdateStatValues.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateSecondaryStatsBasedOnPrimaryStats()
|
||||||
|
{
|
||||||
|
AttackDamage.RemoveAllModifiersFromSource(GameConstants.ObjectSources.StrengthSource);
|
||||||
|
|
||||||
|
Strength.RemoveAllModifiersFromSource(GameConstants.ObjectSources.LevelSource);
|
||||||
|
Agility.RemoveAllModifiersFromSource(GameConstants.ObjectSources.LevelSource);
|
||||||
|
Intelligence.RemoveAllModifiersFromSource(GameConstants.ObjectSources.LevelSource);
|
||||||
|
Spirit.RemoveAllModifiersFromSource(GameConstants.ObjectSources.LevelSource);
|
||||||
|
Vitality.RemoveAllModifiersFromSource(GameConstants.ObjectSources.LevelSource);
|
||||||
|
|
||||||
|
//Strength.AddModifier(new StatModifier((level.currentLevel - 1), StatModType.Flat, GameConstants.ObjectSources.LevelSource));
|
||||||
|
//Agility.AddModifier(new StatModifier((level.currentLevel - 1), StatModType.Flat, GameConstants.ObjectSources.LevelSource));
|
||||||
|
//Intelligence.AddModifier(new StatModifier((level.currentLevel - 1), StatModType.Flat, GameConstants.ObjectSources.LevelSource));
|
||||||
|
//Spirit.AddModifier(new StatModifier((level.currentLevel - 1), StatModType.Flat, GameConstants.ObjectSources.LevelSource));
|
||||||
|
//Vitality.AddModifier(new StatModifier((level.currentLevel - 1), StatModType.Flat, GameConstants.ObjectSources.LevelSource));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -77,7 +77,7 @@ namespace Kryz.CharacterStats.Examples
|
|||||||
{
|
{
|
||||||
AllocatedStatPoints.Add(0);
|
AllocatedStatPoints.Add(0);
|
||||||
}
|
}
|
||||||
AvailablePointsToAllocate = GameConstants.CharacterBalancing.StatPointsPerLevel;
|
AvailablePointsToAllocate = GameConstants.CharacterStatsBalancing.StatPointsPerLevel;
|
||||||
|
|
||||||
characterData.playerOwnerID = PlayerDataHandler.Instance.currentPlayerName.Value;
|
characterData.playerOwnerID = PlayerDataHandler.Instance.currentPlayerName.Value;
|
||||||
characterData.currentLevel = level.currentLevel;
|
characterData.currentLevel = level.currentLevel;
|
||||||
@ -151,7 +151,7 @@ namespace Kryz.CharacterStats.Examples
|
|||||||
|
|
||||||
UpdateStatsBasedOnLevel();
|
UpdateStatsBasedOnLevel();
|
||||||
|
|
||||||
AvailablePointsToAllocate += GameConstants.CharacterBalancing.StatPointsPerLevel;
|
AvailablePointsToAllocate += GameConstants.CharacterStatsBalancing.StatPointsPerLevel;
|
||||||
|
|
||||||
characterData.availablePointsToAllocate = AvailablePointsToAllocate;
|
characterData.availablePointsToAllocate = AvailablePointsToAllocate;
|
||||||
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public enum PrimaryStat //just dev reference
|
||||||
|
{
|
||||||
|
Strength,
|
||||||
|
Agility,
|
||||||
|
Intelligence,
|
||||||
|
Spirit,
|
||||||
|
Vitality
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 310aade90dc7090489dd147248eaf53b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,15 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public enum SecondaryStat //just dev reference
|
||||||
|
{
|
||||||
|
CritChance,
|
||||||
|
CritDamage,
|
||||||
|
AttackDamage,
|
||||||
|
SpellDamage,
|
||||||
|
MaxHealth,
|
||||||
|
Armor,
|
||||||
|
MagicResistance,
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d7076d155fb6eb44285387cc8f44ba90
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -49,11 +49,11 @@ public class SummonAbility : BaseAbility
|
|||||||
ownerStats = user.GetComponent<CharacterStats>();
|
ownerStats = user.GetComponent<CharacterStats>();
|
||||||
minionStats = instantiatedMinion.GetComponent<CharacterStats>();
|
minionStats = instantiatedMinion.GetComponent<CharacterStats>();
|
||||||
|
|
||||||
minionStats.Strength.AddModifier(new StatModifier(ownerStats.Strength.Value * GameConstants.CharacterBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
minionStats.Strength.AddModifier(new StatModifier(ownerStats.Strength.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
||||||
minionStats.Agility.AddModifier(new StatModifier(ownerStats.Agility.Value * GameConstants.CharacterBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
minionStats.Agility.AddModifier(new StatModifier(ownerStats.Agility.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
||||||
minionStats.Intelligence.AddModifier(new StatModifier(ownerStats.Intelligence.Value * GameConstants.CharacterBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
minionStats.Intelligence.AddModifier(new StatModifier(ownerStats.Intelligence.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
||||||
minionStats.Spirit.AddModifier(new StatModifier(ownerStats.Spirit.Value * GameConstants.CharacterBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
minionStats.Spirit.AddModifier(new StatModifier(ownerStats.Spirit.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
||||||
minionStats.Vitality.AddModifier(new StatModifier(ownerStats.Vitality.Value * GameConstants.CharacterBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
minionStats.Vitality.AddModifier(new StatModifier(ownerStats.Vitality.Value * GameConstants.CharacterStatsBalancing.PercentageStatScaleForMinions, StatModType.Flat, ownerStats));
|
||||||
|
|
||||||
minionStats.onUpdateStatValues.Invoke();
|
minionStats.onUpdateStatValues.Invoke();
|
||||||
}
|
}
|
||||||
|
@ -61,8 +61,31 @@ public static class GameConstants
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CharacterBalancing
|
public static class CharacterStatsBalancing
|
||||||
{
|
{
|
||||||
|
public const float CritChanceIncreaseFromAgility = 0.005f; //0.5% agi => critChance (30% +/- tops)
|
||||||
|
public const float CritChanceIncreaseFromIntelligence = 0.002f; //0.2% int => critChance (12% +/- tops)
|
||||||
|
|
||||||
|
public const float CritDamageIncreaseFromAgility = 0.002f; //0.2% agi => critDmg
|
||||||
|
public const float CritDamageIncreaseFromIntelligence = 0.001f; //0.1% int => critDmg
|
||||||
|
public const float CritDamageIncreaseFromStrength = 0.002f; //0.2% str => critDmg
|
||||||
|
|
||||||
|
public const float AttackDamageIncreaseFromStrength = 1f; //100% str => AttkDmg
|
||||||
|
public const float AttackDamageIncreaseFromAgility = 0.45f; // 45% agi => AttkDmg
|
||||||
|
|
||||||
|
public const float SpellDamageIncreaseFromIntelligence = 1f; //100% int => SpDmg
|
||||||
|
public const float SpellDamageIncreaseFromSpirit = 0.45f; // 45% spi => SpDmg
|
||||||
|
|
||||||
|
public const float MaxHealthIncreaseFromVitality = 1f; //100% vit => MaxHP
|
||||||
|
public const float MaxHealthIncreaseFromSpirit = 0.1f; // 10% spi => MaxHP
|
||||||
|
|
||||||
|
public const float ArmorIncreaseFromStrength = 0.1f; //10% str => Armor
|
||||||
|
public const float ArmorIncreaseFromVitality = 0.2f; //20% vit => Armor
|
||||||
|
|
||||||
|
public const float MagicResistanceIncreaseFromSpirit = 1f; //100% spi => MagicRes
|
||||||
|
public const float MagicResistanceIncreaseFromVitality = 0.2f; //20% vit => MagicRes
|
||||||
|
public const float MagicResistanceIncreaseFromIntelligence = 0.1f; // 10% int => MagicRes
|
||||||
|
|
||||||
public const float BaseMaxHealthGrowthPerLevel = 0.2f;
|
public const float BaseMaxHealthGrowthPerLevel = 0.2f;
|
||||||
|
|
||||||
public const float VitalityToHealthRate = 10f;
|
public const float VitalityToHealthRate = 10f;
|
||||||
@ -76,6 +99,11 @@ public static class GameConstants
|
|||||||
|
|
||||||
public const int StatPointsPerLevel = 1;
|
public const int StatPointsPerLevel = 1;
|
||||||
|
|
||||||
|
public const float PercentageStatScaleForMinions = 0.8f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CharacterBalancing
|
||||||
|
{
|
||||||
public const float SoloCheatDeathHealthPercent = 0.5f;
|
public const float SoloCheatDeathHealthPercent = 0.5f;
|
||||||
public const float SoloCheatDeathInvulnerabilityDuration = 3f;
|
public const float SoloCheatDeathInvulnerabilityDuration = 3f;
|
||||||
|
|
||||||
@ -86,7 +114,7 @@ public static class GameConstants
|
|||||||
public const float ReviveTime = 5f;
|
public const float ReviveTime = 5f;
|
||||||
public const float ReviveHealthPercent = 0.5f;
|
public const float ReviveHealthPercent = 0.5f;
|
||||||
|
|
||||||
public const float PercentageStatScaleForMinions = 0.8f;
|
|
||||||
|
|
||||||
public const float MovementSpeedCap = 15f;
|
public const float MovementSpeedCap = 15f;
|
||||||
public const float PercentAngularSpeedCap = 1f;
|
public const float PercentAngularSpeedCap = 1f;
|
||||||
@ -187,6 +215,12 @@ public static class GameConstants
|
|||||||
public static object AllocatedSource = "Allocated";
|
public static object AllocatedSource = "Allocated";
|
||||||
public static object LevelSource = "Level";
|
public static object LevelSource = "Level";
|
||||||
|
|
||||||
|
public static object StrengthSource = "STR";
|
||||||
|
public static object AgilitySource = "AGI";
|
||||||
|
public static object IntelligenceSource = "INT";
|
||||||
|
public static object SpiritSource = "SPI";
|
||||||
|
public static object VitalitySource = "VIT";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ public class Health : Resource
|
|||||||
|
|
||||||
public virtual void CalculateMaxValueBasedOnStat()
|
public virtual void CalculateMaxValueBasedOnStat()
|
||||||
{
|
{
|
||||||
maxValue = baseMaxValue + character.Vitality.Value * GameConstants.CharacterBalancing.VitalityToHealthRate;
|
maxValue = baseMaxValue + character.Vitality.Value * GameConstants.CharacterStatsBalancing.VitalityToHealthRate;
|
||||||
|
|
||||||
CalculateRegenValueBasedOnStat();
|
CalculateRegenValueBasedOnStat();
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ public class Health : Resource
|
|||||||
}
|
}
|
||||||
public void CalculateRegenValueBasedOnStat()
|
public void CalculateRegenValueBasedOnStat()
|
||||||
{
|
{
|
||||||
flatRegen = baseFlatRegen + (character.Strength.Value - character.Strength.BaseValue) * GameConstants.CharacterBalancing.BonusStrengthToFlatRegenRate;
|
flatRegen = baseFlatRegen + (character.Strength.Value - character.Strength.BaseValue) * GameConstants.CharacterStatsBalancing.BonusStrengthToFlatRegenRate;
|
||||||
//percentRegen = (character.Vitality.Value - character.Vitality.BaseValue) * GameConstants.CharacterBalancing.BonusVitalityToPercentRegenRate;
|
//percentRegen = (character.Vitality.Value - character.Vitality.BaseValue) * GameConstants.CharacterBalancing.BonusVitalityToPercentRegenRate;
|
||||||
|
|
||||||
//Debug.Log(this.gameObject.name + " regens health " + flatRegen + " " + percentRegen + " = " + flatRegen + (maxValue * percentRegen / 100f));
|
//Debug.Log(this.gameObject.name + " regens health " + flatRegen + " " + percentRegen + " = " + flatRegen + (maxValue * percentRegen / 100f));
|
||||||
|
@ -87,7 +87,7 @@ public class Mana : Resource
|
|||||||
|
|
||||||
public void CalculateMaxValueBasedOnStat()
|
public void CalculateMaxValueBasedOnStat()
|
||||||
{
|
{
|
||||||
maxValue = baseMaxValue + character.Intelligence.Value * GameConstants.CharacterBalancing.IntelligenceToManaRate;
|
maxValue = baseMaxValue + character.Intelligence.Value * GameConstants.CharacterStatsBalancing.IntelligenceToManaRate;
|
||||||
|
|
||||||
CalculateRegenValueBasedOnStat();
|
CalculateRegenValueBasedOnStat();
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public class Mana : Resource
|
|||||||
}
|
}
|
||||||
public void CalculateRegenValueBasedOnStat()
|
public void CalculateRegenValueBasedOnStat()
|
||||||
{
|
{
|
||||||
flatRegen = baseFlatRegen + (character.Spirit.Value - character.Spirit.BaseValue) * GameConstants.CharacterBalancing.BonusSpiritToFlatRegenRate;
|
flatRegen = baseFlatRegen + (character.Spirit.Value - character.Spirit.BaseValue) * GameConstants.CharacterStatsBalancing.BonusSpiritToFlatRegenRate;
|
||||||
//percentRegen = (character.Spirit.Value - character.Spirit.BaseValue) * GameConstants.CharacterBalancing.BonusSpiritToPercentRegenRate;
|
//percentRegen = (character.Spirit.Value - character.Spirit.BaseValue) * GameConstants.CharacterBalancing.BonusSpiritToPercentRegenRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ public class PlayerHealth : Health
|
|||||||
{
|
{
|
||||||
currentLevel = ((PlayerCharacterStats)character).level.currentLevel - 1;
|
currentLevel = ((PlayerCharacterStats)character).level.currentLevel - 1;
|
||||||
|
|
||||||
maxValue = (baseMaxValue + (baseMaxValue * currentLevel * GameConstants.CharacterBalancing.BaseMaxHealthGrowthPerLevel)) + character.Vitality.Value * GameConstants.CharacterBalancing.VitalityToHealthRate;
|
maxValue = (baseMaxValue + (baseMaxValue * currentLevel * GameConstants.CharacterStatsBalancing.BaseMaxHealthGrowthPerLevel)) + character.Vitality.Value * GameConstants.CharacterStatsBalancing.VitalityToHealthRate;
|
||||||
|
|
||||||
CalculateRegenValueBasedOnStat();
|
CalculateRegenValueBasedOnStat();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user