Пример #1
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Obstacle"))
        {
            Vector3 collisionDir = collision.GetContact(0).point - transform.position;
            if (Vector3.Angle(collisionDir, transform.forward) < maxFrontCollisionAngle)
            {
                Debug.Log("Front Collision");
                base.FireEventList();
            }
        }

        if (collision.gameObject.CompareTag("Player") || collision.gameObject.CompareTag("Enemy") || collision.gameObject.CompareTag("Ground"))
        {
            if (collision.relativeVelocity.magnitude > 2)
            {
                AudioUtility.PlayRandomClip(LeanPool.Spawn(audioEffectPrefab, transform.position, Quaternion.identity).audioSource, crashAudioClips, true);
            }
        }
    }
Пример #2
0
    private IEnumerator NPCFire(float delay)
    {
        yield return(new WaitForSeconds(delay));

        float fireStartTime = Time.time;
        float fireTime      = UnityEngine.Random.Range(minFireLength, maxFireLength);
        float fireRate      = maxFireRate;

        while (Time.time - fireStartTime < fireTime)
        {
            yield return(new WaitForFixedUpdate());

            AudioUtility.PlayRandomClip(audioSource, fireSound, true);
            //audioSource.PlayOneShot(fireSound);
            LeanPool.Spawn(bulletPrefab.gameObject, firePoint.transform.position, Quaternion.LookRotation((playerTr.position + playerTr.up * 1f) - firePoint.transform.position, transform.up)); //gun.transform.rotation);
            LeanPool.Spawn(muzzleFlash, firePoint.transform.position, firePoint.transform.rotation);
            yield return(new WaitForSeconds(UnityEngine.Random.Range(minFireRate, maxFireRate)));
        }

        FireRandomDelayLoop();
    }
Пример #3
0
    private void OnTriggerEnter(Collider other)
    {
        //Debug.Log("Bullet collision: " + other.name, other.gameObject);
        if (other.CompareTag("Player"))
        {
            RaycastHit hit;
            if (Physics.Raycast(transform.position, transform.forward, out hit))
            {
                //Debug.Log("Point of contact: " + hit.point);
                LeanPool.Spawn(metalImpactEffectPrefab, hit.point, Quaternion.LookRotation(hit.normal, Vector3.up));
            }
            //Debug.Log("Inducing Trauma");
            if (useTraumaInducer)
            {
                traumaInducer.SendTrauma();
            }
            AudioUtility.PlayRandomClip(LeanPool.Spawn(audioEffect, transform.position, Quaternion.identity).audioSource, metalImpactAudioClips, true);

            if (UnityEngine.Random.Range(0, 1) == 1)
            {
                GameController.s_playerController.damage1(1f);
            }
            else
            {
                GameController.s_playerController.damage1(2f);
            }
        }
        else if (other.CompareTag("Ground"))
        {
            RaycastHit hit;
            if (Physics.Raycast(transform.position, transform.forward, out hit))
            {
                //Debug.Log("Point of contact: " + hit.point);
                LeanPool.Spawn(dirtImpactEffectPrefab, hit.point, Quaternion.LookRotation(hit.normal, Vector3.up));
            }
            AudioUtility.PlayRandomClip(LeanPool.Spawn(audioEffect, transform.position, Quaternion.identity).audioSource, dirtImpactAudioClips, true);
        }
        LeanPool.Despawn(gameObject);
    }
 public static void PlayRandomClip(AudioSource audioSource, AudioClips audioClips, bool playOneShot)
 {
     AudioUtility.PlayRandomClip(audioSource, audioClips.m_AudioClips, audioClips
                                 .m_MinVolume, audioClips.m_MaxVolume, audioClips.m_MinPitch, audioClips.m_MaxPitch, playOneShot);
 }