12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using UnityEngine;
- using System.Collections;
- using System;
- public class UIGetCoupone : MonoBehaviour
- {
- public UIButton CloseButton;
- public UIButton ConsumeButton;
- public UILabel CodeCouponeLabel;
- public UITexture CouponeTexture;
- public UILabel TimeCoupone;
- void OnEnable()
- {
-
- }
-
- // Update is called once per frame
- void Start () {
- CloseButton.onClick.Add(new EventDelegate(OnClose));
- ConsumeButton.onClick.Add(new EventDelegate(OnConsume));
- }
- private void OnConsume()
- {
- CurCouponInfo.Consume(success =>
- {
- NGUIMenuScript.Instance.MessengerCoupone.gameObject.SetActive(true);
- if (success)
- {
- NGUIMenuScript.Instance.MessengerCoupone.OnSucceful();
- }
- else
- {
- NGUIMenuScript.Instance.MessengerCoupone.OnUnsucceful();
- }
- NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Coupones);
- NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.CouponeGet);
- });
- }
- private void OnClose()
- {
- NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Coupones);
- NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.CouponeGet);
- }
- private ServerGiftManager.CouponInfo CurCouponInfo;
- public void CouponeInit(ServerGiftManager.CouponInfo couponInfo)
- {
- CurCouponInfo = couponInfo;
- OnInit();
- }
- private void OnInit()
- {
- Debug.Log("OnInit");
- CodeCouponeLabel.text = "Kóði: " + CurCouponInfo.code;
- CurCouponInfo.GetTexture(OnGetTexture);
- TimeCoupone.text = "Gildir til: " + CurCouponInfo.expire;
- }
- private void OnGetTexture(Texture2D obj)
- {
- CouponeTexture.mainTexture = obj;
- }
- }
|