Пример #1
0
 private void Start()
 {
     FullHealth.SetActive(false);
     ThreeFourths.SetActive(false);
     HalfHealth.SetActive(false);
     OneFourth.SetActive(false);
     ZeroHealth.SetActive(false);
 }
Пример #2
0
 void Update()
 {
     // Check for players current health
     // Players current health is 100%
     if (PlayerHealth.Value <= 1.0f && PlayerHealth.Value >= 0.76f)
     {
         FullHealth.SetActive(true);
         ThreeFourths.SetActive(false);
         HalfHealth.SetActive(false);
         OneFourth.SetActive(false);
         ZeroHealth.SetActive(false);
     }
     // Players health is below 76%, check to see where it falls
     if (PlayerHealth.Value <= 0.75f)
     {
         FullHealth.SetActive(false);
         HalfHealth.SetActive(false);
         OneFourth.SetActive(false);
         ZeroHealth.SetActive(false);
         ThreeFourths.SetActive(true);
         if (PlayerHealth.Value <= 0.5f)             //Less than 51% health
         {
             FullHealth.SetActive(false);
             ThreeFourths.SetActive(false);
             OneFourth.SetActive(false);
             ZeroHealth.SetActive(false);
             HalfHealth.SetActive(true);
             if (PlayerHealth.Value <= 0.25f)                 //Less than 26% health
             {
                 FullHealth.SetActive(false);
                 ThreeFourths.SetActive(false);
                 HalfHealth.SetActive(false);
                 ZeroHealth.SetActive(false);
                 OneFourth.SetActive(true);
                 if (PlayerHealth.Value <= 0.0f)                     //Less than 1% health
                 {
                     FullHealth.SetActive(false);
                     ThreeFourths.SetActive(false);
                     HalfHealth.SetActive(false);
                     OneFourth.SetActive(false);
                     ZeroHealth.SetActive(true);
                 }
             }
         }
     }
 }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        damageTaken = false;

        currentCount = maxInvinceTime;

        healthBar.maxValue = maxHealth;
        healthBar.value    = maxHealth;
        currentHealth      = maxHealth;


        //Player states
        deadHealthState    = this.GetComponent <Dead>();
        fullHealthState    = this.GetComponent <FullHealth>();
        halfHealthState    = this.GetComponent <HalfHealth>();
        quarterHealthState = this.GetComponent <QuarterHealth>();

        currentHealthState = fullHealthState;

        currentHealthState.ChangeMovementParticle();

        gm = FindObjectOfType <GameManager>();
    }