using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;


public class lifes : MonoBehaviour

{

   public Button bt;

   public Slider HP;  //实例化一个Slider

   private bool b;

   public GameObject fraction;


   // Start is called before the first frame update

   void Start()

   {

       HP.value = 10000;

       b = true;

   }


   // Update is called once per frame

   void Update()

   {

       if (b = true)

       {

           if (HP.value != 0)

           {

               HP.value = HP.value - 5;

               if (fraction != null)

               {

                   if (fraction.gameObject.activeSelf == true)

                   {

                       if (Time.frameCount % 20 == 0)

                       {

                           HP.value = HP.value - 1000;

                       }

                   }

               }

           }

       }

   }


   public void OnClickBt(GameObject Button)

   {

       GameObject.Find("ButtonPause").GetComponent<lifes>().enabled = false;

   }


   public void start()

   {

       GameObject.Find("ButtonPause").GetComponent<lifes>().enabled = true;

   }


   public void up()

   {

       HP.value = HP.value + 1000;

   }

}