12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.Collections.Generic;
- using JsonFx.Json;
- using UnityEngine;
- using System.Collections;
- public class TimerAd : MonoBehaviour
- {
- public int StartTimer = 8;
- public float Timer = 8;
- public UILabel timer;
- public UILabel text;
- public UILabel textFact;
- private NGUIMenuScript hNGUIMenuScript;
- private UIElementTransition elementTransition;
- private SoundManagerCS hSoundManagerCS;
- private InGameScriptCS hInGameScriptCS;
- void Start ()
- {
- hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
- hSoundManagerCS = (SoundManagerCS)GameObject.Find("SoundManager").GetComponent(typeof(SoundManagerCS));
- hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
- elementTransition = GetComponent<UIElementTransition>();
- timer.text = "";
- }
-
- void OnEnable()
- {
- if (elementTransition==null)
- {
- elementTransition = GetComponent<UIElementTransition>();
- }
-
- elementTransition.Show();
- Timer = StartTimer;
- }
- void Update ()
- {
- Timer = Timer - Time.deltaTime;
- if(Timer <= 0)
- {
- Timer = 0;
- StartCoroutine(SetActiveElement());
-
- if (AdManager.Instance.SmokeCam != null)
- {
- AdManager.Instance.SmokeCam.enabled = (true);
- }
-
-
-
- }
- timer.text = ((int)Timer).ToString();
- //text.text = string.Format(Localization.instance.Get("ad.label.text"), LevelsManager.Instance.CurrentLevelIndex + 1);
- }
- private IEnumerator SetActiveElement()
- {
- yield return new WaitForSeconds(0);
- //hSoundManagerCS.toggleSoundEnabled(true);
- //hSoundManagerCS.toggleMusicEnabled(true);
- hNGUIMenuScript.CloseMenu(NGUIMenuScript.NGUIMenus.Banner);
- if (!InstructionButtonHandler.FirstPlay)
- {
- NGUIMenuScript.Instance.CurStatePopup = NGUIMenuScript.StatesMenuForPopup.None;
- hInGameScriptCS.launchGame();
-
- }
- else
- {
- NGUIMenuScript.Instance.CurStatePopup = NGUIMenuScript.StatesMenuForPopup.None;
- hInGameScriptCS.launchGame();
- }
- NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.RaceStart);
- }
- }
|