using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class HealthSubmarine : MonoBehaviour {


    public static int HealthPoints;
    public Text HPdisplayed;
    public Text difficulte;
    public GameObject submarine;
    public static bool touched = false;
    public static bool mtouched = false;

	// Use this for initialization
	void Start () {
        HealthPoints = 100;
    }
	
	// Update is called once per frame
	void Update () {

        
        HPdisplayed.text = HealthPoints + "%";

        GererVie();
        
        
        if(HealthPoints<=0)
        {
            Destroy(LoadLevel.instance.parent);
            Destroy(LoadLevel.instance.parentsub);
            StateMachine.instance.SetState(STATE.GAMEOVER);
            
        }       

	}

    public void GererVie()
    {
        if (touched)
        {
            if (difficulte.text == "Facile")
            {
                HealthPoints -= 10;
            }

            if (difficulte.text == "Normale")
            {
                HealthPoints -= 25;
            }

            if (difficulte.text == "Difficile")
            {
                HealthPoints -= 50;
            }

        }

        if (mtouched)
        {
            if (difficulte.text == "Facile")
            {
                HealthPoints -= 20;
            }

            if (difficulte.text == "Normale")
            {
                HealthPoints -= 50;
            }

            if (difficulte.text == "Difficile")
            {
                HealthPoints -= 100;
            }

        }
        touched = false;
        mtouched = false;
    }

    
}
