Namespace TetraCreations.ProgressBarSystem
Classes
ActiveConditionChangedEventArgs
Raised when the progress bar active condition has changed.
AnimationsManager
Regroup the Shake and PulseImage effects in the same class.
BarSegment
Represent a portion of the ProgressBar using an Image.
Borders
Controls multiple Rect Transform Offset to display a Border around the ProgressBar,
simply set the size to 0 if you don't want to use it.
ColorChangedEventArgs
Pass the new Color when it changed.
FillSegment
Represent the main area of the ProgressBar to be filled.
It contains a list of BarSegment which are the increasing / decreasing segments.
When modifying the fill method or fill origin, the value of the child segments is automatically updated.
Indicator
Uses an Image component with a Sprite and follows the current value of the progress bar.
We can use a 2D mask to prevent the RectTransform, and therefore the image, from extending beyond the progress bar.
We can also choose any color for the image, but I recommend setting UseSegmentColor to true and then modifying the ColorBrightnessMultiplier.
This way, the image can be slightly brighter (positive multiplier) or darker (negative multiplier) than the colour of the currently active segment.
InitialResourceValue
Resource value used to initialize the ResourceManager of Unit at runtime.
See UnitData.
MaximumValueReachedEventArgs
Raised when the progress bar value is equals to the maximum value.
We pass the overflowing amount, for example if a character needs 100 experience points to level up once :
If he gains 1,000 experience points, we want to calculate how many levels he will gain thanks to the additional 900 experience points.
MinimumValueReachedEventArgs
Raised when the progress bar value is equals to the minimum value.
We pass the overflowing amount, for example if a character has 100 armor :
If he takes 200 damage points we can apply the additional 100 damage points to another protection.
PerformanceManager
This script will update the Progress Bars parent position to follow their 'Owner' transform in one update call inside one canvas.
It also rotate all visible Progress Bars to face the camera. (Billboard)
And finally it will Hide/Show Progress Bars if their 'Owner' is not visible by the Camera. (Culling)
ProgressBar
The progress bar inherits from the ValueManager to modify the minimum, current and maximum values during runtime.
The visual appearance and functionality are divided into different simple C# classes :
- ProgressBarText : Updates the text of the current value and maximum value of the progress bar.
- Indicator : Maintains the position of a Sprite at the current value of the progress bar.
- Borders : Add borders to each corner of the progress bar : Top, Bottom, Left, Right.
- ProgressBarRegeneration : Updates the text of the current regeneration applied to the progress bar.
- AnimationsManager : Controls the shaking and pulsing animations.
ProgressBarChangedEventArgs
Raised when setting a new ProgressBar in the ResourceManager.
ProgressBarCondition
Changes the visual appearance of the progress bar or starts the pulsing animation effect when the progress bar value reaches a certain percentage.
ProgressBarInitializedEventArgs
When the progress bar is initialized, no data for the moment.
ProgressBarRegenerationInitializedEventArgs
Passed when the ProgressBarRegeneration is initialized.
ProgressBarRegenerationText
Update the regeneration text values of the Progress Bar, the amount, the tickrate, the float format etc.
ProgressBarText
Converts the floating point values to the desired format to display them on the progress bar.
By default we show the current and maximum value, but we can choose to show the percentage or the only the current value.
Regeneration
Regenerate the Value of a ProgressBar every tick.
RegenerationActivationEventArgs
Pass if the ResourceRegeneration is Enable/Disable.
RegenerationStateEventArgs
Pass the RegenerationState in the RegenerationStateChangedEvent
RegenerationValuesEventArgs
Send the new regenerated amount per tick and the tick rate.
Resource
Represent a type of 'Resource' like Health, Mana, Stamina, Hunger, Oxygen etc.
ResourceManager
Manages a Resource value and eventually updates a Progress Bar automatically.
ResourceRegeneration
Regenerate a the ValueManager.Value over time.
It also synchronize the regeneration with the ProgressBar.Regeneration class.
ResourcesController
Keep track of all the ResourceManager and ResourceRegeneration for each Resource for a GameObject.
It will Update every ResourceRegeneration timers automatically.
We can also add new ResourceManager or new ResourceRegeneration at runtime, initialize them with Values from UniData InitialResourcesValue for example.
SegmentController
Synchronizes the progression of three different segments by changing the fill amount of their corresponding Image.
Also manages the coroutines of the sub-segment shrink animation.
SegmentEventArgs
Pass a BarSegment using standard C# event
ValueChangedEventArgs
Contains the new value, the difference with the previous value, the value type that changed (Value, Minimum, Maximum).
And the new percentage, so we don't have to recalculate it.
ValueManager
It maintains a value between the minimum and maximum values.
Each value can be modified using this class.
It gives a layer of abstraction as this class doesn't know about ProgressBar or Resource.
ValueManagerInitializedEventArgs
When the value manager is initialized, no data for the moment.
ValueRegeneration<T>
Regenerate the Value of a ValueManager every tick.
We can choose to cumulate multiple regneration type : Flat, Percentage, Percentage of Missing value.
Like the ValueManager this class doesn't know about the ProgressBar or Resource.
We use a generic type to add a layer of abstraction by given the possibility to override the ValueManager.
ValueRegenerationInitializedEventArgs
When the ValueRegeneration is listening to the ValueManager events to update it's state.
ValuesRestoredEventArgs
When the values in the value manager have been restored to their original values.
ValueStateEventArgs
Pass the ValueState in the ValueStateChangedEvent
Structs
ProgressBarRuntimeData
Used by the PerformanceManager update the position of all the ProgressBar to follow their 'owner' position plus an offset.
It also store the Enemy/Unit collider to know if it's visible by the Camera.
Interfaces
IColorChanger
Enums
BorderType
Represents each border of the progress bar : Top, Bottom, Left, Right.
RegenerationDisplay
Choose when you want to display the regeneration values on the ProgressBar :
- Hidden
- AlwaysVisible
- VisibleWhenRegenerating
RegenerationState
Determines the state of the regeneration process :
- Stopped
- Started : Wait for the delay timer to be over.
- Regenerating : The delay timer and the tick rate timer are over. This will loop until we can no longer regenerate.
SegmentType
ProgressBar is splitted into three segments : Main, Increase, Decrease.
Main : The main filling area.
Increase : Represent the last added value.
Decrease : Represent the last remove value.
TextFormat
Determines the display format of the progress bar values.
ValueChangeType
Determines the type of change made to a value : None, Increase or Decrease.
ValueState
Determines the state of a value with limits : either minimum, maximum, or between the two.
ValueType
Determines the type of value(s) that has (have) changed.