123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- using System.Collections.Generic;
- public class ShopItem : MonoBehaviour
- {
- public enum PayType
- {
- Money = 0,
- Coin = 1,
- }
- private static System.Array payTypeArr = System.Enum.GetValues(typeof(PayType));
- public static PayType GetPayTypeByCode(int code)
- {
- return (PayType)payTypeArr.GetValue(code);
- }
- public enum Sort
- {
- None = 0,
- VIP = 1,
- Crystal = 2,
- Cube = 3
- }
- private static System.Array sortArr = System.Enum.GetValues(typeof(Sort));
- public static Sort GetSortByCode(int code)
- {
- return (Sort)sortArr.GetValue (code);
- }
- public enum Platform
- {
- All = 0,
- Android = 1,
- IOS = 2,
- }
- private static System.Array platformArr = System.Enum.GetValues(typeof(Platform));
- public static Platform GetPlatformByCode(int code)
- {
- return (Platform)platformArr.GetValue(code);
- }
- public Text nameTxt;
- public Text descTxt;
- public Text priceTxt;
- public Image icon;
- public ShopPanel shopPanel;
- private ShopData data;
- private PayType type;
- private Platform platform;
- void OnEnable()
- {
- Refresh();
- }
- public void SetData(ShopData data)
- {
- this.data = data;
- if(data == null)
- return;
- type = GetPayTypeByCode(data.type);
- nameTxt.text = GetName();
- descTxt.text = GetDescription();
- priceTxt.text = Language.GetStr("Shop", "RMB")+GetPrice()+".00";
- string path = "Textures/ShopIcon/"+GetIcon();
- Sprite sprite = Resources.Load<Sprite>(path);
- icon.sprite = sprite;
- platform = GetPlatformByCode(data.platform);
- // if(Application.platform == RuntimePlatform.Android)
- // {
- // if(!ExistPlatform(Platform.Android))
- // gameObject.SetActive(false);
- // }
- // else if(Application.platform == RuntimePlatform.IPhonePlayer)
- // {
- // if(!ExistPlatform(Platform.IOS))
- // gameObject.SetActive(false);
- // }
- UserData userData = Session.GetInstance().myUserData;
- if(userData.IsVIP())
- {
- if(data.code.Contains("VIP"))
- {
- gameObject.SetActive(false);
- }
- }
- }
- public void Refresh()
- {
- SetData(data);
- }
- public int GetId()
- {
- return data.id;
- }
- public string GetName()
- {
- return data.name;
- }
- public string GetDescription()
- {
- return data.description;
- }
- public string GetCode()
- {
- return data.code;
- }
- public string GetPrice()
- {
- return data.price;
- }
-
- public PayType GetPayType()
- {
- return type;
- }
- public string GetIcon()
- {
- if(StringUtil.Empty(data.icon))
- return data.code;
- return data.icon;
- }
- }
|