using UnityEngine; using System.Collections; using System; using System.Linq; public class StartLevelMessage : MonoBehaviour { public UILabel Distance; public UILabel Gifts; public Transform DistanceGroup; public Transform GiftsGroup; public UILabel InfoEndGame; public UILabel InfoOtherGame; public UIButton CloseButton; public AchivmentController AchivmentController; void Awake() { StartCoroutine(AlphaActive()); GetComponent().Hide(); CloseButton.onClick.Add(new EventDelegate(OnClose)); hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS)); } public IEnumerator AlphaActive() { yield return new WaitForSeconds(0.5f); GetComponent().alpha = 1; } public void OnEnable() { //Debug.Log(PlayerPrefs.GetInt("Level")); if (PlayerPrefs.GetInt("Level") - 1 < AchivmentController.Levels.Count()) { SetValue(AchivmentController.Levels[PlayerPrefs.GetInt("Level") - 1]); } else { SetValue(AchivmentController.Levels[AchivmentController.Levels.Count()-1]); } } private void SetValue(AchivmentController.Level level) { if(PlayerPrefs.GetInt("Level") == 3) { DistanceGroup.gameObject.SetActive(false); GiftsGroup.gameObject.SetActive(false); InfoEndGame.gameObject.SetActive(true); InfoOtherGame.gameObject.SetActive(false); } else { DistanceGroup.gameObject.SetActive(true); GiftsGroup.gameObject.SetActive(true); InfoEndGame.gameObject.SetActive(false); Distance.text = level.MinMeters.ToString(); Gifts.text = level.Gifts.ToString(); InfoOtherGame.gameObject.SetActive(true); } } private InGameScriptCS hInGameScriptCS; private void OnClose() { GetComponent().Hide(); hInGameScriptCS.LaunchGameStart(); } }