Example #1
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        lifetime = 0;

        /*var tile = collision.gameObject.GetComponent<Tile>();
         * if(tile){
         *      Debug.Log("yo");
         * }*/
        Vector3 hitPosition = Vector3.zero;

        if (TileManager.mainTilemap != null && TileManager.mainTilemap.gameObject == collision.gameObject)
        {
            foreach (ContactPoint2D hit in collision.contacts)
            {
                hitPosition.x = hit.point.x - 0.01f * hit.normal.x;
                hitPosition.y = hit.point.y - 0.01f * hit.normal.y;

                Vector3Int coord = TileManager.mainTilemap.WorldToCell(hitPosition);

                TileType t = TileManager.scriptTilemap.GetTileType(coord);
                if (t)
                {
                    TileManager.OnTileHit(coord, this);
                }
            }
        }

        OnBulletHit?.Invoke(transform.position);
    }
Example #2
0
    private void OnParticleCollision(GameObject other)
    {
        takeDamageFX.Play();

        // Fire up the bullet hit event
        OnBulletHit?.Invoke(this, EventArgs.Empty);
    }
Example #3
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Enemy" || collision.gameObject.tag == "Boss")
     {
         OnBulletHit?.Invoke();
         Destroy(gameObject);
     }
 }
Example #4
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.rigidbody.tag == "Enemy")
     {
         score += 200;
         //Debug.Log("score " + score);
         OnBulletHit?.Invoke(score);
         Destroy(gameObject);
     }
     if (collision.rigidbody.tag == "Boss")
     {
         score += 300;
         OnBulletHit?.Invoke(score);
         Destroy(gameObject);
     }
 }
Example #5
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     OnBulletHit.Invoke(other);
 }