Corgi Engine  v8.8
MoreMountains.Tools.MMHealthBar Class Reference

Add this component to an object and it will show a healthbar above it You can either use a prefab for it, or have the component draw one at the start More...

Inheritance diagram for MoreMountains.Tools.MMHealthBar:

Public Types

enum  HealthBarTypes { HealthBarTypes.Prefab, HealthBarTypes.Drawn, HealthBarTypes.Existing }
 the possible health bar types More...
 
enum  TimeScales { TimeScales.UnscaledTime, TimeScales.Time }
 the possible timescales the bar can work on More...
 

Public Member Functions

virtual void SetInitialActiveState ()
 Forces the bar into its initial active state (hiding it if AlwaysVisible is false) More...
 
virtual void ShowBar (bool state)
 Shows or hides the bar by changing its object's active state More...
 
virtual bool BarIsShown ()
 Whether or not the bar is currently active More...
 
virtual void Initialization ()
 Initializes the bar (handles visibility, parenting, initial value More...
 
virtual void UpdateBar (float currentHealth, float minHealth, float maxHealth, bool show)
 Updates the bar More...
 

Public Attributes

HealthBarTypes HealthBarType = HealthBarTypes.Drawn
 whether the healthbar uses a prefab or is drawn automatically More...
 
TimeScales TimeScale = TimeScales.UnscaledTime
 defines whether the bar will work on scaled or unscaled time (whether or not it'll keep moving if time is slowed down for example) More...
 
MMProgressBar HealthBarPrefab
 the prefab to use as the health bar More...
 
MMProgressBar TargetProgressBar
 the MMProgressBar this health bar should update More...
 
Vector2 Size = new Vector2(1f,0.2f)
 if the healthbar is drawn, its size in world units More...
 
Vector2 BackgroundPadding = new Vector2(0.01f,0.01f)
 if the healthbar is drawn, the padding to apply to the foreground, in world units More...
 
Vector3 InitialRotationAngles
 the rotation to apply to the MMHealthBarContainer when drawing it More...
 
Gradient ForegroundColor
 if the healthbar is drawn, the color of its foreground More...
 
Gradient DelayedColor
 if the healthbar is drawn, the color of its delayed bar More...
 
Gradient BorderColor
 if the healthbar is drawn, the color of its border More...
 
Gradient BackgroundColor
 if the healthbar is drawn, the color of its background More...
 
string SortingLayerName = "UI"
 the name of the sorting layer to put this health bar on More...
 
float Delay = 0.5f
 the delay to apply to the delayed bar if drawn More...
 
bool LerpFrontBar = true
 whether or not the front bar should lerp More...
 
float LerpFrontBarSpeed = 15f
 the speed at which the front bar lerps More...
 
bool LerpDelayedBar = true
 whether or not the delayed bar should lerp More...
 
float LerpDelayedBarSpeed = 15f
 the speed at which the delayed bar lerps More...
 
bool BumpScaleOnChange = true
 if this is true, bumps the scale of the healthbar when its value changes More...
 
float BumpDuration = 0.2f
 the duration of the bump animation More...
 
AnimationCurve BumpAnimationCurve = AnimationCurve.Constant(0,1,1)
 the animation curve to map the bump animation on More...
 
MMFollowTarget.UpdateModes FollowTargetMode = MMFollowTarget.UpdateModes.LateUpdate
 the mode the bar should follow the target in More...
 
bool NestDrawnHealthBar = false
 if this is true, the drawn health bar will be nested below the MMHealthBar More...
 
bool Billboard = false
 if this is true, a MMBillboard component will be added to the progress bar to make sure it always looks towards the camera More...
 
GameObject InstantiatedOnDeath
 a gameobject (usually a particle system) to instantiate when the healthbar reaches zero More...
 
Vector3 HealthBarOffset = new Vector3(0f,1f,0f)
 the offset to apply to the healthbar compared to the object's center More...
 
bool AlwaysVisible = true
 whether or not the bar should be permanently displayed More...
 
float DisplayDurationOnHit = 1f
 the duration (in seconds) during which to display the bar More...
 
bool HideBarAtZero = true
 if this is set to true the bar will hide itself when it reaches zero More...
 
float HideBarAtZeroDelay = 1f
 the delay (in seconds) after which to hide the bar More...
 
float TestMinHealth = 0f
 a test value to use when pressing the TestUpdateHealth button More...
 
float TestMaxHealth = 100f
 a test value to use when pressing the TestUpdateHealth button More...
 
float TestCurrentHealth = 25f
 a test value to use when pressing the TestUpdateHealth button More...
 
bool TestUpdateHealthButton
 

Protected Member Functions

virtual void Awake ()
 On Start, creates or sets the health bar up More...
 
void OnEnable ()
 On enable, initializes the bar again More...
 
virtual void DrawHealthBar ()
 Draws the health bar. More...
 
virtual void Update ()
 On Update, we hide or show our healthbar based on our current status More...
 
virtual IEnumerator FinalHideBar ()
 Hides the bar when it reaches zero More...
 
virtual void UpdateDrawnColors ()
 Updates the colors of the different bars More...
 
virtual void TestUpdateHealth ()
 A test method used to update the bar when pressing the TestUpdateHealth button in the inspector More...
 

Protected Attributes

MMProgressBar _progressBar
 
MMFollowTarget _followTransform
 
float _lastShowTimestamp = 0f
 
bool _showBar = false
 
Image _backgroundImage = null
 
Image _borderImage = null
 
Image _foregroundImage = null
 
Image _delayedImage = null
 
bool _finalHideStarted = false
 

Detailed Description

Add this component to an object and it will show a healthbar above it You can either use a prefab for it, or have the component draw one at the start

Member Enumeration Documentation

◆ HealthBarTypes

the possible health bar types

Enumerator
Prefab 
Drawn 
Existing 

◆ TimeScales

the possible timescales the bar can work on

Enumerator
UnscaledTime 
Time 

Member Function Documentation

◆ Awake()

virtual void MoreMountains.Tools.MMHealthBar.Awake ( )
protectedvirtual

On Start, creates or sets the health bar up

◆ BarIsShown()

virtual bool MoreMountains.Tools.MMHealthBar.BarIsShown ( )
virtual

Whether or not the bar is currently active

Returns

◆ DrawHealthBar()

virtual void MoreMountains.Tools.MMHealthBar.DrawHealthBar ( )
protectedvirtual

Draws the health bar.

◆ FinalHideBar()

virtual IEnumerator MoreMountains.Tools.MMHealthBar.FinalHideBar ( )
protectedvirtual

Hides the bar when it reaches zero

Returns
The hide bar.

◆ Initialization()

virtual void MoreMountains.Tools.MMHealthBar.Initialization ( )
virtual

Initializes the bar (handles visibility, parenting, initial value

◆ OnEnable()

void MoreMountains.Tools.MMHealthBar.OnEnable ( )
protected

On enable, initializes the bar again

◆ SetInitialActiveState()

virtual void MoreMountains.Tools.MMHealthBar.SetInitialActiveState ( )
virtual

Forces the bar into its initial active state (hiding it if AlwaysVisible is false)

◆ ShowBar()

virtual void MoreMountains.Tools.MMHealthBar.ShowBar ( bool  state)
virtual

Shows or hides the bar by changing its object's active state

Parameters
state

◆ TestUpdateHealth()

virtual void MoreMountains.Tools.MMHealthBar.TestUpdateHealth ( )
protectedvirtual

A test method used to update the bar when pressing the TestUpdateHealth button in the inspector

◆ Update()

virtual void MoreMountains.Tools.MMHealthBar.Update ( )
protectedvirtual

On Update, we hide or show our healthbar based on our current status

◆ UpdateBar()

virtual void MoreMountains.Tools.MMHealthBar.UpdateBar ( float  currentHealth,
float  minHealth,
float  maxHealth,
bool  show 
)
virtual

Updates the bar

Parameters
currentHealthCurrent health.
minHealthMinimum health.
maxHealthMax health.
showWhether or not we should show the bar.

◆ UpdateDrawnColors()

virtual void MoreMountains.Tools.MMHealthBar.UpdateDrawnColors ( )
protectedvirtual

Updates the colors of the different bars

Member Data Documentation

◆ _backgroundImage

Image MoreMountains.Tools.MMHealthBar._backgroundImage = null
protected

◆ _borderImage

Image MoreMountains.Tools.MMHealthBar._borderImage = null
protected

◆ _delayedImage

Image MoreMountains.Tools.MMHealthBar._delayedImage = null
protected

◆ _finalHideStarted

bool MoreMountains.Tools.MMHealthBar._finalHideStarted = false
protected

◆ _followTransform

MMFollowTarget MoreMountains.Tools.MMHealthBar._followTransform
protected

◆ _foregroundImage

Image MoreMountains.Tools.MMHealthBar._foregroundImage = null
protected

◆ _lastShowTimestamp

float MoreMountains.Tools.MMHealthBar._lastShowTimestamp = 0f
protected

◆ _progressBar

MMProgressBar MoreMountains.Tools.MMHealthBar._progressBar
protected

◆ _showBar

bool MoreMountains.Tools.MMHealthBar._showBar = false
protected

◆ AlwaysVisible

bool MoreMountains.Tools.MMHealthBar.AlwaysVisible = true

whether or not the bar should be permanently displayed

◆ BackgroundColor

Gradient MoreMountains.Tools.MMHealthBar.BackgroundColor
Initial value:
= new Gradient()
{
colorKeys = new GradientColorKey[2] {
new GradientColorKey(MMColors.Black, 0),
new GradientColorKey(MMColors.Black, 1f)
},
alphaKeys = new GradientAlphaKey[2] { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1) }
}

if the healthbar is drawn, the color of its background

◆ BackgroundPadding

Vector2 MoreMountains.Tools.MMHealthBar.BackgroundPadding = new Vector2(0.01f,0.01f)

if the healthbar is drawn, the padding to apply to the foreground, in world units

◆ Billboard

bool MoreMountains.Tools.MMHealthBar.Billboard = false

if this is true, a MMBillboard component will be added to the progress bar to make sure it always looks towards the camera

◆ BorderColor

Gradient MoreMountains.Tools.MMHealthBar.BorderColor
Initial value:
= new Gradient()
{
colorKeys = new GradientColorKey[2] {
new GradientColorKey(MMColors.AntiqueWhite, 0),
new GradientColorKey(MMColors.AntiqueWhite, 1f)
},
alphaKeys = new GradientAlphaKey[2] { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1) }
}

if the healthbar is drawn, the color of its border

◆ BumpAnimationCurve

AnimationCurve MoreMountains.Tools.MMHealthBar.BumpAnimationCurve = AnimationCurve.Constant(0,1,1)

the animation curve to map the bump animation on

◆ BumpDuration

float MoreMountains.Tools.MMHealthBar.BumpDuration = 0.2f

the duration of the bump animation

◆ BumpScaleOnChange

bool MoreMountains.Tools.MMHealthBar.BumpScaleOnChange = true

if this is true, bumps the scale of the healthbar when its value changes

◆ Delay

float MoreMountains.Tools.MMHealthBar.Delay = 0.5f

the delay to apply to the delayed bar if drawn

◆ DelayedColor

Gradient MoreMountains.Tools.MMHealthBar.DelayedColor
Initial value:
= new Gradient()
{
colorKeys = new GradientColorKey[2] {
new GradientColorKey(MMColors.Orange, 0),
new GradientColorKey(MMColors.Orange, 1f)
},
alphaKeys = new GradientAlphaKey[2] { new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1) }
}

if the healthbar is drawn, the color of its delayed bar

◆ DisplayDurationOnHit

float MoreMountains.Tools.MMHealthBar.DisplayDurationOnHit = 1f

the duration (in seconds) during which to display the bar

◆ FollowTargetMode

MMFollowTarget.UpdateModes MoreMountains.Tools.MMHealthBar.FollowTargetMode = MMFollowTarget.UpdateModes.LateUpdate

the mode the bar should follow the target in

◆ ForegroundColor

Gradient MoreMountains.Tools.MMHealthBar.ForegroundColor
Initial value:
= new Gradient()
{
colorKeys = new GradientColorKey[2] {
new GradientColorKey(MMColors.BestRed, 0),
new GradientColorKey(MMColors.BestRed, 1f)
},
alphaKeys = new GradientAlphaKey[2] {new GradientAlphaKey(1, 0),new GradientAlphaKey(1, 1)}}

if the healthbar is drawn, the color of its foreground

◆ HealthBarOffset

Vector3 MoreMountains.Tools.MMHealthBar.HealthBarOffset = new Vector3(0f,1f,0f)

the offset to apply to the healthbar compared to the object's center

◆ HealthBarPrefab

MMProgressBar MoreMountains.Tools.MMHealthBar.HealthBarPrefab

the prefab to use as the health bar

◆ HealthBarType

HealthBarTypes MoreMountains.Tools.MMHealthBar.HealthBarType = HealthBarTypes.Drawn

whether the healthbar uses a prefab or is drawn automatically

◆ HideBarAtZero

bool MoreMountains.Tools.MMHealthBar.HideBarAtZero = true

if this is set to true the bar will hide itself when it reaches zero

◆ HideBarAtZeroDelay

float MoreMountains.Tools.MMHealthBar.HideBarAtZeroDelay = 1f

the delay (in seconds) after which to hide the bar

◆ InitialRotationAngles

Vector3 MoreMountains.Tools.MMHealthBar.InitialRotationAngles

the rotation to apply to the MMHealthBarContainer when drawing it

◆ InstantiatedOnDeath

GameObject MoreMountains.Tools.MMHealthBar.InstantiatedOnDeath

a gameobject (usually a particle system) to instantiate when the healthbar reaches zero

◆ LerpDelayedBar

bool MoreMountains.Tools.MMHealthBar.LerpDelayedBar = true

whether or not the delayed bar should lerp

◆ LerpDelayedBarSpeed

float MoreMountains.Tools.MMHealthBar.LerpDelayedBarSpeed = 15f

the speed at which the delayed bar lerps

◆ LerpFrontBar

bool MoreMountains.Tools.MMHealthBar.LerpFrontBar = true

whether or not the front bar should lerp

◆ LerpFrontBarSpeed

float MoreMountains.Tools.MMHealthBar.LerpFrontBarSpeed = 15f

the speed at which the front bar lerps

◆ NestDrawnHealthBar

bool MoreMountains.Tools.MMHealthBar.NestDrawnHealthBar = false

if this is true, the drawn health bar will be nested below the MMHealthBar

◆ Size

Vector2 MoreMountains.Tools.MMHealthBar.Size = new Vector2(1f,0.2f)

if the healthbar is drawn, its size in world units

◆ SortingLayerName

string MoreMountains.Tools.MMHealthBar.SortingLayerName = "UI"

the name of the sorting layer to put this health bar on

◆ TargetProgressBar

MMProgressBar MoreMountains.Tools.MMHealthBar.TargetProgressBar

the MMProgressBar this health bar should update

◆ TestCurrentHealth

float MoreMountains.Tools.MMHealthBar.TestCurrentHealth = 25f

a test value to use when pressing the TestUpdateHealth button

◆ TestMaxHealth

float MoreMountains.Tools.MMHealthBar.TestMaxHealth = 100f

a test value to use when pressing the TestUpdateHealth button

◆ TestMinHealth

float MoreMountains.Tools.MMHealthBar.TestMinHealth = 0f

a test value to use when pressing the TestUpdateHealth button

◆ TestUpdateHealthButton

bool MoreMountains.Tools.MMHealthBar.TestUpdateHealthButton

◆ TimeScale

TimeScales MoreMountains.Tools.MMHealthBar.TimeScale = TimeScales.UnscaledTime

defines whether the bar will work on scaled or unscaled time (whether or not it'll keep moving if time is slowed down for example)


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