TopDown Engine  v3.6
MoreMountains.TopDownEngine.AmmoDisplay Class Reference

A class that combines a progress bar and a text display and that can be used to display the current ammo level of a weapon More...

Inheritance diagram for MoreMountains.TopDownEngine.AmmoDisplay:
MoreMountains.Tools.MMProgressBar MoreMountains.Tools.MMMonoBehaviour

Public Member Functions

override void Initialization ()
 On init we initialize our string builder More...
 
virtual void UpdateTextDisplay (string newText)
 Updates the text display with the parameter string More...
 
virtual void UpdateAmmoDisplays (bool magazineBased, int totalAmmo, int maxAmmo, int ammoInMagazine, int magazineSize, bool displayTotal)
 Updates the ammo display's text and progress bar More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMProgressBar
virtual void UpdateBar01 (float normalizedValue)
 Updates the bar's values, using a normalized value More...
 
virtual void UpdateBar (float currentValue, float minValue, float maxValue)
 Updates the bar's values based on the specified parameters More...
 
virtual void SetBar (float currentValue, float minValue, float maxValue)
 Sets the bar value to the one specified More...
 
virtual void SetBar01 (float newPercent)
 Sets the bar value to the normalized value set in parameter More...
 
virtual void Plus10Percent ()
 Test method - increases the bar's current value by 10% More...
 
virtual void Minus10Percent ()
 Test method - decreases the bar's current value by 10% More...
 
virtual void Plus20Percent ()
 Test method - increases the bar's current value by 20% More...
 
virtual void Minus20Percent ()
 Test method - decreases the bar's current value by 20% More...
 
virtual void Bump ()
 Triggers a camera bump More...
 
virtual void ShowBar ()
 A simple method you can call to show the bar (set active true) More...
 
virtual void HideBar (float delay)
 Hides (SetActive false) the progress bar object, after an optional delay More...
 

Public Attributes

int AmmoDisplayID = 0
 the ID of the AmmoDisplay More...
 
Text TextDisplay
 the Text object used to display the current ammo numbers More...
 
- Public Attributes inherited from MoreMountains.Tools.MMProgressBar
string PlayerID
 optional - the ID of the player associated to this bar More...
 
Transform ForegroundBar
 the main, foreground bar More...
 
Transform DelayedBarDecreasing
 the delayed bar that will show when moving from a value to a new, lower value More...
 
Transform DelayedBarIncreasing
 the delayed bar that will show when moving from a value to a new, higher value More...
 
float MinimumBarFillValue = 0f
 the local scale or fillamount value to reach when the value associated to the bar is at 0% More...
 
float MaximumBarFillValue = 1f
 the local scale or fillamount value to reach when the bar is full More...
 
bool SetInitialFillValueOnStart = false
 whether or not to initialize the value of the bar on start More...
 
float InitialFillValue = 0f
 the initial value of the bar More...
 
BarDirections BarDirection = BarDirections.LeftToRight
 the direction this bar moves to More...
 
FillModes FillMode = FillModes.LocalScale
 the foreground bar's fill mode 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...
 
BarFillModes BarFillMode = BarFillModes.SpeedBased
 the selected fill animation mode More...
 
bool LerpForegroundBar = true
 whether or not the foreground bar should lerp More...
 
float LerpForegroundBarSpeedDecreasing = 15f
 the speed at which to lerp the foreground bar More...
 
float LerpForegroundBarSpeedIncreasing = 15f
 the speed at which to lerp the foreground bar if value is increasing More...
 
float LerpForegroundBarDurationDecreasing = 0.2f
 the speed at which to lerp the foreground bar if speed is decreasing More...
 
float LerpForegroundBarDurationIncreasing = 0.2f
 the duration each update of the foreground bar should take (only if in fixed duration bar fill mode) More...
 
AnimationCurve LerpForegroundBarCurveDecreasing = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f)
 the curve to use when animating the foreground bar fill decreasing More...
 
AnimationCurve LerpForegroundBarCurveIncreasing = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f)
 the curve to use when animating the foreground bar fill increasing More...
 
float DecreasingDelay = 1f
 the delay before the delayed bar moves (in seconds) More...
 
bool LerpDecreasingDelayedBar = true
 whether or not the delayed bar's animation should lerp More...
 
float LerpDecreasingDelayedBarSpeed = 15f
 the speed at which to lerp the delayed bar More...
 
float LerpDecreasingDelayedBarDuration = 0.2f
 the duration each update of the foreground bar should take (only if in fixed duration bar fill mode) More...
 
AnimationCurve LerpDecreasingDelayedBarCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f)
 the curve to use when animating the delayed bar fill More...
 
float IncreasingDelay = 1f
 the delay before the delayed bar moves (in seconds) More...
 
bool LerpIncreasingDelayedBar = true
 whether or not the delayed bar's animation should lerp More...
 
float LerpIncreasingDelayedBarSpeed = 15f
 the speed at which to lerp the delayed bar More...
 
float LerpIncreasingDelayedBarDuration = 0.2f
 the duration each update of the foreground bar should take (only if in fixed duration bar fill mode) More...
 
AnimationCurve LerpIncreasingDelayedBarCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f)
 the curve to use when animating the delayed bar fill More...
 
bool BumpScaleOnChange = true
 whether or not the bar should "bump" when changing value More...
 
bool BumpOnIncrease = false
 whether or not the bar should bump when its value increases More...
 
bool BumpOnDecrease = false
 whether or not the bar should bump when its value decreases More...
 
float BumpDuration = 0.2f
 the duration of the bump animation More...
 
bool ChangeColorWhenBumping = true
 whether or not the bar should flash when bumping More...
 
bool StoreBarColorOnPlay = true
 whether or not to store the initial bar color before a bump More...
 
Color BumpColor = Color.white
 the color to apply to the bar when bumping More...
 
AnimationCurve BumpScaleAnimationCurve = new AnimationCurve(new Keyframe(1, 1), new Keyframe(0.3f, 1.05f), new Keyframe(1, 1))
 the curve to map the bump animation on More...
 
AnimationCurve BumpColorAnimationCurve = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.3f, 1f), new Keyframe(1, 0))
 the curve to map the bump animation color animation on More...
 
bool ApplyBumpIntensityMultiplier = false
 if this is true, the BumpIntensityMultiplier curve will be evaluated to apply a multiplier to the bump intensity More...
 
AnimationCurve BumpIntensityMultiplier = new AnimationCurve(new Keyframe(-1, 1), new Keyframe(1, 1))
 the curve to map the bump's intensity on. x is the delta of the bump, y is the associated multiplier More...
 
UnityEvent OnBump
 an event to trigger every time the bar bumps More...
 
UnityEvent< float > OnBumpIntensity
 an event to trigger every time the bar bumps, with its bump intensity (based on BumpDeltaMultiplier) in parameter More...
 
UnityEvent OnBarMovementDecreasingStart
 an event to trigger every time the bar starts decreasing More...
 
UnityEvent OnBarMovementDecreasingStop
 an event to trigger every time the bar stops decreasing More...
 
UnityEvent OnBarMovementIncreasingStart
 an event to trigger every time the bar starts increasing More...
 
UnityEvent OnBarMovementIncreasingStop
 an event to trigger every time the bar stops increasing More...
 
Text PercentageText
 a Text object to update with the bar's value More...
 
string TextPrefix
 a prefix to always add to the bar's value display More...
 
string TextSuffix
 a suffix to always add to the bar's value display More...
 
float TextValueMultiplier = 1f
 a value multiplier to always apply to the bar's value when displaying it More...
 
string TextFormat = "{000}"
 the format in which the text should display More...
 
bool DisplayTotal = false
 whether or not to display the total after the current value More...
 
string TotalSeparator = " / "
 if DisplayTotal is true, the separator to put between the current value and the total More...
 
float DebugNewTargetValue
 the value the bar will move to if you press the DebugSet button More...
 
bool DebugUpdateBarButton
 
bool DebugSetBarButton
 
bool TestBumpButton
 
bool Plus10PercentButton
 
bool Minus10PercentButton
 
float BarProgress
 the current progress of the bar, ideally read only More...
 
float BarTarget
 the value towards which the bar is currently interpolating, ideally read only More...
 
float DelayedBarIncreasingProgress
 the current progress of the delayed bar increasing More...
 
float DelayedBarDecreasingProgress
 the current progress of the delayed bar decreasing More...
 

Protected Attributes

int _totalAmmoLastTime
 
StringBuilder _stringBuilder
 
- Protected Attributes inherited from MoreMountains.Tools.MMProgressBar
bool _initialized
 
Vector2 _initialBarSize
 
Color _initialColor
 
Vector3 _initialScale
 
Image _foregroundImage
 
Image _delayedDecreasingImage
 
Image _delayedIncreasingImage
 
Vector3 _targetLocalScale = Vector3.one
 
float _newPercent
 
float _percentLastTimeBarWasUpdated
 
float _lastUpdateTimestamp
 
float _time
 
float _deltaTime
 
int _direction
 
Coroutine _coroutine
 
bool _coroutineShouldRun = false
 
bool _isDelayedBarIncreasingNotNull
 
bool _isDelayedBarDecreasingNotNull
 
bool _actualUpdate
 
Vector2 _anchorVector
 
float _delayedBarDecreasingProgress
 
float _delayedBarIncreasingProgress
 
MMProgressBarStates CurrentState = MMProgressBarStates.Idle
 
string _updatedText
 
string _totalText
 
bool _isForegroundBarNotNull
 
bool _isForegroundImageNotNull
 
bool _isPercentageTextNotNull
 
bool _isPercentageTextMeshProNotNull
 

Additional Inherited Members

- Public Types inherited from MoreMountains.Tools.MMProgressBar
enum  MMProgressBarStates {
  MMProgressBarStates.Idle, MMProgressBarStates.Decreasing, MMProgressBarStates.Increasing, MMProgressBarStates.InDecreasingDelay,
  MMProgressBarStates.InIncreasingDelay
}
 
enum  FillModes {
  FillModes.LocalScale, FillModes.FillAmount, FillModes.Width, FillModes.Height,
  FillModes.Anchor
}
 the possible fill modes More...
 
enum  BarDirections { BarDirections.LeftToRight, BarDirections.RightToLeft, BarDirections.UpToDown, BarDirections.DownToUp }
 the possible directions for the fill (for local scale and fill amount only) More...
 
enum  TimeScales { TimeScales.UnscaledTime, TimeScales.Time }
 the possible timescales the bar can work on More...
 
enum  BarFillModes { BarFillModes.SpeedBased, BarFillModes.FixedDuration }
 the possible ways to animate the bar fill More...
 
- Protected Member Functions inherited from MoreMountains.Tools.MMProgressBar
virtual void Start ()
 On start we store our image component More...
 
virtual void OnEnable ()
 
virtual void StoreInitialColor ()
 
virtual void DebugUpdateBar ()
 This test method, called via the inspector button of the same name, lets you test what happens when you update the bar to a certain value More...
 
virtual void DebugSetBar ()
 Test method More...
 
virtual void UpdateText ()
 
virtual IEnumerator UpdateBarsCo ()
 On Update we update our bars More...
 
virtual void DetermineDeltaTime ()
 
virtual void DetermineDirection ()
 
virtual void UpdateBars ()
 Updates the foreground bar's scale More...
 
virtual float ComputeNewFill (bool lerpBar, float barSpeed, float barDuration, AnimationCurve barCurve, float delay, float lastPercent, out float t)
 
virtual void SetBarInternal (float newAmount, Transform bar, Image image, Vector2 initialSize)
 
virtual IEnumerator BumpCoroutine (float intensityMultiplier)
 A coroutine that (usually quickly) changes the scale of the bar More...
 
virtual IEnumerator HideBarCo (float delay)
 An internal coroutine used to handle the disabling of the progress bar after a delay More...
 
- Properties inherited from MoreMountains.Tools.MMProgressBar
virtual bool Bumping [get, protected set]
 whether or not the bar is bumping right now More...
 

Detailed Description

A class that combines a progress bar and a text display and that can be used to display the current ammo level of a weapon

Member Function Documentation

◆ Initialization()

override void MoreMountains.TopDownEngine.AmmoDisplay.Initialization ( )
virtual

On init we initialize our string builder

Reimplemented from MoreMountains.Tools.MMProgressBar.

◆ UpdateAmmoDisplays()

virtual void MoreMountains.TopDownEngine.AmmoDisplay.UpdateAmmoDisplays ( bool  magazineBased,
int  totalAmmo,
int  maxAmmo,
int  ammoInMagazine,
int  magazineSize,
bool  displayTotal 
)
virtual

Updates the ammo display's text and progress bar

Parameters
magazineBasedIf set to true magazine based.
totalAmmoTotal ammo.
maxAmmoMax ammo.
ammoInMagazineAmmo in magazine.
magazineSizeMagazine size.
displayTotalIf set to true display total.

◆ UpdateTextDisplay()

virtual void MoreMountains.TopDownEngine.AmmoDisplay.UpdateTextDisplay ( string  newText)
virtual

Updates the text display with the parameter string

Parameters
newTextNew text.

Member Data Documentation

◆ _stringBuilder

StringBuilder MoreMountains.TopDownEngine.AmmoDisplay._stringBuilder
protected

◆ _totalAmmoLastTime

int MoreMountains.TopDownEngine.AmmoDisplay._totalAmmoLastTime
protected

◆ AmmoDisplayID

int MoreMountains.TopDownEngine.AmmoDisplay.AmmoDisplayID = 0

the ID of the AmmoDisplay

◆ TextDisplay

Text MoreMountains.TopDownEngine.AmmoDisplay.TextDisplay

the Text object used to display the current ammo numbers


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