void StartGunProcessIfItsNot() { if (step == stepEnum.Start) { step = stepEnum.FirstDelayAfterReload; } }
void ResetSteps() { step = stepEnum.Start; ResetCurrentMagazineCount(); ResetCurrentFireLoopCount(); ResetFireTimeCounter(); ResetBetwennFireLoopsTimeCounter(); ResetFirstShotAfterReloadDelayTimeCounter(); }
// Update is called once per frame void Update() { if (NeedsReload()) { return; } if (step == stepEnum.FirstDelayAfterReload) { firstShotAfterReloadDelayTimeCounter -= Time.deltaTime; if (firstShotAfterReloadDelayTimeCounter <= 0) { ResetFirstShotAfterReloadDelayTimeCounter(); step = stepEnum.Ready; goto End; } } if (step == stepEnum.Firing) { fireTimeCounter -= Time.deltaTime; if (fireTimeCounter <= 0) { ResetFireTimeCounter(); if (currentFireLoopCount == 0) { step = stepEnum.BetweenFireLoops; goto End; } step = stepEnum.Ready; goto End; } } if (step == stepEnum.BetweenFireLoops) { betweenFireLoopsTimeCounter -= Time.deltaTime; if (betweenFireLoopsTimeCounter <= 0) { ResetBetwennFireLoopsTimeCounter(); ResetCurrentFireLoopCount(); step = stepEnum.Ready; goto End; } } End: return; }
bool FireIfCan() { if (NeedsReload()) { return(false); } StartGunProcessIfItsNot(); if (step == stepEnum.Ready) { currentMagazieCount--; currentFireLoopCount--; //soundPlay.PlaySound_FX(soundsFire, Random.Range(fireSoundMinPitch, fireSoundMaxPitch)); PlayShootSound(); CreateBullet(); step = stepEnum.Firing; return(true); } return(false); }