private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Enemy") && !bUsed) { AudioSource mSFXBox = this.gameObject.AddComponent <AudioSource>(); mSFXBox.outputAudioMixerGroup = m_Channel; mSFXBox.clip = crashSFX; mSFXBox.time = 1; mSFXBox.Play(); WerewolfAI ai = collision.gameObject.GetComponent <WerewolfAI>(); if (ai != null) { //this.transform.parent.transform.parent.GetComponent<Room>().NPCs.Remove(collision.gameObject); collision.gameObject.transform.parent.GetComponent <Room>().NPCs.Remove(collision.gameObject); ai.TakeDamage(ai.HP); } bUsed = true; GetComponent <SpriteRenderer>().enabled = false; GetComponent <Collider2D>().enabled = false; GetComponent <Rigidbody2D>().simulated = false; } }
private void OnTriggerStay2D(Collider2D collision) { WerewolfAI werewolf = collision.gameObject.GetComponent <WerewolfAI>(); if (collision.CompareTag("Enemy")) { if (werewolf.CurrentState != WerewolfAI.EWerewolfStates.Chasing) { werewolf.TakeDamage(werewolf.HP); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Enemy")) { //collision.gameObject.transform.parent = this.transform; WerewolfAI ai = collision.gameObject.GetComponent <WerewolfAI>(); if (ai != null) { //this.transform.parent.GetComponent<Room>().NPCs.Remove(collision.gameObject); collision.gameObject.transform.parent.GetComponent <Room>().NPCs.Remove(collision.gameObject); ai.TakeDamage(ai.HP); StartCoroutine(TrapCooldown()); } } }
private void OnTriggerEnter2D(Collider2D collision) { ServantAI servant = collision.gameObject.GetComponent <ServantAI>(); WerewolfAI werewolf = collision.gameObject.GetComponent <WerewolfAI>(); if (collision.CompareTag("Servant")) { if (servant.CurrentState == ServantAI.EServantStates.Running) { servant.TakeDamage(servant.HP); } } else if (collision.CompareTag("Enemy")) { if (werewolf.CurrentState != WerewolfAI.EWerewolfStates.Chasing) { werewolf.TakeDamage(werewolf.HP); } } }