using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DroneSelectionController : MonoBehaviour {
    public DroneController dc;
    UnityEngine.UI.Text text;
    UnityEngine.UI.Button button;

    public void Start()
    {
        text = GetComponentInChildren<UnityEngine.UI.Text>();
        button = GetComponentInChildren<UnityEngine.UI.Button>();
    }

    public void OnClick()
    {
        if (dc == null)
            return;
        DroneController.active = dc;
    }

    public void Update()
    {
        if (dc == null)
            return;
        var world = Game.instance.worlds[World.GetWorldIndex(dc.transform.position)].world;

        string worldName;
        if (world == null)
            worldName = " ";
        else
            worldName = world.name;

        text.text = dc.name + "|" + worldName + "|" + dc.joules + "kJ";

        if (dc.joules <= 0)
        {
            button.enabled = false;
            text.color = Color.gray;
        }
        else
            text.color = Color.white;
    }
}
