コード例 #1
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
    /// <summary>
    ///
    /// </summary>
    protected override void OnEnable()
    {
        base.OnEnable();
        Source.clip = TakeSound;
        Source.Play();
        if (Animat)
        {
            Animat.DrawWeapon();
        }
        CanFire = true;
        CanAim  = true;
        bl_EventHandler.OnKitAmmo  += this.OnPickUpAmmo;
        bl_EventHandler.OnRoundEnd += this.OnRoundEnd;

        if (Info.Type == GunType.Grenade || Info.Type == GunType.Shotgun)
        {
            Crosshair.Change(2);
        }
        else if (Info.Type == GunType.Knife)
        {
            Crosshair.Change(1);
        }
        else
        {
            Crosshair.Change(0);
        }
        if (inReloadMode)
        {
            StartCoroutine(reload(0.2f));
        }
    }
コード例 #2
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());
        }
    }
コード例 #3
0
ファイル: Animation.cs プロジェクト: cesarl94/GGJ2021-Unity
	public void beginAnimation(string name) {
		if (!animations2.ContainsKey(name) || name == currentAnimation.name) return;
		if (name == "death") {
			frameDuration *= 3;
		}
		currentAnimation = animations2[name];
		lastAnimationBegin = Time.time;
	}
コード例 #4
0
 public Animal other; // 上一次交换的对象
 // Use this for initialization
 void Start()
 {
     agent       = new Animat(GetComponent <Animator>());
     sprite      = GetComponent <SpriteRenderer>();
     move        = GetComponent <Move>();
     move.animal = this;
     RandomColor();
 }
コード例 #5
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
    /// <summary>
    /// burst shooting
    /// </summary>
    /// <returns></returns>
    IEnumerator Burst_Fire()
    {
        int shotCounter = 0;

        // 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)
        {
            while (shotCounter < roundsPerBurst)
            {
                isBursting = true;

                StartCoroutine(FireOneShot());  // fire a physical bullet

                shotCounter++;
                shotsFired++;
                bulletsLeft--; // subtract a bullet
                Kick();
                EjectShell();
                bl_EventHandler.OnLocalPlayerShake(ShakeIntense, 0.25f, 0.03f, isAmed);
                if (muzzleFlash)
                {
                    muzzleFlash.Play();
                }
                if (Sync)
                {
                    Vector3 position = (Info.Type == GunType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                    Sync.Firing(GunType.Burst.ToString(), spread, position, transform.parent.rotation, Info.Damage);
                }
                if (Animat != null)
                {
                    Animat.Fire();
                }
                if (FireSound)
                {
                    Source.clip   = FireSound;
                    Source.spread = Random.Range(1.0f, 1.5f);
                    Source.Play();
                }

                yield return(new WaitForSeconds(lagBetweenShots));
            }

            nextFireTime += Info.FireRate;
            //is Auto reload
            if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
            {
                StartCoroutine(reload());
            }
        }
        isBursting = false;
    }
コード例 #6
0
    /// fire the sniper gun
    void Sniper_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)
            {
                Animat.Fire();
            }
            if (Sync)
            {
                Vector3 position = (typeOfGun == weaponType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                Sync.Firing(weaponType.Sniper.ToString(), spread, position, transform.parent.rotation);
            }
            StartCoroutine(DelayFireSound());
            shotsFired++;
            bulletsLeft--;
            nextFireTime += fireRate;
            EjectShell();
            Kick();
            StartCoroutine(CamShake());
            if (!isAmed)
            {
                StartCoroutine(MuzzleFlash());
            }
            //is Auto reload
            if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
            {
                StartCoroutine(reload());
            }
        }
    }
コード例 #7
0
    /// <summary>
    /// fire the shotgun
    /// </summary>
    void ShotGun_Fire()
    {
        int pelletCounter = 0;  // counter used for pellets per round

        if (bulletsLeft <= 0 && numberOfClips > 0)
        {
            StartCoroutine(reload()); // if out of ammo, 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)
        {
            do
            {
                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 (Sync)
                {
                    Sync.Firing(bl_Gun.weaponType.Shotgun.ToString(), spread);
                }
                pelletCounter++;                      // add another pellet
                shotsFired++;                         // another shot was fired
            } while (pelletCounter < pelletsPerShot); // if number of pellets fired is less then pellets per round... fire more pellets

            StartCoroutine(DelayFireSound());
            if (Animat != null)
            {
                Animat.Fire();
            }
            StartCoroutine(CamShake());
            EjectShell();             // eject 1 shell
            nextFireTime += fireRate; // can fire another shot in "firerate" number of frames
            bulletsLeft--;            // subtract a bullet
            Kick();
        }
    }
コード例 #8
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;
        }
    }
コード例 #9
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
    IEnumerator Launcher_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;
        }
        bool already = false;

        // Keep firing until we used up the fire time
        while (nextFireTime < Time.time)
        {
            if (!already)
            {
                nextFireTime += Info.FireRate;  // can fire another shot in "fire rate" number of frames
                if (Animat != null)
                {
                    Animat.Fire();
                }
                yield return(new WaitForSeconds(DelayFire));

                Vector3 angular = (Random.onUnitSphere * 10f);
                StartCoroutine(FireOneProjectile(angular)); // fire 1 round
                bulletsLeft--;                              // subtract a bullet
                Kick();
                if (Sync)
                {
                    Vector3 position = (Info.Type == GunType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                    Sync.FiringGrenade(spread, position, transform.parent.rotation, angular);
                }
                if (FireSound)
                {
                    Source.clip   = FireSound;
                    Source.spread = Random.Range(1.0f, 1.5f);
                    Source.Play();
                }
                bl_EventHandler.OnLocalPlayerShake(ShakeIntense, 0.75f, 0.07f, isAmed);
                isFiring = false;
                //is Auto reload
                if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
                {
                    StartCoroutine(reload(1.2f));
                }
                already = true;
            }
            else
            {
                yield break;
            }
        }
    }
コード例 #10
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
    /// <summary>
    ///
    /// </summary>
    private float Knife_Fire()
    {
        // If there is more than one shot  between the last and this frame
        // Reset the nextFireTime
        if (Time.time - Info.FireRate > nextFireTime)
        {
            nextFireTime = Time.time - Time.deltaTime;
        }

        float time = 0;

        // Keep firing until we used up the fire time
        while (nextFireTime < Time.time)
        {
            Vector3 position  = Camera.main.transform.position;
            Vector3 direction = Camera.main.transform.TransformDirection(Vector3.forward);

            RaycastHit hit;
            if (Physics.Raycast(position, direction, out hit, Info.Range))
            {
                if (hit.transform.tag == "BodyPart")
                {
                    if (hit.transform.GetComponent <bl_BodyPart>() != null)
                    {
                        hit.transform.GetComponent <bl_BodyPart>().GetDamage(Info.Damage, PhotonNetwork.player.NickName, Info.Name, transform.position, GunID);
                    }
                }
            }

            if (Animat != null)
            {
                time = Animat.KnifeFire();
            }
            else
            {
            }
            if (Sync)
            {
                Sync.Firing(GunType.Knife.ToString(), 0, 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();
            nextFireTime += Info.FireRate;
            Kick();
            bl_EventHandler.OnLocalPlayerShake(ShakeIntense, 0.25f, 0.03f, isAmed);
            Crosshair.OnFire();
            isFiring = false;
        }
        return(time);
    }
コード例 #11
0
    IEnumerator Launcher_Fire()
    {
        // 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;
        }
        bool already = false;

        // Keep firing until we used up the fire time
        while (nextFireTime < Time.time)
        {
            if (!already)
            {
                nextFireTime += fireRate;  // can fire another shot in "firerate" number of frames
                if (Animat != null)
                {
                    Animat.Fire();
                }
                yield return(new WaitForSeconds(DelayFire));

                StartCoroutine(FireOneProjectile()); // fire 1 round
                bulletsLeft--;                       // subtract a bullet
                Kick();
                if (Sync)
                {
                    Vector3 position = (typeOfGun == weaponType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                    Sync.Firing(weaponType.Launcher.ToString(), spread, position, transform.parent.rotation);
                }
                if (FireSound)
                {
                    GetComponent <AudioSource>().clip   = FireSound;
                    GetComponent <AudioSource>().spread = Random.Range(1.0f, 1.5f);
                    GetComponent <AudioSource>().Play();
                }
                StartCoroutine(CamShake());
                isFiring = false;
                //is Auto reload
                if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
                {
                    StartCoroutine(reload());
                }
                already = true;
            }
            else
            {
                yield break;
            }
        }
    }
コード例 #12
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
    /// <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());
            }
        }
    }
コード例 #13
0
 void OnEnable()
 {
     GetComponent <AudioSource>().clip = TakeSound;
     GetComponent <AudioSource>().Play();
     if (Animat)
     {
         Animat.DrawWeapon();
     }
     CanFire = true;
     CanAim  = true;
     bl_EventHandler.OnKitAmmo  += this.OnPickUpAmmo;
     bl_EventHandler.OnRoundEnd += this.OnRoundEnd;
     Cross.movementScale         = CrossHairScale;
 }
コード例 #14
0
 /// When we disable the gun ship called the animation
 /// and disable the basic functions
 public void DisableWeapon()
 {
     CanAim      = false;
     isReloading = false;
     CanFire     = false;
     if (Animat)
     {
         Animat.HideWeapon();
     }
     if (GManager != null)
     {
         GManager.heatReloadAnim(0);
     }
     StopAllCoroutines();
 }
コード例 #15
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
    /// <summary>
    /// fire the sniper gun
    /// </summary>
    void Sniper_Fire()
    {
        isAmed = false;
        // 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)
        {
            mIsSniperReloading = true;
            mLastSniperTime    = Time.time;
            StartCoroutine(FireOneShot());  // fire a physical bullet

            if (Animat != null)
            {
                Animat.Fire();
            }
            if (Sync)
            {
                Vector3 position = (Info.Type == GunType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                Sync.Firing(GunType.Sniper.ToString(), spread, position, transform.parent.rotation, Info.Damage);
            }
            StartCoroutine(DelayFireSound());
            shotsFired++;
            bulletsLeft--;
            nextFireTime += Info.FireRate;
            EjectShell();
            Kick();
            bl_EventHandler.OnLocalPlayerShake(ShakeIntense, 0.25f, 0.03f, isAmed);
            if (!isAmed)
            {
                if (muzzleFlash)
                {
                    muzzleFlash.Play();
                }
            }
            //is Auto reload
            if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
            {
                StartCoroutine(reload(delayForSecondFireSound + 0.2f));
            }
        }
    }
コード例 #16
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
    /// <summary>
    /// fire the shotgun
    /// </summary>
    void ShotGun_Fire()
    {
        int pelletCounter = 0;  // counter used for pellets per round

        // 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)
        {
            do
            {
                StartCoroutine(FireOneShot());  // fire a physical bullet

                if (Sync)
                {
                    Vector3 position = (Info.Type == GunType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                    Sync.Firing(GunType.Shotgun.ToString(), spread, position, transform.parent.rotation, Info.Damage);
                }
                pelletCounter++;                      // add another pellet
                shotsFired++;                         // another shot was fired
            } while (pelletCounter < pelletsPerShot); // if number of pellets fired is less then pellets per round... fire more pellets

            StartCoroutine(DelayFireSound());
            if (Animat != null)
            {
                Animat.Fire();
            }
            bl_EventHandler.OnLocalPlayerShake(ShakeIntense, 0.25f, 0.03f, isAmed);
            EjectShell();                  // eject 1 shell
            nextFireTime += Info.FireRate; // can fire another shot in "fire rate" number of frames
            bulletsLeft--;                 // subtract a bullet
            Kick();
            //is Auto reload
            if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
            {
                StartCoroutine(reload(delayForSecondFireSound + 0.3f));
            }
        }
    }
コード例 #17
0
    /// <summary>
    /// fire your launcher
    /// </summary>
    IEnumerator Launcher_Fire()
    {
        if (bulletsLeft == 0)
        {
            StartCoroutine(reload()); // if out of ammo, reload
            yield return(null);
        }

        // 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)
        {
            nextFireTime += fireRate;  // can fire another shot in "firerate" number of frames
            if (Animat != null)
            {
                Animat.Fire();
            }
            yield return(new WaitForSeconds(DelayFire));

            StartCoroutine(FireOneProjectile()); // fire 1 round
            bulletsLeft--;                       // subtract a bullet
            Kick();
            if (Sync)
            {
                Sync.Firing(weaponType.Launcher.ToString(), spread);
            }
            if (FireSound)
            {
                audio.clip   = FireSound;
                audio.spread = Random.Range(1.0f, 1.5f);
                audio.Play();
            }
            StartCoroutine(CamShake());
            isFiring = false;
        }
    }
コード例 #18
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
 /// <summary>
 /// When we disable the gun ship called the animation
 /// and disable the basic functions
 /// </summary>
 public void DisableWeapon(bool isFastKill = false)
 {
     CanAim = false;
     if (isReloading)
     {
         inReloadMode = true; isReloading = false;
     }
     CanFire = false;
     if (Animat)
     {
         Animat.HideWeapon();
     }
     if (GManager != null)
     {
         GManager.heatReloadAnim(0);
     }
     if (!isFastKill)
     {
         StopAllCoroutines();
     }
 }
コード例 #19
0
ファイル: bl_Gun.cs プロジェクト: BlackZIjian/DestroyFps
    /// <summary>
    /// start reload weapon
    /// deduct the remaining bullets in the cartridge of a new clip
    /// as this happens, we disable the options: fire, aim and run
    /// </summary>
    /// <returns></returns>
    IEnumerator reload(float waitTime = 0.2f)
    {
        isAmed  = false;
        CanFire = false;

        if (isReloading)
        {
            yield break;     // if already reloading... exit and wait till reload is finished
        }
        yield return(new WaitForSeconds(waitTime));

        if (numberOfClips > 0 || inReloadMode)//if have at least one cartridge
        {
            if (Animat != null)
            {
                if (Info.Type == GunType.Shotgun)
                {
                    int t_repeat = bulletsPerClip - bulletsLeft; //get the number of spent bullets
                    Animat.ReloadRepeat(Info.ReloadTime, t_repeat);
                }
                else
                {
                    Animat.Reload(Info.ReloadTime);
                }
            }
            if (!SoundReloadByAnim)
            {
                StartCoroutine(ReloadSoundIE());
            }
            isReloading = true;                                // we are now reloading
            //if (!inReloadMode) { numberOfClips--; }// take away a clip
            yield return(new WaitForSeconds(Info.ReloadTime)); // wait for set reload time

            bulletsLeft = bulletsPerClip;                      // fill up the gun
        }
        isReloading  = false;                                  // done reloading
        CanAim       = true;
        CanFire      = true;
        inReloadMode = false;
    }
コード例 #20
0
 /// <summary>
 ///
 /// </summary>
 void OnEnable()
 {
     audio.clip = TakeSound;
     audio.Play();
     if (Animat)
     {
         Animat.DrawWeapon();
     }
     CanFire = true;
     CanAim  = true;
     if (!isRegistered)
     {
         isRegistered = true;
         bl_EventHandler.OnKitAmmo  += this.OnPickUpAmmo;
         bl_EventHandler.OnRoundEnd += this.OnRoundEnd;
     }
     m_AmmoSlider = GameObject.Find("SliderAmmo").GetComponent <Slider>();
     if (m_AmmoSlider != null)
     {
         m_AmmoSlider.maxValue = bulletsPerClip;
     }
 }
コード例 #21
0
    /// burst shooting
    IEnumerator Burst_Fire()
    {
        int shotCounter = 0;

        if (bulletsLeft <= 0 && numberOfClips > 0)
        {
            StartCoroutine(reload());
            yield break;//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)
        {
            while (shotCounter < roundsPerBurst)
            {
                isBursting = true;
                //Debug.Log(" shotCounter = " + shotCounter + ", roundsPerBurst = "+roundsPerBurst);
                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;
                }
                //Debug.Log("FireOneShot Called in Fire function.");
                shotCounter++;
                shotsFired++;
                bulletsLeft--; // subtract a bullet
                Kick();
                EjectShell();
                StartCoroutine(CamShake());
                StartCoroutine(MuzzleFlash());
                if (Sync)
                {
                    Vector3 position = (typeOfGun == weaponType.Knife) ? Camera.main.transform.position : muzzlePoint.position;
                    Sync.Firing(weaponType.Burst.ToString(), spread, position, transform.parent.rotation);
                }
                if (Animat != null)
                {
                    Animat.Fire();
                }
                if (FireSound)
                {
                    GetComponent <AudioSource>().clip   = FireSound;
                    GetComponent <AudioSource>().spread = Random.Range(1.0f, 1.5f);
                    GetComponent <AudioSource>().Play();
                }
                yield return(new WaitForSeconds(lagBetweenShots));
            }

            nextFireTime += fireRate;
            //is Auto reload
            if (bulletsLeft <= 0 && numberOfClips > 0 && AutoReload)
            {
                StartCoroutine(reload());
            }
        }
        isBursting = false;
    }