Beispiel #1
0
    public void ResetWeaponStates()
    {
        foreach (var weaponState in _weaponStates)
        {
            weaponState.elapsedSinceLastShot     = weaponState.cooldown;
            weaponState.currentDispersionDegrees = weaponState.defaultDispersionDegrees;

            if (weaponState == _activeWeaponState)
            {
                OnDispersionChanged?.Invoke(weaponState.currentDispersionDegrees);
            }
        }
    }
Beispiel #2
0
    private IEnumerator SimulateRecoilDispersionRoutine(WeaponState weaponState, bool simulateRecoil)
    {
        var startDispersionAmount = simulateRecoil ? MAX_DISPERSION_DEGREE : weaponState.currentDispersionDegrees;
        var elapsed = 0f;

        while (_isActive && elapsed < weaponState.cooldown && weaponState.cooldown > 0f)
        {
            elapsed += Time.deltaTime;
            weaponState.currentDispersionDegrees = Mathf.Lerp(startDispersionAmount, weaponState.defaultDispersionDegrees,
                                                              elapsed / weaponState.cooldown);
            if (weaponState.isActive)
            {
                OnDispersionChanged?.Invoke(weaponState.currentDispersionDegrees);
            }
            yield return(null);
        }
        weaponState.currentDispersionDegrees = weaponState.defaultDispersionDegrees;
    }
Beispiel #3
0
 private void IncreaseDispersionRate()
 {
     _activeWeaponState.currentDispersionDegrees = Mathf.Min(MAX_DISPERSION_DEGREE,
                                                             _activeConfig.dispersionIncrementOverTime * _activeWeaponState.currentDispersionDegrees);
     OnDispersionChanged?.Invoke(_activeWeaponState.currentDispersionDegrees);
 }
Beispiel #4
0
 private void ResetActiveWeaponDispersionRate()
 {
     _activeWeaponState.currentDispersionDegrees = _activeConfig.dispersionDegrees;
     OnDispersionChanged?.Invoke(_activeWeaponState.currentDispersionDegrees);
 }