void SetCargerFalse(Collider2D col)
    {
        countCargerAgain = 0;
        countStartFollow = 0;

        carger = false;

        dir  = Vector2.zero;
        toGo = Vector2.zero;

        anim.SetBool("Carger", carger);

        firstTime = false;

        if (col.CompareTag("Player"))
        {
            HealthPlayer healthPlayer = col.GetComponent <HealthPlayer>();
            healthPlayer.Damage(damage);
            GetComponent <AudioManagerEnemies>().PlayAudiosAttack();
            carger = false;
            if (healthPlayer.IsDead())
            {
                StartCoroutine(ResetPos());
            }
        }
        else
        {
            if (!hasFlipped)
            {
                Flip();
                hasFlipped = true;
            }
        }
    }
Example #2
0
    public void TeleportToTPVoid(int damage)
    {
        //EXPLICACION
        //Se llama desde Void.cs, cuando caes al vacio recibes 1 de daño
        //y te teletransportas a la posicion guardada al pasar por el checkpoint.

        hp.Damage(damage);
        transform.position = posTpVoid;
    }
 public void NoDamageShield(BulletType type)
 {
     if (data.baseStats.bulletType[currentType].Equals(type))
     {
         Debug.Log("No Damage");
         HealthPlayer player = FindObjectOfType <HealthPlayer>();
         player.Damage(0);
     }
     else
     {
         Debug.Log("Damage");
         HealthPlayer player = FindObjectOfType <HealthPlayer>();
         Bullet       bullet = FindObjectOfType <Bullet>();
         player.Damage(bullet.damage);
     }
 }
Example #4
0
    private void OnCollisionStay2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            //VARIABLES
            //Count: Contador de segundos
            //timeToDamagePlayer: Se le da el valor desde el inspector,
            //indica cada cuanto tiempo se le hará daño al player.

            //EXPLICACIÓN
            //Lo que se pretende es que cada 'X' segundos de estar encima
            //de una estalagmita, el jugador reciba 1 de daño.
            //De esta forma evitamos que el player se mantenga mucho tiempo encima.

            count += Time.deltaTime;
            if (count >= timeToDamagePlayer)
            {
                health.Damage(1);
                count = 0;
            }
        }
    }
Example #5
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Enemy"))
        {
            Debug.Log("Enemigo");

            Enemy enemy = other.GetComponent <Enemy>();
            if (enemy != null)
            {
                Debug.Log("Buuu");

                enemy.Damage(damage);
                Destroy(this.gameObject);
            }
        }

        if (other.CompareTag("Player"))
        {
            HealthPlayer player = other.GetComponent <HealthPlayer>();

            if (player != null)
            {
                player.Damage(damage);
                Destroy(this.gameObject);
            }
        }

        if (other.CompareTag("EnemyBullet"))
        {
            Destroy(other.gameObject);
            Destroy(this.gameObject);
        }
        else
        {
            Destroy(this.gameObject, 1f);
        }
    }
Example #6
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Vector2 pos = new Vector2(transform.position.x, transform.position.y - 50);

        Instantiate(VFX_destroy, pos, Quaternion.identity, null);
        if (collision.gameObject.CompareTag("Player"))
        {
            playerHealth.Damage(1);
            gameObject.SetActive(false);
        }
        if (collision.gameObject.CompareTag("Ground"))
        {
            gameObject.SetActive(false);
        }
        if (collision.gameObject.CompareTag("Enemy"))
        {
            if (collision.gameObject.TryGetComponent(out HealthEnemies h))
            {
                h.Damage(3);
            }
            gameObject.SetActive(false);
        }
        Destroy(gameObject, 1);
    }