Overview

Create a basic component called EntityResource which can be used for quick implementation of various resources to the game, such as:

  1. Health
  2. Mana
  3. Stamina
  4. Overheat
  5. Etc.

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.

Challenges

  1. Update IncreaseValue function. Add an option which allows increasing CurrentValue more than MaxValue
  2. Add new functions:
    1. IncreaseMaxValue. Increases MaxValue on a given amount
    2. DecreaseMaxValue. Decreases MaxValue on a given amount
  3. Implement auto-decrease functionality. CurrentValue should decrease automatically to MinThreshold with a given rate if CurrentValue > MinThreshold. For example:
    1. MinThreshold = 100
    2. CurrentValue increased from 25 to 200
    3. CurrentValue automatically starts to decrease to 100 with a rate of 5 resource per second
  4. Implement auto-increase functionality. CurrentValue should increase automatically to MaxThreshold with a given rate if CurrentValue < MaxThreshold. For example:
    1. MaxThreshold = 50
    2. CurrentValue decreased from 100 to 5
    3. CurrentValue automatically starts to increase to 50 with a rate of 5 resource per second