using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; public class ShopPanel : PopUpPanel { public GameObject itemPrefab; public RectTransform container; private List dataList; private const int countPrePage = 10; private int totalPage; private int currentPage; private BuyUtil.ItemType itemType = BuyUtil.ItemType.None; void Awake() { currentPanel = this; } void OnDestroy() { currentPanel = null; HaloManager.GetInstance().SyncEquipId(); } // Use this for initialization void OnDisable () { // ShowItemList(itemType); HaloManager.GetInstance().SyncEquipId(); } public void ShowItemList(BuyUtil.ItemType itemType) { if(this.itemType == BuyUtil.ItemType.Halo) HaloManager.GetInstance().SyncEquipId(); this.itemType = itemType; if(itemType == BuyUtil.ItemType.Halo) { InitHaloData(); } } private void InitHaloData() { HaloManager.GetInstance().RecordStartEquipId(); HaloManager.GetInstance().RequestDataList(()=>{ List list = HaloManager.GetInstance().GetDataList(); dataList = new List(); for(int i=0; i(); } else if(data != null) { GameObject itemObj = Instantiate(itemPrefab); PopUpManager.AddToMainCanvas(itemObj, container); item = itemObj.GetComponent(); } if(data == null && item != null) { item.gameObject.SetActive(false); } else if(data != null) { item.gameObject.SetActive(true); item.Init(data); } } } // public void OnValueChange(Vector2 pos) // { // Debuger.Log(pos); // scrollbar.value = 0; // } public void UpdateInfo() { for(int i=0; i().UpdatePrice(); } } public static ShopPanel currentPanel; public static ShopPanel Show() { if(currentPanel != null) { PopUpManager.AddToMainCanvas(currentPanel.gameObject); return currentPanel; } GameObject panelObj = GameObject.Instantiate(Resources.Load("Prefabs/UI/Shop/ShopPanel")); panelObj.GetComponent(); PopUpManager.AddToMainCanvas(panelObj); return currentPanel; } public static void Hide() { if(currentPanel != null) currentPanel.Close(); } public static void Refresh() { if(currentPanel != null) { currentPanel.UpdateInfo(); } } }