示例#1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.layer == LayerMask.NameToLayer("Shootable"))
     {
         myProj.removeForce();
         Instantiate(explosionEffect, transform.position, transform.rotation);
         Destroy(gameObject);
         if (other.tag == "Enemy")
         {
             enemyHealth hurtEnemy = other.gameObject.GetComponent <enemyHealth>();
             hurtEnemy.addDamage(weaponDamage);
         }
     }
 }
示例#2
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        bool destroy = false;

        if (collision.gameObject.tag == "ShootTable")
        {
            if (collision.gameObject.layer == LayerMask.NameToLayer("enemy"))
            {
                if (!collision.gameObject.transform.parent.GetComponent <EnemyController>().isBerserk)
                {
                    destroy = true;
                    EnemyController hurtEnemy;
                    hurtEnemy = collision.gameObject.GetComponentInParent <EnemyController>();
                    hurtEnemy.addDamage(weaponDamage);
                }
            }
            else if (collision.gameObject.layer == LayerMask.NameToLayer("destructible"))
            {
                destroy = true;
                EnemyHealth hurtEnemy;
                hurtEnemy = collision.gameObject.GetComponent <EnemyHealth>();
                hurtEnemy.addDamage(weaponDamage);
            }
            else if (collision.gameObject.layer == LayerMask.NameToLayer("boss"))
            {
                destroy = true;
                EnemyHealth hurtEnemy;
                hurtEnemy = collision.gameObject.GetComponentInParent <EnemyHealth>();
                hurtEnemy.addDamage(weaponDamage);
            }
        }
        else if (collision.gameObject.tag == "Ground" && collision.gameObject.GetComponent <PlatformEffector2D>().useOneWay == false)
        {
            destroy = true;
        }

        if (destroy)
        {
            proCon.removeForce();
            Instantiate(bulletExplosion, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }