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(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; } }