using UnityEngine; using System.Collections; public class UIRaceEnd : MonoBehaviour { [SerializeField] private UIButton [] Ok; [SerializeField] private UIButton Cancel; public UILabel Distance; public UILabel Packet; public UILabel Score; private PlayerSidesColliderScriptCS hPlayerSidesColliderScriptCS; private PlayerFrontColliderScriptCS hPlayerFrontColliderScriptCS; public ControllerScriptCS hControllerScriptCS; public PowerupsMainControllerCS hPowerupsMainControllerCS; // Use this for initialization void Start () { hControllerScriptCS = (ControllerScriptCS)GameObject.Find("Player").GetComponent(typeof(ControllerScriptCS)); hPowerupsMainControllerCS = (PowerupsMainControllerCS)GameObject.Find("Player").GetComponent(typeof(PowerupsMainControllerCS)); for (int i = 0; i < Ok.Length; i++) { Ok[i].onClick.Add(new EventDelegate(OnOk)); } //Cancel.onClick.Add(new EventDelegate(OnCancel)); hPlayerSidesColliderScriptCS = (PlayerSidesColliderScriptCS)GameObject.Find("PlayerSidesCollider").GetComponent(typeof(PlayerSidesColliderScriptCS)); hPlayerFrontColliderScriptCS = (PlayerFrontColliderScriptCS)GameObject.Find("PlayerFrontCollider").GetComponent(typeof(PlayerFrontColliderScriptCS)); } private void OnEnable() { hControllerScriptCS = (ControllerScriptCS)GameObject.Find("Player").GetComponent(typeof(ControllerScriptCS)); hPowerupsMainControllerCS = (PowerupsMainControllerCS)GameObject.Find("Player").GetComponent(typeof(PowerupsMainControllerCS)); var dist = PlayerControllerLevels.Instance.AllDistance + (int) hControllerScriptCS.getCurrentMileage(); var gifts = PlayerControllerLevels.Instance.AllGifts + (int)hPowerupsMainControllerCS.getCurrencyUnits(); Distance.text = dist + "m"; Packet.text = gifts.ToString(); Score.text = ((int)(dist + (gifts * 3)+TooltipLastterController.Instance.PontWords)).ToString(); } private void OnOk() { UIEnergy.Instance.Restore(); NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.RaceEnd); PlayerController.Instance.Alive(); InGameScriptCS.Instance.InvokeResurrection(); hPlayerSidesColliderScriptCS.InvokeResurrection(); hPlayerFrontColliderScriptCS.InvokeResurrection(); InGameScriptCS.Instance.EnergyAdd(100); NGUIMenuScript.Instance.startResumeGameCounter(true); InGameScriptCS.Instance.Resurected = false; Text_PauseCounter.Show(); //Analitics.BrandIap(); } private void OnCancel() { NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.RaceEnd); InGameScriptCS.Instance.setupDeathMenu(); hPlayerSidesColliderScriptCS.deactivateCollider(); //dont detect stumbles on death hPlayerFrontColliderScriptCS.deactivateCollider(); //dont detect stumbles on death InGameScriptCS.Instance.collidedWithObstacle(); //play the death scene } // Update is called once per frame void Update () { } }