using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class HangarPanel : DetailsPanel
{
    public AttributePanel sterlings;
    public AttributePanel fuel;
    public AttributePanel location;
    public AttributePanel cargo;
    public TMP_Text fuelRate;
    public TMP_Text fuelTotal;
    public Button refuelButton;
    public TMP_Text fullTank;

    // Update is called once per frame
    void Update()
    {
        sterlings.SetValue(airship.sterlings.ToString());
        fuel.SetValue(airship.CurrentFuel().ToString() + "/" + airship.maxFuel.ToString() + " tonnes");
        location.SetValue(LocationString());
        cargo.SetValue(airship.CurrentCargo().ToString() + "/" + airship.cargoCapacity.ToString() + " tonnes");
        fuelRate.text = "£" + airship.location.FuelRate() + " per tonne";

        if (airship.fuel < airship.maxFuel)
        {
            refuelButton.gameObject.SetActive(true);
            fuelTotal.gameObject.SetActive(true);
            fullTank.gameObject.SetActive(false);
            fuelTotal.text = "£" + airship.RefuelCost() + " total";
        } else
        {
            refuelButton.gameObject.SetActive(false);
            fuelTotal.gameObject.SetActive(false);
            fullTank.gameObject.SetActive(true);
        }
        
        
    }

    string LocationString()
    {
        return airship.location.cityName + " Hangar";
    }

    public void Refuel()
    {
        airship.Refuel();
    }

    public override void Activate()
    {
        if (FindObjectOfType<Airship>().location != null)
        {
            base.Activate();
        }
    }
}
