UnitStatsProvider
A way of providing stats to units.
Inherits from MonoBehaviour.
Properties
Name | Description | Type |
---|---|---|
data | Unit stats data. | UnitStats |
onStatChanged | Called whenever a stat's current value is changed. | UnityEvent<UpgradableStat> |
onStatReachedMin | Called whenever a stat's current value reaches its min value. | UnitEvent<UpgradableStat> |
onStatReachedMax | Called whenever a stat's current value reaches its max value. | UnitEvent<UpgradableStat> |
onStatLevelChanged | Called whenever a stat's level is changed. | UnitEvent<UpgradableStat> |
level | The level of the unit. | int |
Methods
SetStat
Sets the current value of a stat.
Parameters
Name | Description | Type |
---|---|---|
name | The name of the stat. | string |
newValue | The value to set to. | float |
IncreaseStat
Return Type: float
Increases a stat's current value by an amount. Returns the excess amount.
Parameters
Name | Description | Type |
---|---|---|
name | The name of the stat. | string |
amount | The amount to increase. | float |
DecreaseStat
Return Type: float
Decreases a stat's current value by an amount. Returns the excess amount.
Parameters
Name | Description | Type |
---|---|---|
name | The name of the stat. | string |
amount | The amount to decrease. | float |
GetStat
Return Type: UpgradableStat
Gets a stat by name.
Parameters
Name | Description | Type |
---|---|---|
name | The name of the stat. | string |
LevelUp
Increases the unit's level by 1.
LevelDown
Decreases the unit's level by 1.
SetLevel
Sets the unit's level.
Parameters
Name | Description | Type |
---|---|---|
level | The level to set to. | int |
RecalculateAll
Recalculates all stats.
ResetAllCurrentValues
Resets all stat current values.
Last updated