ProgressLevelController.cs 879 B

1234567891011121314151617181920212223242526272829303132
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ProgressLevelController : MonoBehaviour
  6. {
  7. public List<Image> ListImagesLevelProgress;
  8. public void UpdateListImages(int stage)
  9. {
  10. var value = stage / LevelManager.STAGE_LEVEL;
  11. int indexLevel = Mathf.CeilToInt(value);
  12. var v = value - indexLevel;
  13. for (var i = 0; i < ListImagesLevelProgress.Count; i++)
  14. {
  15. if(i <= indexLevel)
  16. {
  17. ListImagesLevelProgress[i].fillAmount = 1;
  18. }
  19. else if(i == indexLevel+1)
  20. {
  21. ListImagesLevelProgress[i].fillAmount = v / LevelManager.STAGE_LEVEL;
  22. }
  23. else
  24. {
  25. ListImagesLevelProgress[i].fillAmount = 0;
  26. }
  27. }
  28. }
  29. }