Iuvo Unity 0.5.1
This is library containing a variety of helper classes and extension methods for the Unity gane engine.
GitHub | Iuvo Unity Updates | Creator
Loading...
Searching...
No Matches
IuvoUnity.Configurations.HealthConfiguration Class Reference
Inheritance diagram for IuvoUnity.Configurations.HealthConfiguration:
IuvoUnity.Configurations.BaseConfig< T > IuvoUnity.Interfaces.IConfigure< T > IuvoUnity.Interfaces.IReconfigure< T > IuvoUnity.BaseClasses.IuvoInterfaceBase IuvoUnity.BaseClasses.IuvoInterfaceBase

Public Member Functions

AnimationCurve GetDefaultExperienceCurve ()
int GetMaxHealthAtLevel (int level)
void Serialize (HealthComponentData HealthComponent)
HealthComponentDataDeserializeHealthComponent ()
void SetLevelScalingCurve (AnimationCurve newHealthCurve)
 Sets a new experience curve for level scaling.
Dictionary< int, int > GetFullHealthTable ()
 Returns a dictionary mapping each level to the cumulative EXP required to reach that level.
virtual void OnEnable ()
virtual void OnDisable ()
override void PrintInfo ()
Public Member Functions inherited from IuvoUnity.Configurations.BaseConfig< T >
virtual void Configure (T configurable)
virtual void Reconfigure (T reconfigurable)
virtual string GetConfigSerializePath (string actingConfigClass, string objectToSerializeName, string parentConfigClass="BaseConfig")

Public Attributes

int BaseHealth = 100
Public Attributes inherited from IuvoUnity.Configurations.BaseConfig< T >
string configName

Protected Member Functions

virtual void ImplementDefaultScalingAlgorithm ()

Properties

int MaxLevel [get]

Private Attributes

AnimationCurve DefaultHealthGrowth
AnimationCurve healthCurve
HealthComponentData lastHealthComponentData = new HealthComponentData { MaxHealth = -100, CurrentLevel = -1, CurrentHealth = -1 }

Member Function Documentation

◆ DeserializeHealthComponent()

HealthComponentData? IuvoUnity.Configurations.HealthConfiguration.DeserializeHealthComponent ( )
53 {
54 // no valid data to load
55 return null;
56
57
58 // valid data to load
59
60 }

◆ GetDefaultExperienceCurve()

AnimationCurve IuvoUnity.Configurations.HealthConfiguration.GetDefaultExperienceCurve ( )
30 {
31 return DefaultHealthGrowth;
32 }

References DefaultHealthGrowth.

◆ GetFullHealthTable()

Dictionary< int, int > IuvoUnity.Configurations.HealthConfiguration.GetFullHealthTable ( )

Returns a dictionary mapping each level to the cumulative EXP required to reach that level.

Returns
92 {
93 Dictionary<int, int> healthTable = new Dictionary<int, int>();
94 for (int level = 1; level <= MaxLevel; level++)
95 {
96 healthTable[level] = GetMaxHealthAtLevel(level);
97 }
98 return healthTable;
99 }

References GetMaxHealthAtLevel(), and MaxLevel.

◆ GetMaxHealthAtLevel()

int IuvoUnity.Configurations.HealthConfiguration.GetMaxHealthAtLevel ( int level)
35 {
36 if (level < 1 || level > MaxLevel)
37 {
38 IuvoDebug.DebugLogError($"Level {level} is out of bounds. Valid levels are between 1 and {MaxLevel}.");
39 return -1;
40 }
41 return Mathf.FloorToInt(healthCurve.Evaluate(level));
42 }

References IuvoUnity.Debug.IuvoDebug.DebugLogError(), healthCurve, and MaxLevel.

Referenced by GetFullHealthTable().

◆ ImplementDefaultScalingAlgorithm()

virtual void IuvoUnity.Configurations.HealthConfiguration.ImplementDefaultScalingAlgorithm ( )
protectedvirtual
82 {
83 IuvoDebug.DebugLog("Implementing default level scaling algorithm...");
84 }

References IuvoUnity.Debug.IuvoDebug.DebugLog().

Referenced by SetLevelScalingCurve().

◆ OnDisable()

virtual void IuvoUnity.Configurations.HealthConfiguration.OnDisable ( )
virtual
106 {
107 IuvoDebug.DebugLog("HealthConfiguration disabled.");
108 }

References IuvoUnity.Debug.IuvoDebug.DebugLog().

◆ OnEnable()

virtual void IuvoUnity.Configurations.HealthConfiguration.OnEnable ( )
virtual
103 {
104 }

◆ PrintInfo()

override void IuvoUnity.Configurations.HealthConfiguration.PrintInfo ( )
virtual

Reimplemented from IuvoUnity.Configurations.BaseConfig< T >.

111 {
112 base.PrintInfo();
113 IuvoDebug.DebugLog($"Health Configuration: BaseHealth = {BaseHealth}");
114 }

References IuvoUnity.Debug.IuvoDebug.DebugLog().

◆ Serialize()

void IuvoUnity.Configurations.HealthConfiguration.Serialize ( HealthComponentData HealthComponent)
48 {
49
50 }

◆ SetLevelScalingCurve()

void IuvoUnity.Configurations.HealthConfiguration.SetLevelScalingCurve ( AnimationCurve newHealthCurve)

Sets a new experience curve for level scaling.

Parameters
newExpCurve
70 {
71 if (newHealthCurve == null)
72 {
73 IuvoDebug.DebugLogError("New Expereience curve cannot be null. Implementing default scaling");
74 ImplementDefaultScalingAlgorithm();
75 return;
76 }
77 IuvoDebug.DebugLog("Setting level scaling algorithm...");
78 healthCurve = newHealthCurve;
79 }

References IuvoUnity.Debug.IuvoDebug.DebugLog(), IuvoUnity.Debug.IuvoDebug.DebugLogError(), healthCurve, and ImplementDefaultScalingAlgorithm().

Member Data Documentation

◆ BaseHealth

int IuvoUnity.Configurations.HealthConfiguration.BaseHealth = 100

◆ DefaultHealthGrowth

AnimationCurve IuvoUnity.Configurations.HealthConfiguration.DefaultHealthGrowth
private
Initial value:
= new AnimationCurve(
new Keyframe(1, 100),
new Keyframe(25, 25000),
new Keyframe(50, 150000),
new Keyframe(75, 2500000),
new Keyframe(100, 50000000)
)

Referenced by GetDefaultExperienceCurve().

◆ healthCurve

AnimationCurve IuvoUnity.Configurations.HealthConfiguration.healthCurve
private

◆ lastHealthComponentData

HealthComponentData IuvoUnity.Configurations.HealthConfiguration.lastHealthComponentData = new HealthComponentData { MaxHealth = -100, CurrentLevel = -1, CurrentHealth = -1 }
private
26{ MaxHealth = -100, CurrentLevel = -1, CurrentHealth = -1 };

Property Documentation

◆ MaxLevel

int IuvoUnity.Configurations.HealthConfiguration.MaxLevel
get

The documentation for this class was generated from the following file: