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(); timer.text = ""; } void OnEnable() { if (elementTransition==null) { elementTransition = GetComponent(); } 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); } }