Beispiel #1
0
    void Shoot()
    {
        timer = 0f;

        //gunAudio.Play();

        gunLight.enabled = true;

        //gunParticles.Stop();
        //gunParticles.Play();

        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);

        shootRay.origin    = transform.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            enemyHealth eHealth = shootHit.collider.GetComponent <enemyHealth>();
            if (eHealth != null)
            {
                eHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        enemyHealth enemy = hitInfo.GetComponent <enemyHealth>();

        // Grabs the enemyHealth script component
        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
Beispiel #3
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag(target))
     {
         enemyHealth eHealth = other.GetComponent <enemyHealth>();
         if (eHealth != null)
         {
             eHealth.TakeDamage(skillDamange, transform.position);
         }
         else
         {
             playerHealth pHealth = other.GetComponent <playerHealth>();
             pHealth.TakeDamage(skillDamange);
         }
     }
 }
Beispiel #4
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        //want to use the enemy takedamage function
        enemyHealth enemy = hitInfo.GetComponent <enemyHealth>();

        //if the enemy is hit
        if (hitInfo.transform.name == "enemy_AI")
        {
            Impact();
            enemy.TakeDamage(damage);
        }
        // hitting anything else does not do anything except trigger the explosion
        else
        {
            Impact();
        }
    }
Beispiel #5
0
 protected virtual void OnTriggerEnter(Collider other)
 {
     if (other.tag.Equals("Projectile"))
     {
         projectileController proj = other.gameObject.GetComponent <projectileController> ();
         if (proj.m_shooter != this.gameObject)
         {
             if (proj.m_shooter.tag.Equals("Player"))
             {
                 m_healthController.TakeDamage(proj.m_damage);
                 Vector3 shootForce = player.GetComponent <playerShoot> ().m_pushForce *(this.transform.position - proj.m_shooter.transform.position);
                 this.rigidbody.AddForceAtPosition(shootForce, this.transform.position);
                 if (!proj.isPiercing)
                 {
                     Destroy(other.gameObject);
                 }
             }
         }
     }
 }