Exemplo n.º 1
0
 void Start()
 {
     health = 4;
     Heart1.SetActive(true);
     Heart2.SetActive(true);
     Heart3.SetActive(true);
     Heart4.SetActive(true);
     gameOver.SetActive(false);
     Restart.SetActive(false);
     MainMenu.SetActive(false);
     Quit.SetActive(false);
 }
    //everytime the player gets hit a hearth is gone
    void Update()
    {
        if (health > 4)
        {
            health = 4;
        }
        switch (health)
        {
        case 4:
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(true);
            Heart4.SetActive(true);
            break;

        case 3:
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(true);
            Heart4.SetActive(false);
            break;

        case 2:
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
            break;

        case 1:
            Heart1.SetActive(true);
            Heart2.SetActive(false);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
            break;

        case 0:
            Heart1.SetActive(false);
            Heart2.SetActive(false);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
            // UI interface when the game is over
            gameOver.SetActive(true);
            Restart.SetActive(true);
            MainMenu.SetActive(true);
            MainMenu.SetActive(true);
            Time.timeScale = 0;
            health         = 4;
            break;
        }
    }
Exemplo n.º 3
0
    void RestarVida(int vida)
    {
        Rigidbody rb = this.GetComponent <Rigidbody>();

        if (vida == 1)
        {
            Heart1.SetActive(false);
            rb.velocity = new Vector3(0.0f, 0.0f, 0.0f);
            PlayerController.balaAgarrada = false;
        }
        else if (vida == 2)
        {
            Heart2.SetActive(false);
            rb.velocity = new Vector3(0.0f, 0.0f, 0.0f);
            PlayerController.balaAgarrada = false;
        }
        else if (vida == 3)
        {
            Heart3.SetActive(false);
            rb.velocity = new Vector3(0.0f, 0.0f, 0.0f);
            PlayerController.balaAgarrada = false;
        }
        else if (vida == 4)
        {
            Heart4.SetActive(false);
            rb.velocity = new Vector3(0.0f, 0.0f, 0.0f);
            Player2Controller.balaAgarrada = false;
        }
        else if (vida == 5)
        {
            Heart5.SetActive(false);
            rb.velocity = new Vector3(0.0f, 0.0f, 0.0f);
            Player2Controller.balaAgarrada = false;
        }
        else if (vida == 6)
        {
            Heart6.SetActive(false);
            rb.velocity = new Vector3(0.0f, 0.0f, 0.0f);
            Player2Controller.balaAgarrada = false;
        }
    }
Exemplo n.º 4
0
    private void Update()
    {
        switch (health)
        {
        case 0:
            Heart1.SetActive(false);
            Heart2.SetActive(false);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
            break;

        case 1:
            Heart1.SetActive(true);
            Heart2.SetActive(false);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
            break;

        case 2:
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
            break;

        case 3:
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(true);
            Heart4.SetActive(false);
            break;

        case 4:
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(true);
            Heart4.SetActive(true);
            break;
        }
    }
Exemplo n.º 5
0
    public void UpdateHealth(int currentHealth, int maxHealth)
    {
        float percentage = currentHealth / (float)maxHealth;

        if (percentage >= 1f)
        {
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(true);
            Heart4.SetActive(true);
        }
        else if (percentage >= 0.75f)
        {
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(true);
            Heart4.SetActive(false);
        }
        else if (percentage >= 0.5f)
        {
            Heart1.SetActive(true);
            Heart2.SetActive(true);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
        }
        else if (percentage >= 0.25f)
        {
            Heart1.SetActive(true);
            Heart2.SetActive(false);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
        }
        else
        {
            Heart1.SetActive(false);
            Heart2.SetActive(false);
            Heart3.SetActive(false);
            Heart4.SetActive(false);
        }
    }