Ejemplo n.º 1
0
    protected virtual void OnTriggerEnter2D(Collider2D collider2D)
    {
        if (aiBase != null && aiBase.GetEnemyAction() == enumEnemyActions.defend)
        {
            return;
        }

        if (collider2D.tag == "Punch" && m_movementModel.GetPushBackSpeed() == 0f)
        {
            if (GetComponentInChildren <Attackable>() == null)
            {
                Debug.Log(transform.parent.name);
            }

            int damage = playerStats.GetComponentInChildren <Attackable>().GetDamage();

            attackerMovementModel = collider2D.GetComponentInParent <CharacterMovementModel>();

            DoHit(damage, attackerMovementModel.GetFacingDirection());
        }

        if (collider2D.tag == "PlayerProjectile" && m_movementModel.GetPushBackSpeed() == 0f)
        {
            if (health <= 0)
            {
                return;
            }

            Destroy(collider2D.gameObject);

            DoHit(1, collider2D.GetComponent <Projectile>().GetMovementDirection());
        }

        if (collider2D.tag == "PlayerHazard" && m_movementModel.GetPushBackSpeed() == 0f)
        {
            if (health <= 0)
            {
                return;
            }

            Vector2 movementDirection = transform.parent.GetComponent <CharacterMovementModel>().GetReverseFacingDirection();
            Debug.Log(movementDirection);
            DoHit(1, movementDirection);
        }

        if (collider2D.tag == "PlayerBombRing" && m_movementModel.GetPushBackSpeed() == 0f)
        {
            if (health <= 0)
            {
                return;
            }

            Vector2 hitDirection = collider2D.GetComponentInParent <PlayerBomb>().GetHitDirection(transform);

            DoHit(1, hitDirection);
        }
    }