Added Sound Manager and gave vol Control.
This commit is contained in:
parent
bdc4b2feb7
commit
aa1592ea9f
@ -125,7 +125,7 @@ TextureImporter:
|
||||
width: 2074
|
||||
height: 501
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
@ -146,7 +146,7 @@ TextureImporter:
|
||||
width: 1000
|
||||
height: 398
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
@ -163,11 +163,11 @@ TextureImporter:
|
||||
rect:
|
||||
serializedVersion: 2
|
||||
x: 1513
|
||||
y: 744
|
||||
y: 632
|
||||
width: 569
|
||||
height: 798
|
||||
height: 910
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
outline: []
|
||||
physicsShape: []
|
||||
|
||||
@ -514,10 +514,10 @@ RectTransform:
|
||||
m_Father: {fileID: 263763516}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 170.5, y: -62.5}
|
||||
m_SizeDelta: {x: 249, y: 76}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &39309454
|
||||
MonoBehaviour:
|
||||
@ -1061,9 +1061,9 @@ RectTransform:
|
||||
m_Father: {fileID: 590772468}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 487.5, y: -150}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 250, y: 250}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &72344294
|
||||
@ -2155,7 +2155,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &151341081
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2230,6 +2230,7 @@ MonoBehaviour:
|
||||
baseObjects:
|
||||
- {fileID: 1132189049}
|
||||
- {fileID: 1307957997}
|
||||
- {fileID: 1547560743}
|
||||
--- !u!4 &158202995
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2711,7 +2712,7 @@ GameObject:
|
||||
- component: {fileID: 211380491}
|
||||
- component: {fileID: 211380492}
|
||||
m_Layer: 5
|
||||
m_Name: Slider
|
||||
m_Name: Slider - Main
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -2784,10 +2785,10 @@ MonoBehaviour:
|
||||
m_FillRect: {fileID: 1605934311}
|
||||
m_HandleRect: {fileID: 137284923}
|
||||
m_Direction: 0
|
||||
m_MinValue: 0
|
||||
m_MinValue: 0.0001
|
||||
m_MaxValue: 1
|
||||
m_WholeNumbers: 0
|
||||
m_Value: 0.825
|
||||
m_Value: 1
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
@ -4053,9 +4054,9 @@ MonoBehaviour:
|
||||
canvasGroup: {fileID: 0}
|
||||
fadeDuration: 0
|
||||
closeBtn: {fileID: 828394515}
|
||||
mainVolSlider: {fileID: 0}
|
||||
musicVolSlider: {fileID: 0}
|
||||
sfxVolSlider: {fileID: 0}
|
||||
mainVolSlider: {fileID: 211380492}
|
||||
musicVolSlider: {fileID: 1557638215}
|
||||
sfxVolSlider: {fileID: 871997188}
|
||||
--- !u!1 &327093596
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -9842,7 +9843,7 @@ GameObject:
|
||||
- component: {fileID: 871997187}
|
||||
- component: {fileID: 871997188}
|
||||
m_Layer: 5
|
||||
m_Name: Slider
|
||||
m_Name: Slider - SFX
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -9915,7 +9916,7 @@ MonoBehaviour:
|
||||
m_FillRect: {fileID: 1927713902}
|
||||
m_HandleRect: {fileID: 1398679743}
|
||||
m_Direction: 0
|
||||
m_MinValue: 0
|
||||
m_MinValue: 0.0001
|
||||
m_MaxValue: 1
|
||||
m_WholeNumbers: 0
|
||||
m_Value: 0.558
|
||||
@ -11013,10 +11014,10 @@ RectTransform:
|
||||
m_Father: {fileID: 263763516}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 439.5, y: -62.5}
|
||||
m_SizeDelta: {x: 249, y: 76}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &984740902
|
||||
MonoBehaviour:
|
||||
@ -11199,7 +11200,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1000165775
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -14326,7 +14327,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &1237011202
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -15894,10 +15895,10 @@ RectTransform:
|
||||
m_Father: {fileID: 263763516}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 708.5, y: -62.5}
|
||||
m_SizeDelta: {x: 249, y: 76}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1409739061
|
||||
MonoBehaviour:
|
||||
@ -17727,6 +17728,162 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1540597791}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1547560743
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1547560746}
|
||||
- component: {fileID: 1547560745}
|
||||
- component: {fileID: 1547560744}
|
||||
m_Layer: 0
|
||||
m_Name: SoundManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!82 &1547560744
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1547560743}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: -6863119307137819627, guid: 12870a2f915674f679b5025697171155, type: 2}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!114 &1547560745
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1547560743}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 99c5865aac11841f39f2acc724c0a8eb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
audioSource: {fileID: 1547560744}
|
||||
audioMixer: {fileID: 24100000, guid: 12870a2f915674f679b5025697171155, type: 2}
|
||||
soundDatas:
|
||||
- soundType: 3
|
||||
priority: 1
|
||||
soundClip: {fileID: 8300000, guid: b54c343586ce9417e89b147a9958632c, type: 3}
|
||||
- soundType: 2
|
||||
priority: 1
|
||||
soundClip: {fileID: 8300000, guid: 49ecba8e6ecec4b03aa83364ed90d991, type: 3}
|
||||
- soundType: 0
|
||||
priority: 1
|
||||
soundClip: {fileID: 8300000, guid: ab84af1777a3b46eb9e9b48241f8b760, type: 3}
|
||||
- soundType: 1
|
||||
priority: 1
|
||||
soundClip: {fileID: 8300000, guid: 570447e081a5e483ea033039c6342f58, type: 3}
|
||||
--- !u!4 &1547560746
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1547560743}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 22
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1548064881
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -17803,7 +17960,7 @@ GameObject:
|
||||
- component: {fileID: 1557638214}
|
||||
- component: {fileID: 1557638215}
|
||||
m_Layer: 5
|
||||
m_Name: Slider
|
||||
m_Name: Slider - BGM
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -17876,10 +18033,10 @@ MonoBehaviour:
|
||||
m_FillRect: {fileID: 711345448}
|
||||
m_HandleRect: {fileID: 2137975464}
|
||||
m_Direction: 0
|
||||
m_MinValue: 0
|
||||
m_MinValue: 0.0001
|
||||
m_MaxValue: 1
|
||||
m_WholeNumbers: 0
|
||||
m_Value: 0.825
|
||||
m_Value: 1
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
@ -21001,9 +21158,9 @@ RectTransform:
|
||||
m_Father: {fileID: 590772468}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 162.5, y: -150}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 250, y: 250}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1927536914
|
||||
|
||||
@ -6,6 +6,8 @@ public class InstructionsPopup : PopupBase
|
||||
[Header("References")]
|
||||
[SerializeField] private Button closeBtn;
|
||||
|
||||
private SoundManager soundManager;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
closeBtn.onClick.AddListener(OnClick_closeBtn);
|
||||
@ -21,6 +23,9 @@ public class InstructionsPopup : PopupBase
|
||||
ScreenManager screenManager = InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>();
|
||||
screenManager.ShowScreen(ScreenType.MenuHUDScreen);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,11 +12,18 @@ public class OptionsPopup : PopupBase
|
||||
private void OnEnable()
|
||||
{
|
||||
closeBtn.onClick.AddListener(OnClick_closeBtn);
|
||||
mainVolSlider.onValueChanged.AddListener(OnMainVolChanged);
|
||||
musicVolSlider.onValueChanged.AddListener(OnBGMVolChanged);
|
||||
sfxVolSlider.onValueChanged.AddListener(OnSFXVolChanged);
|
||||
InitializeSliders();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
closeBtn.onClick.RemoveAllListeners();
|
||||
closeBtn.onClick.RemoveListener(OnClick_closeBtn);
|
||||
mainVolSlider.onValueChanged.RemoveListener(OnMainVolChanged);
|
||||
musicVolSlider.onValueChanged.RemoveListener(OnBGMVolChanged);
|
||||
sfxVolSlider.onValueChanged.RemoveListener(OnSFXVolChanged);
|
||||
}
|
||||
|
||||
private void OnClick_closeBtn()
|
||||
@ -26,5 +33,44 @@ public class OptionsPopup : PopupBase
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
public void OnMainVolChanged(float value)
|
||||
{
|
||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||
if (soundManager != null)
|
||||
{
|
||||
soundManager.SetMainVolume(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBGMVolChanged(float value)
|
||||
{
|
||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||
if (soundManager != null)
|
||||
{
|
||||
soundManager.SetBGMVolume(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnSFXVolChanged(float value)
|
||||
{
|
||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||
if (soundManager != null)
|
||||
{
|
||||
soundManager.SetSFXVolume(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeSliders()
|
||||
{
|
||||
float mainVol = PlayerPrefs.GetFloat("MainVol", 1f);
|
||||
float bgmVol = PlayerPrefs.GetFloat("BGMVol", 1f);
|
||||
float sfxVol = PlayerPrefs.GetFloat("SFXVol", 1f);
|
||||
|
||||
mainVolSlider.value = mainVol;
|
||||
musicVolSlider.value = bgmVol;
|
||||
sfxVolSlider.value = sfxVol;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ public class PvAIModePopup : PopupBase
|
||||
private string playerName;
|
||||
|
||||
private ScreenManager screenManager;
|
||||
private SoundManager soundManager;
|
||||
private int selectedPlayerCount;
|
||||
public int SelectedPlayerCount => selectedPlayerCount;
|
||||
|
||||
@ -48,6 +49,11 @@ public class PvAIModePopup : PopupBase
|
||||
{
|
||||
playerName = playerNameInput.text;
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
//TODO: Start PvAI Game with the selected player count and name
|
||||
|
||||
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
||||
Debug.Log($"Player 1: {playerName}");
|
||||
|
||||
@ -57,6 +63,8 @@ public class PvAIModePopup : PopupBase
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.ShowScreen(ScreenType.MenuHUDScreen);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,8 @@ public class GameHUDS : ScreenBase
|
||||
[SerializeField] private TMP_Text diceCountText;
|
||||
[SerializeField] private TMP_Text playerTurnText;
|
||||
|
||||
SoundManager soundManager;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
pauseBtn.onClick.AddListener(OnClick_pauseBtn);
|
||||
@ -25,6 +27,9 @@ public class GameHUDS : ScreenBase
|
||||
PopupManager popupManager = InterfaceManager.Instance?.GetInterfaceInstance<PopupManager>();
|
||||
popupManager.ShowPopup(PopupType.PauseMenuPopup);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ public class MenuHUDScreen : ScreenBase
|
||||
[SerializeField] private Button exitBtn;
|
||||
|
||||
private PopupManager popupManager;
|
||||
private SoundManager soundManager;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@ -37,6 +38,9 @@ public class MenuHUDScreen : ScreenBase
|
||||
popupManager = popupManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<PopupManager>() : popupManager;
|
||||
popupManager.ShowPopup(PopupType.PvPModePopup);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Hide();
|
||||
// screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
// screenManager.HideScreen(ScreenType.MenuHUDScreen);
|
||||
@ -47,6 +51,9 @@ public class MenuHUDScreen : ScreenBase
|
||||
popupManager = popupManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<PopupManager>() : popupManager;
|
||||
popupManager.ShowPopup(PopupType.PvAIModePopup);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
@ -55,6 +62,9 @@ public class MenuHUDScreen : ScreenBase
|
||||
popupManager = popupManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<PopupManager>() : popupManager;
|
||||
popupManager.ShowPopup(PopupType.OptionsPopup);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
@ -63,11 +73,17 @@ public class MenuHUDScreen : ScreenBase
|
||||
popupManager = popupManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<PopupManager>() : popupManager;
|
||||
popupManager.ShowPopup(PopupType.InstructionsPopup);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void OnClick_exitBtn()
|
||||
{
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ public class PvPModePopup : PopupBase
|
||||
private string playerFourName;
|
||||
|
||||
private ScreenManager screenManager;
|
||||
private SoundManager soundManager;
|
||||
private int selectedPlayerCount;
|
||||
public int SelectedPlayerCount => selectedPlayerCount;
|
||||
|
||||
@ -65,6 +66,10 @@ public class PvPModePopup : PopupBase
|
||||
playerThreeName = playerThreeNameInput.text;
|
||||
playerFourName = playerFourNameInput.text;
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
//TODO: Start PVP Game with the selected player count and names
|
||||
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
||||
Debug.Log($"Player 1: {playerOneName}");
|
||||
Debug.Log($"Player 2: {playerTwoName}");
|
||||
@ -80,6 +85,9 @@ public class PvPModePopup : PopupBase
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.ShowScreen(ScreenType.MenuHUDScreen);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,8 @@ public class PauseMenuPopup : PopupBase
|
||||
[SerializeField] private Button playBtn;
|
||||
[SerializeField] private Button exitBtn;
|
||||
|
||||
SoundManager soundManager;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
playBtn.onClick.AddListener(OnClick_playBtn);
|
||||
@ -27,12 +29,18 @@ public class PauseMenuPopup : PopupBase
|
||||
ScreenManager screenManager = InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>();
|
||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void OnClick_homeBtn()
|
||||
{
|
||||
//TODO: Implement Home Button Functionality
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
}
|
||||
|
||||
private void OnClick_exitBtn()
|
||||
|
||||
116
Assets/Scripts/UI/SoundManager.cs
Normal file
116
Assets/Scripts/UI/SoundManager.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
public enum SoundType
|
||||
{
|
||||
Jump,
|
||||
SafeZoneEnter,
|
||||
Dice,
|
||||
ButtonClick
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SoundData
|
||||
{
|
||||
public SoundType soundType;
|
||||
public int priority;
|
||||
public AudioClip soundClip;
|
||||
}
|
||||
|
||||
public class SoundManager : MonoBehaviour, IBootLoader, IBase, IDataLoader
|
||||
{
|
||||
[SerializeField] AudioSource audioSource;
|
||||
[SerializeField] private AudioMixer audioMixer;
|
||||
[SerializeField] private SoundData[] soundDatas;
|
||||
|
||||
private float volTimer = 0, cachedSecVolTimer = 0;
|
||||
private bool startVolTimer = false;
|
||||
public bool IsGameSoundOn
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private Dictionary<SoundType, SoundData> soundDataDict = new Dictionary<SoundType, SoundData>();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
InterfaceManager.Instance?.RegisterInterface<SoundManager>(this);
|
||||
}
|
||||
|
||||
public void InitializeData()
|
||||
{
|
||||
audioSource.priority = 0;
|
||||
for (int idx = 0; idx < soundDatas.Length; idx++)
|
||||
{
|
||||
if (soundDataDict.ContainsKey(soundDatas[idx].soundType))
|
||||
soundDataDict[soundDatas[idx].soundType] = soundDatas[idx];
|
||||
else
|
||||
soundDataDict.Add(soundDatas[idx].soundType, soundDatas[idx]);
|
||||
}
|
||||
|
||||
SetMainVolume(PlayerPrefs.GetFloat("MainVol", 1f));
|
||||
SetBGMVolume(PlayerPrefs.GetFloat("BGMVol", 1f));
|
||||
SetSFXVolume(PlayerPrefs.GetFloat("SFXVol", 1f));
|
||||
}
|
||||
|
||||
public void SetGameSound(bool state)
|
||||
{
|
||||
IsGameSoundOn = state;
|
||||
}
|
||||
|
||||
public void PlayGameSoundClip(SoundType soundType)
|
||||
{
|
||||
if (!enabled) return;
|
||||
|
||||
SoundData soundData = soundDataDict[soundType];
|
||||
|
||||
audioSource.priority = soundData.priority;
|
||||
audioSource.PlayOneShot(soundData.soundClip);
|
||||
}
|
||||
|
||||
public void PlayButtonSoundClip(SoundType soundType)
|
||||
{
|
||||
SoundData soundData = soundDataDict[soundType];
|
||||
|
||||
audioSource.priority = soundData.priority;
|
||||
audioSource.PlayOneShot(soundData.soundClip);
|
||||
}
|
||||
|
||||
public void SetSFXVolume(float value)
|
||||
{
|
||||
audioMixer.SetFloat("SFXVol", Mathf.Log10(value) * 20);
|
||||
PlayerPrefs.SetFloat("SFXVol", value);
|
||||
Debug.Log($"SFX Volume set to : {audioMixer.GetFloat("SFXVol", out float vol)}");
|
||||
}
|
||||
|
||||
public void SetBGMVolume(float value)
|
||||
{
|
||||
audioMixer.SetFloat("BGMVol", Mathf.Log10(value) * 20);
|
||||
PlayerPrefs.SetFloat("BGMVol", value);
|
||||
Debug.Log($"BGM Volume set to : {audioMixer.GetFloat("BGMVol", out float vol)}");
|
||||
}
|
||||
|
||||
public void SetMainVolume(float value)
|
||||
{
|
||||
audioMixer.SetFloat("MainVol", Mathf.Log10(value) * 20);
|
||||
PlayerPrefs.SetFloat("MainVol", value);
|
||||
Debug.Log($"Main Volume set to : {audioMixer.GetFloat("MainVol", out float vol)}");
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!startVolTimer) return;
|
||||
|
||||
if (volTimer > 0)
|
||||
{
|
||||
volTimer -= Time.deltaTime / 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
volTimer = 0;
|
||||
startVolTimer = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SoundManager.cs.meta
Normal file
11
Assets/Scripts/UI/SoundManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99c5865aac11841f39f2acc724c0a8eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user