mirror of
https://github.com/ryzij/Cube-Tower-Defense.git
synced 2026-07-14 01:56:57 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 14193de8f7 | |||
| 42e301c895 | |||
| 4b3ff895af | |||
| 0d9e55211f |
File diff suppressed because it is too large
Load Diff
@@ -4,6 +4,7 @@ public class AudioManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Wallet _wallet;
|
||||
[SerializeField] private GameManager _gameManager;
|
||||
[SerializeField] private TurretsShop _shop;
|
||||
[SerializeField] private AudioSource _levelBackgroundMusic;
|
||||
[SerializeField] private AudioSource _buildBackgroundMusic;
|
||||
[SerializeField] private AudioSource _winMusic;
|
||||
@@ -22,14 +23,16 @@ public class AudioManager : MonoBehaviour
|
||||
_money = _wallet.Money;
|
||||
_state = _gameManager.CurrentState;
|
||||
|
||||
_wallet.OnMoneyChanged += OnMoneyChanged;
|
||||
//_wallet.OnMoneyChanged += OnMoneyChanged;
|
||||
_gameManager.OnStateChanged += OnStateChanged;
|
||||
_shop.OnTurretBought += OnTurretBought;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_wallet.OnMoneyChanged -= OnMoneyChanged;
|
||||
//_wallet.OnMoneyChanged -= OnMoneyChanged;
|
||||
_gameManager.OnStateChanged -= OnStateChanged;
|
||||
_shop.OnTurretBought -= OnTurretBought;
|
||||
}
|
||||
|
||||
public void PlayBlockDestroySound(BlockScript block)
|
||||
@@ -43,17 +46,22 @@ public class AudioManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMoneyChanged(int money)
|
||||
private void OnTurretBought(TurretShopItem _)
|
||||
{
|
||||
var oldMoney = _money;
|
||||
_money = money;
|
||||
|
||||
if (_moneyChangeSound.Length == 0 || oldMoney <= money)
|
||||
return;
|
||||
|
||||
Play(_moneyChangeSound, ref _moneyChangeSoundIndex);
|
||||
}
|
||||
|
||||
//private void OnMoneyChanged(int money)
|
||||
//{
|
||||
// var oldMoney = _money;
|
||||
// _money = money;
|
||||
|
||||
// if (_moneyChangeSound.Length == 0 || oldMoney <= money)
|
||||
// return;
|
||||
|
||||
// Play(_moneyChangeSound, ref _moneyChangeSoundIndex);
|
||||
//}
|
||||
|
||||
private void OnStateChanged(GameManager.GameState newState)
|
||||
{
|
||||
if (newState == _state ||
|
||||
|
||||
@@ -13,6 +13,7 @@ public class TurretsShop : MonoBehaviour
|
||||
[SerializeField] private TurretShopItem[] _turretShopItems;
|
||||
[SerializeField] private UnityEvent<BlockScript> _onBlockSelected;
|
||||
[SerializeField] private UnityEvent _onBlockDeselected;
|
||||
[SerializeField] private UnityEvent<TurretShopItem> _onTurretBought;
|
||||
|
||||
public IReadOnlyCollection<TurretShopItem> TurretShopItems => _turretShopItems;
|
||||
|
||||
@@ -28,6 +29,12 @@ public class TurretsShop : MonoBehaviour
|
||||
remove => _onBlockDeselected.RemoveListener(value);
|
||||
}
|
||||
|
||||
public event UnityAction<TurretShopItem> OnTurretBought
|
||||
{
|
||||
add => _onTurretBought.AddListener(value);
|
||||
remove => _onTurretBought.RemoveListener(value);
|
||||
}
|
||||
|
||||
private BlockScript _selectedBlock;
|
||||
|
||||
private void OnEnable()
|
||||
@@ -77,6 +84,7 @@ public class TurretsShop : MonoBehaviour
|
||||
|
||||
_wallet.TakeMoney(item.Price);
|
||||
Instantiate(item.TurretPrefab, _selectedBlock.transform.position + Vector3.up, Quaternion.identity, _turretsHolder);
|
||||
_onTurretBought?.Invoke(item);
|
||||
DeselectBlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ public class GameMenuButtons : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameManager _gameManager;
|
||||
[SerializeField] private SandPathBuildService _sandPathBuildService;
|
||||
[SerializeField] private Wallet _wallet;
|
||||
[SerializeField] private Button _mainMenuButton;
|
||||
[SerializeField] private Button _nextLevelButton;
|
||||
[SerializeField] private Button _resetPathButton;
|
||||
@@ -48,6 +49,7 @@ public class GameMenuButtons : MonoBehaviour
|
||||
private void OnResetButtonClick()
|
||||
{
|
||||
_sandPathBuildService.ResetPath();
|
||||
_wallet.TakeMoney(_wallet.Money);
|
||||
_gameManager.CurrentState = GameManager.GameState.BuildingPath;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TimeControlMenu : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button _pauseBtn;
|
||||
[SerializeField] private Button _resumeBtn;
|
||||
[SerializeField] private Button _2xBtn;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_pauseBtn.onClick.AddListener(SwitchPause);
|
||||
_resumeBtn.onClick.AddListener(() => Time.timeScale = 1f);
|
||||
_2xBtn.onClick.AddListener(() => Time.timeScale = 2f);
|
||||
}
|
||||
|
||||
public static void SwitchPause()
|
||||
{
|
||||
Time.timeScale = Time.timeScale > 0f ? 0f : 1f;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 078c659d31556e94687a93d8cf5919d2
|
||||
@@ -136,6 +136,7 @@ MonoBehaviour:
|
||||
m_PrefilterReflectionProbeBlending: 0
|
||||
m_PrefilterReflectionProbeBoxProjection: 0
|
||||
m_PrefilterReflectionProbeAtlas: 1
|
||||
m_PrefilterPointSamplingUpsampling: 1
|
||||
m_ShaderVariantLogLevel: 0
|
||||
m_ShadowCascades: 0
|
||||
m_Textures:
|
||||
|
||||
@@ -136,6 +136,7 @@ MonoBehaviour:
|
||||
m_PrefilterReflectionProbeBlending: 0
|
||||
m_PrefilterReflectionProbeBoxProjection: 0
|
||||
m_PrefilterReflectionProbeAtlas: 0
|
||||
m_PrefilterPointSamplingUpsampling: 1
|
||||
m_ShaderVariantLogLevel: 0
|
||||
m_ShadowCascades: 0
|
||||
m_Textures:
|
||||
|
||||
+216
-9
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user