using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; public class UAVPanel : PopUpPanel { public Transform equipContainer; public EquipIcon equipItemPrefab; public EquipInfo equipInfo; private EquipedData equipedData; void Awake() { ListHelper.HideAll (equipContainer); equipItemPrefab.uavPanel = this; equipInfo.uavPanel = this; Shown (); } protected override void Shown () { EquipManager.GetInstance ().InventoryUpdate.AddListener (OnInventoryUpdate); EquipManager.GetInstance ().RequestInventory (); } private void OnInventoryUpdate() { EquipManager.GetInstance ().InventoryUpdate.RemoveListener (OnInventoryUpdate); List list = UAVManager.GetInstance ().GetInventoryList (); ListHelper.FillList (equipContainer, list, equipItemPrefab); if (list.Count > 0) SelectEquip (equipItemPrefab); else SelectEquip (null); } public void SelectEquip(EquipIcon icon) { ButtonUtil.TabSelected (icon, equipContainer); if (icon != null) { ShowEquipInfo (icon.data as Equipment); } else { ShowEquipInfo (null); } } private void ShowEquipInfo(Equipment equipment) { equipInfo.SetEquip (equipment); } public void Equip(Equipment equip) { UAVItem uavItem = UAVManager.GetInstance ().GetUAVItem (equip.GetData ().id); UAVManager.GetInstance ().SetEquipedItem (uavItem); List list = UAVManager.GetInstance ().GetInventoryList (); ListHelper.FillList (equipContainer, list, equipItemPrefab); ShowEquipInfo (equip); } public bool IsEquiped(Equipment equip) { UAVItem uavItem = UAVManager.GetInstance ().GetEquipedItem (); if(uavItem != null && uavItem.GetEquipment () == equip) return true; return false; } private static UAVPanel currentPanel; public static UAVPanel Show() { if (currentPanel != null) { currentPanel.gameObject.SetActive (true); PopUpManager.AddToMainCanvas (currentPanel.gameObject); } else currentPanel = PopUpManager.AddPopUp (Resources.Load ("Prefabs/UI/UAVPanel/UAVPanel"), null, true); currentPanel.Open (); return currentPanel; } }