private void OnTriggerEnter2D(Collider2D collision) { if (GameManager.instance.IsGameOver()) { return; } if (collision.gameObject.CompareTag(GameInformation.enemyBulletTag)) { unit.TakeDamage(collision.gameObject.GetComponent <EnemyBullet>().damage); Destroy(collision.gameObject); } }
public void OnTriggerEnter(Collider other) { if (other.tag == "UnitNeutral") { //print(other.name + " " + gameObject.name); other.GetComponent <UnitBehavior>().Recruit(Ruler); } else if (isEnemy(other) && Damage > 0 && Ruler > 0) { //print(gameObject.name + Ruler +" hits " + other.name + " for " + Damage + " damage"); // damage audio.Play("attack"); UnitBehavior ub = other.GetComponent <UnitBehavior>(); ub.TakeDamage(Damage, Ruler); } if (other.tag == "Environment") { Environment env = other.GetComponent <Environment>(); EnvironmentSpeedModifier = env.SpeedModifier; EnvironmentAttackModifier = env.AttackModifier; print("Hit environment"); if (this is Knight) { if (other.name.Contains("Trees")) { Damage = 0; } } } else if (other.tag == "Drown") { Die(); } }