Create a basic component called EntityResource which can be used for quick implementation of various resources to the game, such as:
The component should have these parameters, functions, and callbacks.
| PARAMETER | DESCRIPTION |
|---|---|
InitialValue |
Determines CurrentValue of the resource at the start of a game |
MaxValue |
Determines MaxValue of the resource |
| FUNCTION | DESCRIPTION |
|---|---|
IncreaseValue |
Increases CurrentValue of the resource on a given amount. It can’t increase CurrentValue more thanMaxValue |
DecreaseValue |
Decreases CurrentValue of the resource on a given amount. It can’t decrease CurrentValue less than zero |
| CALLBACK | DESCRIPTION |
|---|---|
OnValueIncreased |
Called when CurrentValue was increased |
OnValueDecreased |
Called when CurrentValue was decreased |
OnValueZero |
Called when CurrentValue reached zero |
Create a HealthComponent inherited from EntityResourceComponent.
IncreaseValue function. Add an option which allows increasing CurrentValue more than MaxValueIncreaseMaxValue. Increases MaxValue on a given amountDecreaseMaxValue. Decreases MaxValue on a given amountCurrentValue should decrease automatically to MinThreshold with a given rate if CurrentValue > MinThreshold. For example:
MinThreshold = 100CurrentValue increased from 25 to 200CurrentValue automatically starts to decrease to 100 with a rate of 5 resource per secondCurrentValue should increase automatically to MaxThreshold with a given rate if CurrentValue < MaxThreshold. For example:
MaxThreshold = 50CurrentValue decreased from 100 to 5CurrentValue automatically starts to increase to 50 with a rate of 5 resource per second