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;
        }
    }
示例#2
0
    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);
            }
        }
    }
示例#3
0
 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());
         }
     }
 }
示例#4
0
    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);
            }
        }
    }