completed sounds
This commit is contained in:
1 parent
3938d93241
commit
be3defc280
12 files changed
+1084
-22
No files matched your search
@@ -16,13 +16,18 @@ namespace Code.Gameplay.Enemies
|
|||||||
[SerializeField] private float _blinkDuration = 0.2f;
|
[SerializeField] private float _blinkDuration = 0.2f;
|
||||||
[SerializeField] private Color _hitColor = Color.red;
|
[SerializeField] private Color _hitColor = Color.red;
|
||||||
|
|
||||||
|
[SerializeField] private AudioSource _audioSource;
|
||||||
|
|
||||||
private Color _originalColor;
|
private Color _originalColor;
|
||||||
|
|
||||||
private Vector3 _startPosition;
|
private Vector3 _startPosition;
|
||||||
private bool _facingRight = true;
|
private bool _facingRight = true;
|
||||||
|
|
||||||
|
private AudioClip _deathClip;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
_deathClip = Resources.Load<AudioClip>("Audio/SFX/BirdDeathSFX");
|
||||||
_startPosition = transform.position;
|
_startPosition = transform.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +98,7 @@ namespace Code.Gameplay.Enemies
|
|||||||
|
|
||||||
private void Die()
|
private void Die()
|
||||||
{
|
{
|
||||||
|
_audioSource.PlayOneShot(_deathClip);
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace Code.Gameplay.Player
|
|||||||
public float nextAttackTime => _lastAttackTime + _attackCooldown;
|
public float nextAttackTime => _lastAttackTime + _attackCooldown;
|
||||||
|
|
||||||
private AudioClip _attackClip;
|
private AudioClip _attackClip;
|
||||||
|
private AudioClip _damageClip;
|
||||||
|
|
||||||
public event Action<int> OnHealthChanged;
|
public event Action<int> OnHealthChanged;
|
||||||
public event Action OnDied;
|
public event Action OnDied;
|
||||||
@@ -39,6 +40,7 @@ namespace Code.Gameplay.Player
|
|||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_attackClip = Resources.Load<AudioClip>("Audio/SFX/AttackSFX");
|
_attackClip = Resources.Load<AudioClip>("Audio/SFX/AttackSFX");
|
||||||
|
_damageClip = Resources.Load<AudioClip>("Audio/SFX/DamageSFX");
|
||||||
_currentHealth = _maxHealth;
|
_currentHealth = _maxHealth;
|
||||||
OnHealthChanged?.Invoke(_currentHealth);
|
OnHealthChanged?.Invoke(_currentHealth);
|
||||||
}
|
}
|
||||||
@@ -59,6 +61,7 @@ namespace Code.Gameplay.Player
|
|||||||
_currentHealth -= _damageFromEnemy;
|
_currentHealth -= _damageFromEnemy;
|
||||||
OnHealthChanged?.Invoke(_currentHealth);
|
OnHealthChanged?.Invoke(_currentHealth);
|
||||||
OnTookDamage?.Invoke();
|
OnTookDamage?.Invoke();
|
||||||
|
audioSource.PlayOneShot(_damageClip);
|
||||||
|
|
||||||
if (_currentHealth <= 0)
|
if (_currentHealth <= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ namespace Code.Gameplay.Player
|
|||||||
[SerializeField] private float _jumpDuration = 0.5f;
|
[SerializeField] private float _jumpDuration = 0.5f;
|
||||||
[SerializeField] private float _sprintPitchMultiplier = 1.2f;
|
[SerializeField] private float _sprintPitchMultiplier = 1.2f;
|
||||||
|
|
||||||
[SerializeField] private AudioSource audioSource;
|
[SerializeField] private AudioSource walkAudioSource;
|
||||||
|
[SerializeField] private AudioSource jumpAudioSource;
|
||||||
|
|
||||||
private IInputService _input;
|
private IInputService _input;
|
||||||
private bool _isJumping;
|
private bool _isJumping;
|
||||||
@@ -39,8 +40,6 @@ namespace Code.Gameplay.Player
|
|||||||
private AudioClip _jumpClip;
|
private AudioClip _jumpClip;
|
||||||
private AudioClip _walkClip;
|
private AudioClip _walkClip;
|
||||||
|
|
||||||
private bool _wasMovingLastFrame;
|
|
||||||
|
|
||||||
public bool isGrounded { get; private set; }
|
public bool isGrounded { get; private set; }
|
||||||
|
|
||||||
public void Construct(IInputService input)
|
public void Construct(IInputService input)
|
||||||
@@ -79,7 +78,7 @@ namespace Code.Gameplay.Player
|
|||||||
{
|
{
|
||||||
case true when isGrounded:
|
case true when isGrounded:
|
||||||
_isJumping = true;
|
_isJumping = true;
|
||||||
audioSource.PlayOneShot(_jumpClip);
|
jumpAudioSource.PlayOneShot(_jumpClip);
|
||||||
_jumpTimer = 0f;
|
_jumpTimer = 0f;
|
||||||
_rb.linearVelocity = new Vector2(_rb.linearVelocity.x, _jumpForce);
|
_rb.linearVelocity = new Vector2(_rb.linearVelocity.x, _jumpForce);
|
||||||
break;
|
break;
|
||||||
@@ -159,17 +158,24 @@ namespace Code.Gameplay.Player
|
|||||||
|
|
||||||
_rb.linearVelocity = new Vector2(targetVelocityX, _rb.linearVelocity.y);
|
_rb.linearVelocity = new Vector2(targetVelocityX, _rb.linearVelocity.y);
|
||||||
|
|
||||||
// Проигрываем звук ходьбы ТОЛЬКО при начале движения
|
if (isMoving && isGrounded)
|
||||||
if (isMoving && !_wasMovingLastFrame && isGrounded)
|
|
||||||
{
|
{
|
||||||
if (_walkClip)
|
if (_walkClip && walkAudioSource)
|
||||||
{
|
{
|
||||||
audioSource.pitch = _input.SprintHeld ? _sprintPitchMultiplier : 1f;
|
walkAudioSource.pitch = _input.SprintHeld ? _sprintPitchMultiplier : 1f;
|
||||||
audioSource.PlayOneShot(_walkClip);
|
if (walkAudioSource.clip != _walkClip)
|
||||||
|
{
|
||||||
|
walkAudioSource.clip = _walkClip;
|
||||||
|
walkAudioSource.Play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
_wasMovingLastFrame = isMoving;
|
else
|
||||||
|
{
|
||||||
|
walkAudioSource.Stop();
|
||||||
|
walkAudioSource.pitch = 1;
|
||||||
|
walkAudioSource.clip = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleJump()
|
private void HandleJump()
|
||||||
@@ -185,12 +191,12 @@ namespace Code.Gameplay.Player
|
|||||||
|
|
||||||
private async void StartBlinking()
|
private async void StartBlinking()
|
||||||
{
|
{
|
||||||
_spriteRenderer.color = new Color(1, 1, 1, 0.5f); // полупрозрачность
|
_spriteRenderer.color = new Color(1, 1, 1, 0.5f);
|
||||||
float blinkDuration = 2f;
|
const float blinkDuration = 2f;
|
||||||
float blinkInterval = 0.1f;
|
const float blinkInterval = 0.1f;
|
||||||
int blinkCount = (int)(blinkDuration / blinkInterval);
|
var blinkCount = (int)(blinkDuration / blinkInterval);
|
||||||
|
|
||||||
for (int i = 0; i < blinkCount; i++)
|
for (var i = 0; i < blinkCount; i++)
|
||||||
{
|
{
|
||||||
_spriteRenderer.enabled = !_spriteRenderer.enabled;
|
_spriteRenderer.enabled = !_spriteRenderer.enabled;
|
||||||
await UniTask.Delay(TimeSpan.FromSeconds(blinkInterval));
|
await UniTask.Delay(TimeSpan.FromSeconds(blinkInterval));
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e5624994353fdd8d5994056b4fa2f67d
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: da45cc662eb37b05fa86d992f932e975
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 43f915a7118825fb58ac724dc23dfe89
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 8
|
||||||
|
defaultSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
preloadAudioData: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user