mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 01:56:57 +00:00
Добавил новые состояния для игры
This commit is contained in:
@@ -6,6 +6,8 @@ public class AudioManager : MonoBehaviour
|
|||||||
[SerializeField] private GameManager _gameManager;
|
[SerializeField] private GameManager _gameManager;
|
||||||
[SerializeField] private AudioSource _levelBackgroundMusic;
|
[SerializeField] private AudioSource _levelBackgroundMusic;
|
||||||
[SerializeField] private AudioSource _buildBackgroundMusic;
|
[SerializeField] private AudioSource _buildBackgroundMusic;
|
||||||
|
[SerializeField] private AudioSource _winMusic;
|
||||||
|
[SerializeField] private AudioSource _loseMusic;
|
||||||
[SerializeField] private AudioSource[] _grassBlockDestroySound;
|
[SerializeField] private AudioSource[] _grassBlockDestroySound;
|
||||||
[SerializeField] private AudioSource[] _moneyChangeSound;
|
[SerializeField] private AudioSource[] _moneyChangeSound;
|
||||||
|
|
||||||
@@ -70,6 +72,16 @@ public class AudioManager : MonoBehaviour
|
|||||||
Stop(_levelBackgroundMusic);
|
Stop(_levelBackgroundMusic);
|
||||||
Play(_buildBackgroundMusic);
|
Play(_buildBackgroundMusic);
|
||||||
break;
|
break;
|
||||||
|
case GameManager.GameState.Win:
|
||||||
|
Stop(_levelBackgroundMusic);
|
||||||
|
Stop(_buildBackgroundMusic);
|
||||||
|
Play(_winMusic);
|
||||||
|
break;
|
||||||
|
case GameManager.GameState.Lose:
|
||||||
|
Stop(_levelBackgroundMusic);
|
||||||
|
Stop(_buildBackgroundMusic);
|
||||||
|
Play(_loseMusic);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ public class GameManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
BuildingPath,
|
BuildingPath,
|
||||||
BuildingTurrets,
|
BuildingTurrets,
|
||||||
Level
|
Level,
|
||||||
|
Win,
|
||||||
|
Lose
|
||||||
}
|
}
|
||||||
|
|
||||||
[SerializeField] private Level[] _levels;
|
[SerializeField] private Level[] _levels;
|
||||||
|
|||||||
@@ -40,8 +40,11 @@ public class WinLoseController : MonoBehaviour
|
|||||||
|
|
||||||
private void OnLastEnemyDestroyed()
|
private void OnLastEnemyDestroyed()
|
||||||
{
|
{
|
||||||
if (_isLastLevel)
|
if (!_isLastLevel)
|
||||||
_onWin?.Invoke();
|
return;
|
||||||
|
|
||||||
|
_gameManager.CurrentState = GameManager.GameState.Win;
|
||||||
|
_onWin?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLevelChanged(GameManager.OnLevelChangedEventArgs args)
|
private void OnLevelChanged(GameManager.OnLevelChangedEventArgs args)
|
||||||
@@ -52,6 +55,7 @@ public class WinLoseController : MonoBehaviour
|
|||||||
|
|
||||||
private void OnDeath()
|
private void OnDeath()
|
||||||
{
|
{
|
||||||
|
_gameManager.CurrentState = GameManager.GameState.Lose;
|
||||||
_onGameOver?.Invoke(new OnGameOverEventArgs(_currentLevel));
|
_onGameOver?.Invoke(new OnGameOverEventArgs(_currentLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user