private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.name == "Player")
     {
         //levelManager.RespawnPlayer();
         healthManager.DamagePlayer(healthManager.maxHealth);
     }
 }
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("HurtBox") && !StaticVars.invincible && StaticVars.alive)
     {
         StaticVars.invincible = true;
         Vector2 hitDirection = other.transform.position - transform.position;
         hitDirection = hitDirection.normalized;
         health.DamagePlayer(damageAmount, hitDirection, knockBackForce);
         Instantiate(damageParticles, StaticVars.player.transform.position, StaticVars.player.transform.rotation);
     }
 }
Beispiel #3
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.name == "Player")
     {
         HealthManager.DamagePlayer(damageToDeal);
         var player = other.GetComponent <PlayerController>();
         player.knockbackCount = player.knockbackLength;
         if (other.transform.position.x < transform.position.x)
         {
             player.knockFromRight = true;
         }
         else
         {
             player.knockFromRight = false;
         }
     }
 }
Beispiel #4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.name == "Player")
        {
            healthManager.DamagePlayer(damageToGive);

            PlayerController player = collision.GetComponent <PlayerController>();
            player.knockbackCount = player.knockbackLength;

            if (collision.transform.position.x < transform.position.x)
            {
                player.knockFromRight = true;
            }
            else
            {
                player.knockFromRight = false;
            }
        }
    }
Beispiel #5
0
    public void React(GameObject effector)
    {
        Damager effectorinfo = effector.GetComponent <Damager>();

        if (!_hm.CurrentlyInvincible)
        {
            AudioSource.PlayClipAtPoint(Hit, 0.9f * Camera.main.transform.position + 0.1f * transform.position, 10f);
            LastImpact     = effector;
            EffectStrength = effectorinfo.EffectStrength;
            EffectLength   = effectorinfo.EffectLength;

            if (effector.CompareTag("Projectiles"))
            {
                HitHazard = false;
                switch (effector.name)
                {
                case "Default Bullet(Clone)":
                    HitHazard = false;
                    KnockPlayer();
                    break;

                case "Bubblet(Clone)":
                    FloatPlayer();
                    break;

                case "Unstoppabullet(Clone)":
                    HitHazard = false;
                    KnockPlayer();
                    break;
                }
            }
            else if (!_pc.CurrentlyDashing)
            {
                _hm.LastHitIFrames = effectorinfo.IFrames;
                _hm.MakeInvincible(effectorinfo.IFrames);
                _hm.DamagePlayer(effectorinfo.Damage);

                HitHazard = true;
                KnockPlayer();
            }
        }
    }