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

public class RepairAll : MonoBehaviour
{

    public static float EnginInteg = RepairableEngin.Integrity;
    public static float GeneratorInteg = RepairableGenerator.Integrity;
    public static float GravityInteg = RepairableGravity.Integrity;
    public static float LifeInteg = RepairableLifeSuport.Integrity;
    public static float ShipIntegrity = 100f;
    public int IntShipIntegrity = Mathf.RoundToInt(ShipIntegrity);

    public GameObject GameText;
    public GameObject Camera;

    public GameObject TextDisplay;

    // Start is called before the first frame update
    void Start()
    {
        GameText.GetComponent<TextMesh>().text = "";
    }

    // Update is called once per frame
    void Update()
    {
        EnginInteg = RepairableEngin.Integrity;
        GeneratorInteg = RepairableGenerator.Integrity;
        GravityInteg = RepairableGravity.Integrity;
        LifeInteg = RepairableLifeSuport.Integrity;
        ShipIntegrity = ((EnginInteg / 4) +(GeneratorInteg / 4)+(GravityInteg / 4)+(LifeInteg / 4));
        IntShipIntegrity = Mathf.RoundToInt(ShipIntegrity);
        TextDisplay.GetComponent<TextMesh>().text = "Ship Integrity: " + IntShipIntegrity + "%";

        if (IntShipIntegrity <= 50)
        {
            GameOver();
        }
    }

    public void GameOver()
    {
        GameText.GetComponent<TextMesh>().text = "Game Over!";
    }
}
