UIRaceEnd.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. InGameScriptCS.Instance.EnergyAdd(100);
  48. NGUIMenuScript.Instance.startResumeGameCounter(true);
  49. InGameScriptCS.Instance.Resurected = false;
  50. Text_PauseCounter.Show();
  51. //Analitics.BrandIap();
  52. }
  53. private void OnCancel()
  54. {
  55. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.RaceEnd);
  56. InGameScriptCS.Instance.setupDeathMenu();
  57. hPlayerSidesColliderScriptCS.deactivateCollider(); //dont detect stumbles on death
  58. hPlayerFrontColliderScriptCS.deactivateCollider(); //dont detect stumbles on death
  59. InGameScriptCS.Instance.collidedWithObstacle(); //play the death scene
  60. }
  61. // Update is called once per frame
  62. void Update () {
  63. }
  64. }