StartLevelMessage.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. using System.Linq;
  5. public class StartLevelMessage : MonoBehaviour {
  6. public UILabel Distance;
  7. public UILabel Gifts;
  8. public Transform DistanceGroup;
  9. public Transform GiftsGroup;
  10. public UILabel InfoEndGame;
  11. public UILabel InfoOtherGame;
  12. public UIButton CloseButton;
  13. public AchivmentController AchivmentController;
  14. void Awake()
  15. {
  16. StartCoroutine(AlphaActive());
  17. GetComponent<ScreenBase>().Hide();
  18. CloseButton.onClick.Add(new EventDelegate(OnClose));
  19. hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
  20. }
  21. public IEnumerator AlphaActive()
  22. {
  23. yield return new WaitForSeconds(0.5f);
  24. GetComponent<UIPanel>().alpha = 1;
  25. }
  26. public void OnEnable()
  27. {
  28. //Debug.Log(PlayerPrefs.GetInt("Level"));
  29. if (PlayerPrefs.GetInt("Level") - 1 < AchivmentController.Levels.Count())
  30. {
  31. SetValue(AchivmentController.Levels[PlayerPrefs.GetInt("Level") - 1]);
  32. }
  33. else
  34. {
  35. SetValue(AchivmentController.Levels[AchivmentController.Levels.Count()-1]);
  36. }
  37. }
  38. private void SetValue(AchivmentController.Level level)
  39. {
  40. if(PlayerPrefs.GetInt("Level") == 3)
  41. {
  42. DistanceGroup.gameObject.SetActive(false);
  43. GiftsGroup.gameObject.SetActive(false);
  44. InfoEndGame.gameObject.SetActive(true);
  45. InfoOtherGame.gameObject.SetActive(false);
  46. }
  47. else
  48. {
  49. DistanceGroup.gameObject.SetActive(true);
  50. GiftsGroup.gameObject.SetActive(true);
  51. InfoEndGame.gameObject.SetActive(false);
  52. Distance.text = level.MinMeters.ToString();
  53. Gifts.text = level.Gifts.ToString();
  54. InfoOtherGame.gameObject.SetActive(true);
  55. }
  56. }
  57. private InGameScriptCS hInGameScriptCS;
  58. private void OnClose()
  59. {
  60. GetComponent<ScreenBase>().Hide();
  61. hInGameScriptCS.LaunchGameStart();
  62. }
  63. }