StartLevelMessage.cs 2.2 KB

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