Exemplo n.º 1
0
 private void OnCollisionStay2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "AICharacter" && isMelee)
     {
         //Debug.Log("AI & IsMelee");
         BasicAI ai = collision.gameObject.GetComponent <BasicAI>();
         if (!ai.meleeDamaged)
         {
             ai.Damage(meleeDamage);
             isInvulnerable = true;
             gameObject.GetComponent <Renderer>().material.color = new Color(1, 1, 1, invulnerableTransparency);
             Invoke("TurnOffInvulnerable", invulnerablePeriod);
         }
         ai.meleeDamaged = true;
     }
 }
Exemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log(collision.name);
        if (collision.tag == "AIProjectile")
        {
            if (!isInvulnerable && collision.gameObject.GetComponent <Projectile>().hasTarget)
            {
                //Debug.Log("Invulnerable");
                Destroy(collision.gameObject);
                //if (!isMelee)
                //{
                //Debug.Log("Hit by " + collision.name);
                life--;
                if (life <= 0)
                {
                    RestartGame();
                }
                //}
            }
            else if (isInvulnerable)
            {
                Destroy(collision.gameObject);
            }
        }

        /*
         * Debug.Log("Collided");
         * Debug.Log(isMelee);
         * Debug.Log(collision.gameObject.tag);
         */
        if (collision.gameObject.tag == "AICharacter" && isMelee)
        {
            //Debug.Log("AI & IsMelee");
            BasicAI ai = collision.gameObject.GetComponent <BasicAI>();
            if (!ai.meleeDamaged)
            {
                ai.Damage(meleeDamage);
            }
            ai.meleeDamaged = true;
        }
    }