private void shoot()
    {
        //StartCoroutine(cameraShake.Shake(shakeDuration, shakeAmount, shakeDecreaseAmount));
        CameraShaker.Instance.ShakeOnce(shakeAmount, shakeRoughness, shakeFadeInTime, shakeFadeOutTime);
        fireSound.Play();
        //fireSound.pitch = Random.Range(pitchMin, pitchMax);
        //fireSound.volume = Random.Range(volumeMin, volumeMax);
        //fireSound.PlayOneShot(fireClip);

        PlayerStats.stats[4] -= 1;

        int newDamage = 1 * Random.Range(20, 30);

        RaycastHit raycastHit;

        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.TransformDirection(Vector3.forward), out raycastHit, Mathf.Infinity, ~(1 << 2)))
        {
            if (raycastHit.transform.gameObject.layer == 10)
            {
                Enemy enemy = raycastHit.transform.parent.GetComponent <Enemy>();
                enemy.Damage(newDamage);
                //Debug.Log(enemy);
                //if (enemy != null) enemy.Damage(newDamage);
                if (enemy.enemyHealth <= 0)
                {
                    particleDecalPool.spawnBloodParticles(newDamage, raycastHit.transform.position - new Vector3(0, 0.4f, 0));
                }
                else
                {
                    particleDecalPool.spawnBloodParticles(newDamage, raycastHit.transform.position);
                }
            }
        }
    }
Пример #2
0
    public void shoot()
    {
        if (PlayerStats.stats[4] <= 0)
        {
            anim.SetTrigger(stopShootHash);
            anim.SetBool(fullAutoHash, false);
            anim.SetBool(switchWeaponHash, true);
        }
        else
        {
            PlayerStats.stats[4] -= 1;

            int newDamage = 1 * Random.Range(60, 71);

            RaycastHit raycastHit;
            if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.TransformDirection(Vector3.forward), out raycastHit, Mathf.Infinity, ~(1 << 2)))
            {
                if (raycastHit.transform.gameObject.layer == 10)
                {
                    Enemy enemy = raycastHit.transform.parent.GetComponent <Enemy>();
                    enemy.Damage(newDamage);

                    if (enemy.enemyHealth <= 0)
                    {
                        particleDecalPool.spawnBloodParticles(newDamage, raycastHit.transform.position - new Vector3(0, 0.4f, 0));
                    }
                    else
                    {
                        particleDecalPool.spawnBloodParticles(newDamage, raycastHit.transform.position);
                    }
                }
            }
        }
    }
    private void stab()
    {
        knifeStabSound.Play();

        int newDamage = 1 * Random.Range(50, 70);

        RaycastHit raycastHit;

        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.TransformDirection(Vector3.forward), out raycastHit, 0.6f, ~(1 << 2)))
        {
            if (raycastHit.transform.gameObject.layer == 10)
            {
                Enemy enemy = raycastHit.transform.parent.GetComponent <Enemy>();
                enemy.Damage(newDamage);

                if (enemy.enemyHealth <= 0)
                {
                    particleDecalPool.spawnBloodParticles(newDamage, raycastHit.transform.position - new Vector3(0, 0.4f, 0));
                }
                else
                {
                    particleDecalPool.spawnBloodParticles(newDamage, raycastHit.transform.position);
                }
            }
        }
    }