Exemple #1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        NPlayerController otherPlayer = col.gameObject.GetComponent <NPlayerController>();

        if (otherPlayer != null && onFire != null)
        {
            otherPlayer.HitByFire();
        }
    }
Exemple #2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        NPlayerController np = collider.gameObject.GetComponent <NPlayerController>();
        NWeapon           w  = collider.gameObject.GetComponent <NWeapon>();

        if (np != null && np != wielder)
        {
            np.HitByFire();
        }
        else if (w != null)
        {
            w.HitByFire();
        }
    }
Exemple #3
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        NPlayerController np = collision.collider.gameObject.GetComponent <NPlayerController>();
        NWeapon           w  = collision.collider.gameObject.GetComponent <NWeapon>();

        if (np != null)
        {
            np.HitByFire();
            IEnumerator explosion = Explosion(Vector2.Reflect(rb.velocity, collision.contacts[0].normal));
            StartCoroutine(explosion);
        }
        else if (collision.collider.gameObject.layer.Equals(LayerMask.NameToLayer("Platforms")))
        {
            IEnumerator explosion = Explosion(Vector2.Reflect(lastFrameVelocity, collision.contacts[0].normal));
            StartCoroutine(explosion);
        }
        else if (w != null)
        {
            w.HitByFire();
        }
    }