Esempio n. 1
0
    public void TakeDamage(int damage) //funcion que te reduce la vida respecto al danyo que recibes
    {
        if (extraHealth <= 0)
        {
            currentHealth = currentHealth - damage;  // vida actual - el danyo que te hacen
            if (currentHealth <= 0)
            {
                currentHealth = 0;
            }
        }
        else
        {
            extraHealth -= damage;
            if (extraHealth < 0)
            {
                currentHealth += extraHealth;
                extraHealth    = 0;
            }
        }

        healthBar.SetCurrentHealth(currentHealth);
        extraHealthBar.setCurrentHealth(extraHealth);

        rodySoundsManager.prepararSonido(1);
        animatorHandler.PlayTargetAnimation("Damage_01", true); //activar animacion de danyo
        if (currentHealth <= 0)
        {
            rodySoundsManager.prepararSonido(0);
            animatorHandler.PlayTargetAnimation("Dead_01", true);
            if (SceneManager.GetActiveScene().name.Equals("nivel1"))
            {
                ScenesStaticClass.deadInNivel1();
            }
            else if (SceneManager.GetActiveScene().name.Equals("arena_nyapos"))
            {
                ScenesStaticClass.deadInArenaNyapos();
            }
            SceneManager.LoadScene("GameOver");
        }
    }
Esempio n. 2
0
    private void Update()
    {
        if (extraHealthActive)
        {
            timer += Time.deltaTime;
            if (timer > extraHealthSpeed)
            {
                extraHealth--;
                extraHealthBar.setCurrentHealth(extraHealth);
                timer = 0;
            }
            if (extraHealth <= 0)
            {
                extraHealth       = 0;
                extraHealthActive = false;
            }
        }

        if (contadorMonedasActive)
        {
            timerMonedas += Time.deltaTime;
            if (timerMonedas > tiempoContadorMonedasActivo)
            {
                BarraMonedas.SetActive(false);
                timerMonedas = 0;
            }
        }

        if (FLAGcontadorMonedasActive)
        {
            timerMonedas              = 0;
            contadorMonedasActive     = true;
            FLAGcontadorMonedasActive = false;
        }

        if (FLAGcontadorMonedasActive)
        {
            timerMonedas              = 0;
            contadorMonedasActive     = true;
            FLAGcontadorMonedasActive = false;
        }

        if (FLAGGuende)
        {
            timerGuende += Time.deltaTime;
            if (timerGuende < 20)
            {
                staminaRegenTimer = 0;
                timerInf         += Time.deltaTime;
                if (timerInf >= infectionSpeed)
                {
                    if (extraHealth <= 0)
                    {
                        currentHealth -= vidaGuende;               // vida actual - el danyo que te hacen

                        healthBar.SetCurrentHealth(currentHealth); // actualizar la salud
                        if (currentHealth <= 0)
                        {
                            currentHealth = 0;
                        }
                    }
                    else
                    {
                        extraHealth -= vidaGuende;
                        if (extraHealth < 0)
                        {
                            extraHealth = 0;
                        }
                        healthBar.SetCurrentHealth(currentHealth);
                        extraHealthBar.setCurrentHealth(extraHealth);
                    };

                    if (currentHealth <= 0)
                    {
                        rodySoundsManager.prepararSonido(0);
                        animatorHandler.PlayTargetAnimation("Dead_01", true);
                        if (SceneManager.GetActiveScene().name.Equals("nivel1"))
                        {
                            ScenesStaticClass.deadInNivel1();
                        }
                        else if (SceneManager.GetActiveScene().name.Equals("arena_nyapos"))
                        {
                            ScenesStaticClass.deadInArenaNyapos();
                        }
                        SceneManager.LoadScene("GameOver");
                    }
                    timerInf = 0;
                }
            }
            else
            {
                vidaGuende  = 0;
                timerGuende = 0;
                playerLocomotion.movementSpeed = normalSpeed;
                playerLocomotion.sprintSpeed   = rollSpeed;
                FLAGGuende = false;
            }
        }

        if (FLAGFuego)
        {
            if (fireClone != null)
            {
                fireClone.transform.position = transform.position;
            }
            else
            {
                fireClone = GameObject.Find("ParticleFire(Clone)");
            }
            timerFuego += Time.deltaTime;
            if (timerFuego > 60)
            {
                Destroy(fireClone);
                extraFireDamage = 0;
                FLAGFuego       = false;
            }
        }
    }