StarsSummary.cs 907 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using UnityEngine;
  2. using System.Collections;
  3. public class StarsSummary : MonoBehaviour
  4. {
  5. public StarAchieved star1, star2, star3;
  6. public void AnimateStars()
  7. {
  8. var level = LevelsManager.Instance.CurrentLevel;
  9. if (GameDataManager.Instance.Score < level.star1Threshold)
  10. {
  11. var countObjective = 0;
  12. foreach (var objective in level.objectives)
  13. {
  14. if(objective.Actual < objective.target)
  15. {
  16. countObjective++;
  17. }
  18. }
  19. if (countObjective == level.objectives.Length)
  20. {
  21. SoundManager.Play(SoundEvent.scoreSummary_levelFailed);
  22. }
  23. return;
  24. }
  25. int score = GameDataManager.Instance.Score;
  26. if (score >= level.star1Threshold)
  27. {
  28. star1.Animate(0);
  29. }
  30. if (score >= level.star2Threshold)
  31. {
  32. star2.Animate(1);
  33. }
  34. if (score >= level.star3Threshold)
  35. {
  36. star3.Animate(2);
  37. }
  38. SoundManager.Play(SoundEvent.scoreSummary_levelPassed, 2);
  39. }
  40. }