1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- 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<ScreenBase>().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<UIPanel>().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<ScreenBase>().Hide();
- hInGameScriptCS.LaunchGameStart();
- }
- }
|