void OnTriggerEnter2D(Collider2D other) { GameObject hit = other.gameObject; if (hit.layer == 8) { gameObject.SetActive(false); return; } if (hit.gameObject.CompareTag("Player") && !playerBullet) { hit.GetComponent <PlayerManager>().FullHealth(); gameObject.SetActive(false); return; } if (hit.CompareTag("Enemy") || hit.CompareTag("EnemyMove") && playerBullet) { BossManager bossmanager = hit.GetComponent <BossManager>(); EnemyManager manager = hit.GetComponent <EnemyManager>(); Debug.Log(hit.tag); try { manager.HitDamage(1); } catch (NullReferenceException e) { //Debug.Log("Enemy did not have manager.hitDamage()"); } try { bossmanager.HitDamage(1); } catch (NullReferenceException e) { // Debug.Log("Enemy did not have bossmanager.hitDamage()"); } if (isInArena && bossmanager == null) { if (other.GetComponent <EnemyManager>().currentHealth == 0) { arena.killcount += -1; Debug.Log("Arena kill"); } } gameObject.SetActive(false); return; } }
void OnTriggerEnter2D(Collider2D other) { GameObject hit = other.gameObject; if (hit.layer == 8) { gameObject.SetActive(false); return; } if (hit.gameObject.CompareTag("Player") && !playerBullet) { hit.GetComponent <PlayerManager>().Damage(); gameObject.SetActive(false); return; } if (playerBullet && (hit.CompareTag("Enemy") || hit.CompareTag("EnemyMove"))) { BossManager bossmanager = hit.GetComponent <BossManager>(); EnemyManager manager = hit.GetComponent <EnemyManager>(); if (manager != null) { manager.HitDamage(1); } if (bossmanager != null) { bossmanager.HitDamage(1); } if (manager != null) { if (isInArena) { if (manager.currentHealth == 1 && arena != null) { arena.killcount += -1; Debug.Log("Arena kill"); } } } gameObject.SetActive(false); return; } }