1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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<Equipment> list = UAVManager.GetInstance ().GetInventoryList ();
- ListHelper.FillList<Equipment> (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<Equipment> list = UAVManager.GetInstance ().GetInventoryList ();
- ListHelper.FillList<Equipment> (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<UAVPanel> (Resources.Load<GameObject> ("Prefabs/UI/UAVPanel/UAVPanel"), null, true);
- currentPanel.Open ();
- return currentPanel;
- }
- }
|