Beispiel #1
0
    public void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Enemy"))
        {
            // Disable the collider so we can't hit another enemy
            if (type != 4)
            {
                myTr.collider2D.enabled = false;                        // laser can shoot through enemies !
            }
            //Debug.Log("Bullet collided with an enemy", gameObject);
            other.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);

            // Call the DestroyObject function
            if (type != 4)
            {
                StartCoroutine(DestroyObject());
            }
        }

        if (other.CompareTag("Ground"))
        {
            //Debug.Log("Player Bullet collided with the ground", gameObject);

            // If type = laser
            if (type == 4)
            {
                return;                        // laser can shoot through walls !
            }
            // If type = bomb, deploy napalm !
            if (type == 5)
            {
                impactClone = impactPool.Spawn();
                impactClone.transform.position = myTr.position;

                ImpactScript impactCloneScript = impactClone.GetComponent <ImpactScript>() as ImpactScript;               //var impactCloneScript : ImpactScript = impactClone.GetComponent<ImpactScript>() as ImpactScript;
                impactCloneScript.bombImpact = true;

                StartCoroutine(BombLandingDamage());

                StartCoroutine(DestroyObject());

                return;
            }

            impactClone = impactPool.Spawn();
            impactClone.transform.position = myTr.position;

            // Call the DestroyObject function
            StartCoroutine(DestroyObject());
        }
    }
Beispiel #2
0
 protected void Impact()
 {
     is_moving = false;
     if (is_targeted)
     {
         ImpactScript impact_script = target.gameObject.GetComponent <ImpactScript>();
         if (impact_script)
         {
             impact_script.CheckImpact(proj_type);
         }
     }
     gameObject.SetActive(false);
     Destroy(gameObject);
 }