UIGetCoupone.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using UnityEngine;
  2. using System.Collections;
  3. using System;
  4. public class UIGetCoupone : MonoBehaviour
  5. {
  6. public UIButton CloseButton;
  7. public UIButton ConsumeButton;
  8. public UILabel CodeCouponeLabel;
  9. public UITexture CouponeTexture;
  10. public UILabel TimeCoupone;
  11. void OnEnable()
  12. {
  13. }
  14. // Update is called once per frame
  15. void Start () {
  16. CloseButton.onClick.Add(new EventDelegate(OnClose));
  17. ConsumeButton.onClick.Add(new EventDelegate(OnConsume));
  18. }
  19. private void OnConsume()
  20. {
  21. CurCouponInfo.Consume(success =>
  22. {
  23. NGUIMenuScript.Instance.MessengerCoupone.gameObject.SetActive(true);
  24. if (success)
  25. {
  26. NGUIMenuScript.Instance.MessengerCoupone.OnSucceful();
  27. }
  28. else
  29. {
  30. NGUIMenuScript.Instance.MessengerCoupone.OnUnsucceful();
  31. }
  32. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Coupones);
  33. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.CouponeGet);
  34. });
  35. }
  36. private void OnClose()
  37. {
  38. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Coupones);
  39. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.CouponeGet);
  40. }
  41. private ServerGiftManager.CouponInfo CurCouponInfo;
  42. public void CouponeInit(ServerGiftManager.CouponInfo couponInfo)
  43. {
  44. CurCouponInfo = couponInfo;
  45. OnInit();
  46. }
  47. private void OnInit()
  48. {
  49. Debug.Log("OnInit");
  50. CodeCouponeLabel.text = "Kóði: " + CurCouponInfo.code;
  51. CurCouponInfo.GetTexture(OnGetTexture);
  52. TimeCoupone.text = "Gildir til: " + CurCouponInfo.expire;
  53. }
  54. private void OnGetTexture(Texture2D obj)
  55. {
  56. CouponeTexture.mainTexture = obj;
  57. }
  58. }