Ejemplo n.º 1
0
    /// <summary>
    /// fire the machine gun
    /// </summary>
    void MachineGun_Fire()
    {
        if (bulletsLeft <= 0 && numberOfClips > 0)
        {
            StartCoroutine(reload());
            return;
        }
        // If there is more than one bullet between the last and this frame
        // Reset the nextFireTime
        if (Time.time - fireRate > nextFireTime)
        {
            nextFireTime = Time.time - Time.deltaTime;
        }

        // Keep firing until we used up the fire time
        while (nextFireTime < Time.time)
        {
            switch (typeOfBullet)
            {
            case BulletType.Physical:
                StartCoroutine(FireOneShot());      // fire a physical bullet
                break;

            case BulletType.Raycast:
                StartCoroutine(FireOneRay());      // fire a raycast.... change to FireOneRay
                break;

            default:
                Debug.Log("error in bullet type");
                break;
            }
            if (Animat != null)
            {
                if (isAmed)
                {
                    Animat.AimFire();
                }
                else
                {
                    Animat.Fire();
                }
            }
            if (Sync)
            {
                Sync.Firing(weaponType.Machinegun.ToString(), spread);
            }
            audio.clip   = FireSound;
            audio.spread = Random.Range(1.0f, 1.5f);
            audio.pitch  = Random.Range(1.0f, 1.05f);
            audio.Play();
            shotsFired++;
            bulletsLeft--;
            nextFireTime += fireRate;
            EjectShell();
            Kick();
            StartCoroutine(CamShake());
            StartCoroutine(MuzzleFlash());
        }
    }
Ejemplo n.º 2
0
    void Knife_Fire()
    {
        // If there is more than one shot  between the last and this frame
        // Reset the nextFireTime
        if (Time.time - fireRate > nextFireTime)
        {
            nextFireTime = Time.time - Time.deltaTime;
        }

        // Keep firing until we used up the fire time
        while (nextFireTime < Time.time)
        {
            switch (typeOfBullet)
            {
            case BulletType.Physical:
                StartCoroutine(FireOneShot());      // fire a physical bullet
                break;

            case BulletType.Raycast:
                StartCoroutine(FireOneRay());      // fire a raycast.... change to FireOneRay
                break;

            default:
                Debug.Log("error in bullet type");
                break;
            }
            if (Animat != null)
            {
                if (isAmed)
                {
                    Animat.AimFire();
                }
                else
                {
                    Animat.Fire();
                }
            }
            if (Sync)
            {
                Vector3 position = (typeOfGun == weaponType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                Sync.Firing(weaponType.Knife.ToString(), 0, position, transform.parent.rotation);
            }
            GetComponent <AudioSource>().clip   = FireSound;
            GetComponent <AudioSource>().spread = Random.Range(1.0f, 1.5f);
            GetComponent <AudioSource>().pitch  = Random.Range(1.0f, 1.05f);
            GetComponent <AudioSource>().Play();
            nextFireTime += fireRate;
            Kick();
            StartCoroutine(CamShake());
            isFiring = false;
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// fire the machine gun
    /// </summary>
    void MachineGun_Fire()
    {
        // If there is more than one bullet between the last and this frame
        // Reset the nextFireTime
        if (Time.time - Info.FireRate > nextFireTime)
        {
            nextFireTime = Time.time - Time.deltaTime;
        }

        // Keep firing until we used up the fire time
        while (nextFireTime < Time.time)
        {
            StartCoroutine(FireOneShot());  // fire a physical bullet

            if (Animat != null)
            {
                if (isAmed)
                {
                    Animat.AimFire();
                }
                else
                {
                    Animat.Fire();
                }
            }
            if (Sync)
            {
                Vector3 position = (Info.Type == GunType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                Sync.Firing(GunType.Machinegun.ToString(), spread, position, transform.parent.rotation, Info.Damage);
            }
            Source.clip   = FireSound;
            Source.spread = Random.Range(1.0f, 1.5f);
            Source.pitch  = Random.Range(1.0f, 1.05f);
            Source.Play();
            shotsFired++;
            bulletsLeft--;
            nextFireTime += Info.FireRate;
            EjectShell();
            Kick();
            bl_EventHandler.OnLocalPlayerShake(ShakeIntense, 0.25f, 0.03f, isAmed);
            if (muzzleFlash)
            {
                muzzleFlash.Play();
            }
            //is Auto reload
            if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
            {
                StartCoroutine(reload());
            }
        }
    }
Ejemplo n.º 4
0
    /// fire the machine gun
    void MachineGun_Fire()
    {
        if (bulletsLeft <= 0 && numberOfClips > 0)
        {
            StartCoroutine(reload());
            return;
        }
        // If there is more than one bullet between the last and this frame
        // Reset the nextFireTime
        if (Time.time - fireRate > nextFireTime)
        {
            nextFireTime = Time.time - Time.deltaTime;
        }

        // Keep firing until we used up the fire time
        while (nextFireTime < Time.time)
        {
            switch (typeOfBullet)
            {
            case BulletType.Physical:
                StartCoroutine(FireOneShot());      // fire a physical bullet
                break;

            case BulletType.Raycast:
                StartCoroutine(FireOneRay());      // fire a raycast.... change to FireOneRay
                break;

            default:
                Debug.Log("error in bullet type");
                break;
            }
            if (Animat != null)
            {
                if (isAmed)
                {
                    Animat.AimFire();
                }
                else
                {
                    Animat.Fire();
                }
            }
            if (Sync)
            {
                Vector3 position = (typeOfGun == weaponType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                Sync.Firing(weaponType.Machinegun.ToString(), spread, position, transform.parent.rotation);
            }
            GetComponent <AudioSource>().clip   = FireSound;
            GetComponent <AudioSource>().spread = Random.Range(1.0f, 1.5f);
            GetComponent <AudioSource>().pitch  = Random.Range(1.0f, 1.05f);
            GetComponent <AudioSource>().Play();
            shotsFired++;
            bulletsLeft--;
            nextFireTime += fireRate;
            EjectShell();
            Kick();
            StartCoroutine(CamShake());
            StartCoroutine(MuzzleFlash());
            //is Auto reload
            if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
            {
                StartCoroutine(reload());
            }
        }
    }