示例#1
0
    IEnumerator Shoot()
    {
        shootEfect.Play();
        shootGunSound.Play();

        RaycastHit hit;

        if (Physics.Raycast(mainCamera.transform.position, mainCamera.transform.forward, out hit, range))
        {
            BreakableObject breakableObject = hit.transform.GetComponent <BreakableObject>();
            Bomb            bombObj         = hit.transform.GetComponent <Bomb>();

            if (breakableObject != null)
            {
                glassBrokeSound.Play();
                breakableObject.triggerBreak();
                gameContoller.AddScore();
            }
            else if (bombObj != null)
            {
                explosionSound.Play();
                bombObj.triggerBreak();
                bloodCanvas.SetActive(true);
                yield return(new WaitForSeconds(1));

                gameContoller.EndLevel(true);
            }
        }
    }