UIRaceEnd.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using UnityEngine;
  2. using System.Collections;
  3. public class UIRaceEnd : MonoBehaviour
  4. {
  5. [SerializeField]
  6. private UIButton [] Ok;
  7. [SerializeField]
  8. private UIButton Cancel;
  9. public UILabel Distance;
  10. public UILabel Packet;
  11. public UILabel Score;
  12. private PlayerSidesColliderScriptCS hPlayerSidesColliderScriptCS;
  13. private PlayerFrontColliderScriptCS hPlayerFrontColliderScriptCS;
  14. public ControllerScriptCS hControllerScriptCS;
  15. public PowerupsMainControllerCS hPowerupsMainControllerCS;
  16. // Use this for initialization
  17. void Start ()
  18. {
  19. hControllerScriptCS = (ControllerScriptCS)GameObject.Find("Player").GetComponent(typeof(ControllerScriptCS));
  20. hPowerupsMainControllerCS = (PowerupsMainControllerCS)GameObject.Find("Player").GetComponent(typeof(PowerupsMainControllerCS));
  21. for (int i = 0; i < Ok.Length; i++)
  22. {
  23. Ok[i].onClick.Add(new EventDelegate(OnOk));
  24. }
  25. //Cancel.onClick.Add(new EventDelegate(OnCancel));
  26. hPlayerSidesColliderScriptCS = (PlayerSidesColliderScriptCS)GameObject.Find("PlayerSidesCollider").GetComponent(typeof(PlayerSidesColliderScriptCS));
  27. hPlayerFrontColliderScriptCS = (PlayerFrontColliderScriptCS)GameObject.Find("PlayerFrontCollider").GetComponent(typeof(PlayerFrontColliderScriptCS));
  28. }
  29. private void OnEnable()
  30. {
  31. hControllerScriptCS = (ControllerScriptCS)GameObject.Find("Player").GetComponent(typeof(ControllerScriptCS));
  32. hPowerupsMainControllerCS = (PowerupsMainControllerCS)GameObject.Find("Player").GetComponent(typeof(PowerupsMainControllerCS));
  33. var dist = PlayerControllerLevels.Instance.AllDistance + (int) hControllerScriptCS.getCurrentMileage();
  34. var gifts = PlayerControllerLevels.Instance.AllGifts + (int)hPowerupsMainControllerCS.getCurrencyUnits();
  35. Distance.text = dist + "m";
  36. Packet.text = gifts.ToString();
  37. Score.text = ((int)(dist + (gifts * 3)+TooltipLastterController.Instance.PontWords)).ToString();
  38. }
  39. private void OnOk()
  40. {
  41. UIEnergy.Instance.Restore();
  42. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.RaceEnd);
  43. PlayerController.Instance.Alive();
  44. InGameScriptCS.Instance.InvokeResurrection();
  45. hPlayerSidesColliderScriptCS.InvokeResurrection();
  46. hPlayerFrontColliderScriptCS.InvokeResurrection();
  47. NGUIMenuScript.Instance.startResumeGameCounter(true);
  48. Text_PauseCounter.Show();
  49. //Analitics.BrandIap();
  50. }
  51. private void OnCancel()
  52. {
  53. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.RaceEnd);
  54. InGameScriptCS.Instance.setupDeathMenu();
  55. hPlayerSidesColliderScriptCS.deactivateCollider(); //dont detect stumbles on death
  56. hPlayerFrontColliderScriptCS.deactivateCollider(); //dont detect stumbles on death
  57. InGameScriptCS.Instance.collidedWithObstacle(); //play the death scene
  58. }
  59. // Update is called once per frame
  60. void Update () {
  61. }
  62. }