예제 #1
0
 public void Enemy_Damage()
 {
     CameraManager.CameraInstance.ShakeCamera(0.2f, 0.1f);
     hitPause.Freeze();
     if (health <= 0)
     {
         Die();
     }
 }
예제 #2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.GetComponent <HealthComponent>() != null)
     {
         if (causes_screen_shake_)
         {
             camera_manager_.Shake(hit_pause_.base_duration_ * damage_ * screen_shake_base_duration_, damage_ * screen_shake_base_magnitude_);
         }
         if (causes_hit_pause_)
         {
             hit_pause_.Freeze(damage_);
         }
         damage_popup.Create(collision.gameObject, damage_, false);
         collision.gameObject.GetComponent <HealthComponent>().TakeDamage(damage_);
     }
 }
예제 #3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (enemy_mask_ == (enemy_mask_ | (1 << collision.gameObject.layer)))
        {
            if (collision.gameObject.GetComponent <HealthComponent>() != null)
            {
                if (causes_screen_shake_)
                {
                    camera_manager_.Shake(hit_pause_.base_duration_ * damage_ * screen_shake_base_duration_, damage_ * screen_shake_base_magnitude_);
                }
                if (causes_hit_pause_)
                {
                    hit_pause_.Freeze(damage_);
                }

                if (UnityEngine.Random.Range(1, 100) <= crit_chance)
                {
                    if (collision.gameObject != null)
                    {
                        if (collision.gameObject.GetComponent <HealthComponent>() != null)
                        {
                            if (!collision.gameObject.GetComponent <HealthComponent>().isInvincible() && collision.gameObject != GameObject.Find("Player"))
                            {
                                if (damage_popup_manager_ != null)
                                {
                                    damage_popup_manager_.Create(gameObject, damage_ * crit_modifier, true);
                                }
                            }
                            collision.gameObject.GetComponent <HealthComponent>().TakeDamage(damage_ * crit_modifier);
                        }
                    }
                }
                else
                {
                    if (collision.gameObject != null)
                    {
                        if (collision.gameObject.GetComponent <HealthComponent>() != null)
                        {
                            if (!collision.gameObject.GetComponent <HealthComponent>().isInvincible() && collision.gameObject != GameObject.Find("Player"))
                            {
                                if (damage_popup_manager_ != null)
                                {
                                    damage_popup_manager_.Create(collision.gameObject, damage_, true);
                                }
                            }
                            collision.gameObject.GetComponent <HealthComponent>().TakeDamage(damage_);
                        }
                    }
                }
                // get direction
                Vector2 direction = ((Vector2)collision.gameObject.transform.position - (Vector2)transform.position).normalized;

                if (collision.gameObject.GetComponent <BloodEffect>() != null)
                {
                    collision.gameObject.GetComponent <BloodEffect>().DrawBlood(direction);
                }

                if (knock_back_ && GetComponent <BombKnockback>() != null)
                {
                    GetComponent <BombKnockback>().ForcePush();
                }
            }
        }
    }