Пример #1
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.CompareTag("Enemy"))
     {
         gameManagerEngine.GetHit();
     }
 }
Пример #2
0
    void CheckHits()
    {
        RaycastHit hit;

        if (Physics.Raycast(transform.position, Vector3.forward, out hit, gameManagerEngine.explosionRange))
        {
            if (hit.collider.CompareTag("Player"))
            {
                gameManagerEngine.GetHit();
            }
            else if (hit.collider.CompareTag("Enemy"))
            {
                gameManagerEngine.DestroyEnemy(hit.collider);
            }
            else if (hit.collider.CompareTag("Brick"))
            {
                gameManagerEngine.DestroyBrick(hit.collider);
            }
            else if (hit.collider.CompareTag("ExtraItem"))
            {
                gameManagerEngine.DestroyExtraItem(hit.collider);
            }
        }

        if (Physics.Raycast(transform.position, Vector3.right, out hit, gameManagerEngine.explosionRange))
        {
            if (hit.collider.CompareTag("Player"))
            {
                gameManagerEngine.GetHit();
            }
            else if (hit.collider.CompareTag("Enemy"))
            {
                gameManagerEngine.DestroyEnemy(hit.collider);
            }
            else if (hit.collider.CompareTag("Brick"))
            {
                gameManagerEngine.DestroyBrick(hit.collider);
            }
            else if (hit.collider.CompareTag("ExtraItem"))
            {
                gameManagerEngine.DestroyExtraItem(hit.collider);
            }
        }

        if (Physics.Raycast(transform.position, Vector3.back, out hit, gameManagerEngine.explosionRange))
        {
            if (hit.collider.CompareTag("Player"))
            {
                gameManagerEngine.GetHit();
            }
            else if (hit.collider.CompareTag("Enemy"))
            {
                gameManagerEngine.DestroyEnemy(hit.collider);
            }
            else if (hit.collider.CompareTag("Brick"))
            {
                gameManagerEngine.DestroyBrick(hit.collider);
            }
            else if (hit.collider.CompareTag("ExtraItem"))
            {
                gameManagerEngine.DestroyExtraItem(hit.collider);
            }
        }

        if (Physics.Raycast(transform.position, Vector3.left, out hit, gameManagerEngine.explosionRange))
        {
            if (hit.collider.CompareTag("Player"))
            {
                gameManagerEngine.GetHit();
            }
            else if (hit.collider.CompareTag("Enemy"))
            {
                gameManagerEngine.DestroyEnemy(hit.collider);
            }
            else if (hit.collider.CompareTag("Brick"))
            {
                gameManagerEngine.DestroyBrick(hit.collider);
            }
            else if (hit.collider.CompareTag("ExtraItem"))
            {
                gameManagerEngine.DestroyExtraItem(hit.collider);
            }
        }

        Vector3 forward = transform.TransformDirection(Vector3.forward) * gameManagerEngine.explosionRange;
        Vector3 back    = transform.TransformDirection(Vector3.back) * gameManagerEngine.explosionRange;
        Vector3 left    = transform.TransformDirection(Vector3.left) * gameManagerEngine.explosionRange;
        Vector3 right   = transform.TransformDirection(Vector3.right) * gameManagerEngine.explosionRange;

        //TODO: Change DrawRay to explosion effect in the future.
        Debug.DrawRay(transform.position, forward, Color.red, 1f);
        Debug.DrawRay(transform.position, back, Color.red, 1f);
        Debug.DrawRay(transform.position, left, Color.red, 1f);
        Debug.DrawRay(transform.position, right, Color.red, 1f);
    }