void OnTriggerEnter2D(Collider2D collider)
    {
        Debug.Log("OnTriggerEnter2D: " + collider.name);

        // Don't continue to trigger while exploding
        if (destroyDelay > 0f)
        {
            return;
        }
        if (collider.CompareTag("Missle"))
        {
            Debug.Log("Removing object: " + collider.name);
            Destroy(collider.gameObject);

            destroyDelay = Time.time + .4f;
            animator.SetBool("explode", true);
            game.AddToScore(scoreValue);
            explosionController.PlayExplosion();
        }
        if (collider.CompareTag("Player"))
        {
            Debug.Log("Collided with player");
            game.RemoveLife();
            explosionController.PlayExplosion();
        }
    }
Example #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "NPC")
     {
         Debug.Log("<color=green>ProjectileContoller::</color> <color=red>Hit NPC</color>");
         //TODO(Rok Kos): Use polling
         ExplosionController explosionController = Instantiate(explosionControllerPrefab, other.transform.position, Quaternion.identity, null);
         explosionController.PlayExplosion();
         if (type != ProjectileType.kLaser)
         {
             Destroy(this.gameObject);
         }
     }
 }
Example #3
0
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.collider.gameObject.layer == 8)
        {
            Debug.LogFormat("<color=green>ProjectileContoller::</color> <color=red>End Pos:{0:0.00} {1:0.00} {2:0.00}</color>", transform.position.x, transform.position.y, transform.position.z);
            Debug.Log("<color=green>ProjectileContoller::</color> <color=red>Hit Enviroment</color>");
            //TODO(Rok Kos): Use polling
            ExplosionController explosionController = Instantiate(explosionControllerPrefab, transform.position, Quaternion.identity, null);
            explosionController.PlayExplosion();
            Destroy(this.gameObject);
        }

        if (collision.collider.tag == "NPC")
        {
            Debug.Log("<color=green>ProjectileContoller::</color> <color=red>Hit NPC</color>");
            //TODO(Rok Kos): Use polling
            ExplosionController explosionController = Instantiate(explosionControllerPrefab, collision.collider.transform.position, Quaternion.identity, null);
            explosionController.PlayExplosion();
            Destroy(this.gameObject);
        }
    }