void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Enemy")) { EnemyHealthBase enemyHealth = other.GetComponent <EnemyHealthBase> (); if (enemyHealth != null) { enemyHealth.Damage(damagePerShot); } explosionEffect.Play(); Destroy(gameObject, 0.1f); } else if (other.CompareTag("LowerCollider")) { bossHealth = GameObject.FindGameObjectWithTag("Boss").GetComponent <WhipMasterHealth> (); bossHealth.Damage(damagePerShot); explosionEffect.Play(); Destroy(gameObject, 0.1f); } else if (other.CompareTag("UpperCollider")) { explosionEffect.Play(); Destroy(gameObject, 0.1f); } else if (other.CompareTag("BoxTwo")) { boxHealth = GameObject.FindGameObjectWithTag("BoxTwo").GetComponent <BoxHealth> (); boxHealth.Damage(damagePerShot); explosionEffect.Play(); Destroy(gameObject, 0.1f); } }
void OnTriggerEnter2D(Collider2D other) { if ((other.CompareTag("TopCollider") || other.CompareTag("BottomCollider"))) { if (GameObject.FindGameObjectWithTag("Player") != null) { playerHealth = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealth> (); playerHealth.Damage(damage, 0f); } } else if (other.CompareTag("Enemy")) { EnemyHealthBase enemyHealth = other.GetComponent <EnemyHealthBase>(); if (enemyHealth != null) { enemyHealth.Damage(20); } } } //OnTriggerEnter2Df
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Enemy")) { EnemyHealthBase enemyHealth = other.GetComponent <EnemyHealthBase> (); if (enemyHealth != null) { enemyHealth.Damage(damage); } playerScore.IncreaseScore(250); } else if (other.CompareTag("LowerCollider") || other.CompareTag("UpperCollider")) { bossHealth = GameObject.FindGameObjectWithTag("Boss").GetComponent <WhipMasterHealth> (); bossHealth.Damage(damage); playerScore.IncreaseScore(550); } else if (other.CompareTag("BoxTwo")) { boxHealth = GameObject.FindGameObjectWithTag("BoxTwo").GetComponent <BoxHealth> (); boxHealth.Damage(damage); playerScore.IncreaseScore(50); } //if-else } //OnTriggerEnter2D