private void AdjustGreenBarsToHP()
    {
        float share = player.GetCurrentHP() / player.GetMaxHP();

        foreach (RectTransform health_bar in green_health_bars)
        {
            health_bar.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, share * screen_height);
        }
    }
Exemple #2
0
 //called every frame
 void Update()
 {
     //if the man dies, destroy all invaders
     manHPLeft = manHP.GetMaxHP();
     if (manHPLeft == 0)
     {
         StartCoroutine(wait.waitFor(0.1F));
         destroyAllInvaders(true, false);
     }
 }
    //shield sprites have 3 states, depending on the amount of damage taken
    private void checkForSpriteChange()
    {
        switch (damagable.GetMaxHP())
        {
        case 3:
            spriteRend.sprite = sprites[0];
            break;

        case 2:
            spriteRend.sprite = sprites[1];
            break;

        case 1:
            spriteRend.sprite = sprites[2];
            break;
        }
    }
Exemple #4
0
    //depending on the amount of lives left, destroy the life shown for it
    private void checkLives()
    {
        switch (d.GetMaxHP())
        {
        case 2:
            Destroy(lives[2]);
            break;

        case 1:
            Destroy(lives[1]);
            break;

        case 0:
            Destroy(lives[0]);
            break;
        }
    }