Example #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         Rigidbody2D playerRigidBody = other.GetComponent <Rigidbody2D>();
         while (!PlayerLifeController.RemoveLife())
         {
         }
     }
 }
Example #2
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.CompareTag("Player"))
        {
            Rigidbody2D playerRigidBody = coll.GetComponent <Rigidbody2D>();
            // lose a life

            if (!PlayerLifeController.RemoveLife())
            {
                playerRigidBody.AddForce(new Vector2(0, explosionForce));
            }
        }
    }
Example #3
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         Rigidbody2D playerRigidBody = other.GetComponent <Rigidbody2D>();
         if (PlayerLifeController.RemoveLife())
         {
             // Might change this with death animation (in remove life function)
             foreach (GameObject go in explosionObjects)
             {
                 Instantiate(go, other.transform.position, Quaternion.identity);
             }
         }
         playerRigidBody.AddForce(new Vector2(0, -knockbackForce));
     }
 }
Example #4
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.CompareTag("Player"))
        {
            // make the player lose a life
            // send him in A direction

            if (!coll.GetComponent <ShieldController>().IsShieldActive())
            {
                Rigidbody2D playerRigidBody = coll.GetComponent <Rigidbody2D>();
                // lose a life

                if (!PlayerLifeController.RemoveLife())
                {
                    playerRigidBody.AddForce(new Vector2(0, explosionForce));
                }
            }
            Destroy(this.gameObject);
        }
        else if (coll.CompareTag("HarpoonBullet"))
        {
            Destroy(this.gameObject);
        }

        //Create explosion effect

        if (GetComponent <Renderer>().isVisible)
        {
            var explosionInstance = Instantiate(explosionPrefab, transform.position, Quaternion.identity);
            Destroy(explosionInstance, 3);

            if (UIManagerScript.soundEffectsEnabled)
            {
                var soundInstance = Instantiate(explosionSound, transform.position, Quaternion.identity);
                Destroy(soundInstance, 3);
            }

            Camera.main.GetComponent <CameraShake>().ShakeFor(0.5f);
        }
    }