Пример #1
0
    private void OnTriggerEnter(Collider other)
    {
        IDamage damage = other.transform.root.GetComponent <IDamage>();

        if (damage != null)
        {
            damage.Damage(headdamage);
        }
    }
Пример #2
0
    public void Damage(int dmgTaken)
    {
        Debug.Log("Hit Button");
        anim.SetTrigger("Button_Activate");
        IDamage hit = target.GetComponent <IDamage>();

        if (hit != null)
        {
            hit.Damage(-1);
        }
    }
Пример #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player" && _isEnemyLaser == true)
        {
            IDamage IDamage = other.GetComponent <IDamage>();

            if (IDamage != null)
            {
                IDamage.Damage();
                gameObject.SetActive(false);
            }
        }
    }
Пример #4
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            other.GetComponent <IDamage>().Damage();
            IDamage.Damage();
        }
        else if (other.tag == "Laser")
        {
            if (!other.GetComponent <Laser>()._isEnemyLaser)
            {
                Player _player = GameObject.Find("Player").GetComponent <Player>();
                if (_player != null)
                {
                    _player.AddScore(10);
                }

                IDamage.Damage();
                other.gameObject.SetActive(false);
            }
        }
    }
Пример #5
0
 public void Damage(int dmgTaken)
 {
     Debug.Log("Hit Button");
     anim.SetTrigger("Button_Activate");
     for (int i = 0; i < targets.Length; i++)
     {
         IDamage hit = targets[i].GetComponent <IDamage>();
         if (hit != null)
         {
             hit.Damage(-1);
         }
     }
 }
Пример #6
0
    private void OnTriggerEnter(Collider collision)
    {
        IDamage hit = collision.gameObject.GetComponent <IDamage>();

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

        Debug.Log(hit);

        /*
         * if (collision.gameObject.tag == "Animal")
         * {
         * }
         */
    }
Пример #7
0
        void OnCollisionEnter(Collision collision)
        {
            Instantiate(hitEffect, transform.position, Quaternion.identity);

            DamageInfo info = new DamageInfo();

            info.SetDamageValue(shootDamageValue);

            MonoBehaviour[] behaviors = collision.gameObject.GetComponents <MonoBehaviour>();
            foreach (MonoBehaviour b in behaviors)
            {
                IDamage i = b as IDamage;
                if (i != null)
                {
                    i.Damage(info);
                }
            }

            Destroy(gameObject);
        }
Пример #8
0
        void OnCollisionEnter(Collision collision)
        {
            Vector3 melee_vector = (collision.transform.position - transform.position);

            collision.gameObject.rigidbody.AddForce(meleePower * melee_vector);

            DamageInfo info = new DamageInfo();

            info.SetDamageValue(meleeDamageValue);

            MonoBehaviour[] behaviors = collision.gameObject.GetComponents <MonoBehaviour>();
            foreach (MonoBehaviour b in behaviors)
            {
                IDamage i = b as IDamage;
                if (i != null)
                {
                    i.Damage(info);
                }
            }

            Instantiate(hitEffect, transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
Пример #9
0
    //cooldown before object can take damage again

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (!(other.CompareTag("Player") &&
              this.CompareTag("Player")) &&
            !(other.CompareTag("Player") && this.CompareTag("Fey")) &&
            !(other.CompareTag("Fey") &&
              this.CompareTag("Player")) &&
            !(other.CompareTag("Fey") &&
              this.CompareTag("Fey")) &&
            !(other.CompareTag("Buddy Bullet") &&
              this.CompareTag("Buddy Bullet")) &&
            !(other.CompareTag("Buddy Bullet") &&
              this.CompareTag("Fey")) &&
            !(other.CompareTag("Fey") &&
              this.CompareTag("Buddy Bullet")) &&
            !(other.CompareTag("Enemy") && this.CompareTag("Enemy")) &&
            !(other.CompareTag("EnemyBullet") && this.CompareTag("EnemyBullet")) &&
            !(other.CompareTag("EnemyBullet") && this.CompareTag("Enemy")) &&
            !(other.CompareTag("Enemy") && this.CompareTag("EnemyBullet"))

            )
        {
            IDamage hit = other.GetComponent <IDamage>();
            if (hit != null)
            {
                if (this.CompareTag("Button"))
                {
                    Debug.Log(this);
                    hit.Damage(1);
                }
                else if (other.CompareTag("Fey") && other.gameObject.layer != 10)
                {
                    Debug.Log("fey hurted");
                    Fey fey = other.GetComponent <Fey>();
                    if (!fey._immunity)
                    {
                        hit.Damage(damageDealt);
                        fey.tookDamage();
                    }
                }
                else if (other.CompareTag("Enemy") && gameObject.layer != 16)
                {
                    Enemy enemy = other.GetComponent <Enemy>();
                    if (enemy != null)
                    {
                        if (!enemy._immunity)
                        {
                            hit.Damage(damageDealt);
                            enemy.tookDamage();
                        }
                    }
                }
                else if (other.CompareTag("EnemyBullet"))
                {
                    hit.Damage(damageDealt);
                }
                else
                {
                    hit.Damage(damageDealt);
                }
            }

            /*if (hit != null){
             *  if (this.CompareTag("Button"))
             *  {
             *      Debug.Log(this);
             *      hit.Damage(1);
             *  }
             *  else
             *      {
             *          if (damageDealt > 0)
             *          {
             *              //Debug.Log("hit: " + other.name);
             *              //call our interface in order to access its methods related to the object this is attached to
             *              //should be attached to the fight hitbox.
             *              if (_immunity == false)
             *              {
             *                  hit.Damage(damageDealt);
             *
             *                  _immunity = true;
             *                  StartCoroutine(EnemyImmunityCoolDown());
             *              }
             *          }
             *      }
             *  }*/
        }
    }