private void OnTriggerEnter2D(Collider2D collision) { EnemyHealthManager healthManager = collision.gameObject.GetComponent <EnemyHealthManager>(); // If the boss collided with an enemy attack, decrease its health if (healthManager != null) { healthManager.DecreaseHealth(GetDamage()); //GameObject.Destroy(playerAttack.gameObject); } MchawiMovement mchawiMovement = collision.gameObject.GetComponent <MchawiMovement>(); if (mchawiMovement != null) { mchawiMovement.OnCollisionWithAttack(); } }
private void Start() { // If Kujenga boss has been defeated the game object is deactivated if (!SharedInfo.MchawiBossDefeated) { this.gameObject.SetActive(SharedInfo.CurseStarted); } else { this.gameObject.SetActive(false); } _healthManager = GetComponent <EnemyHealthManager>(); if (_healthManager == null) { throw new MissingComponentException("Mchawi Boss is missing the EnemyHealthManager component!"); } _mchawiMovement = GetComponent <MchawiMovement>(); if (_mchawiMovement == null) { throw new MissingComponentException("Mchawi Boss is missing the KujengaMovement component!"); } _interactable = GetComponent <Interactable>(); if (_interactable == null) { throw new MissingComponentException("Mchawi Boss is missing the Interactable component!"); } _capsuleCollider2D = GetComponent <CapsuleCollider2D>(); if (_capsuleCollider2D == null) { throw new MissingComponentException("Mchawi Boss is missing the capsule collider 2D component!"); } Physics2D.IgnoreCollision(GameObject.Find("Player").GetComponent <CapsuleCollider2D>(), _capsuleCollider2D, true); }