Ejemplo n.º 1
0
 /// <summary>
 /// Stop the coroutine that fill the image
 /// </summary>
 /// <param name="_lifeBar"></param>
 public void StopFilling(TDS_LifeBar _lifeBar)
 {
     if (filledImages.ContainsKey(_lifeBar))
     {
         if (filledImages[_lifeBar] != null)
         {
             StopCoroutine(filledImages[_lifeBar]);
         }
         filledImages.Remove(_lifeBar);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Fill the image until its fillAmount until it reaches the fillingValue
 /// At the end of the filling, remove the entry of the dictionary at the key _filledImage
 /// </summary>
 /// <param name="_lifebar">Image to fill</param>
 /// <param name="_fillingValue">Fill amount to reach</param>
 /// <returns></returns>
 private IEnumerator UpdateFilledImage(TDS_LifeBar _lifebar, float _fillingValue)
 {
     if (!_lifebar)
     {
         yield break;
     }
     if (_lifebar.ForegroundFilledImage)
     {
         _lifebar.ForegroundFilledImage.fillAmount = _fillingValue;
     }
     while (_lifebar.FilledImage.fillAmount != _fillingValue && _lifebar.FilledImage != null)
     {
         _lifebar.FilledImage.fillAmount = Mathf.MoveTowards(_lifebar.FilledImage.fillAmount, _fillingValue, Time.deltaTime / 5);
         yield return(new WaitForEndOfFrame());
     }
     filledImages.Remove(_lifebar);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Check if the image is already being filled
 /// If so, stop the coroutine and remove it from the dictionary
 /// Then start the coroutine and stock it with the filledImage as a key in the dictionary
 /// </summary>
 /// <param name="_filledImage">Image to fill</param>
 /// <param name="_fillingValue">Filling value to reach</param>
 public void FillImage(TDS_LifeBar _lifebar, float _fillingValue)
 {
     StopFilling(_lifebar);
     filledImages.Add(_lifebar, StartCoroutine(UpdateFilledImage(_lifebar, _fillingValue)));
 }