-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
6,131 additions
and
1,162 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class MusicManager : MonoBehaviour { | ||
private const string PLAYER_PREFS_MUSIC_EFFECTS_VOLUME = "MusicVolume"; | ||
|
||
public static MusicManager Instance { get; private set; } | ||
|
||
private AudioSource audioSource; | ||
private float volume = 0.3f; | ||
|
||
private void Awake() { | ||
Instance = this; | ||
|
||
audioSource = GetComponent<AudioSource>(); | ||
|
||
volume = PlayerPrefs.GetFloat(PLAYER_PREFS_MUSIC_EFFECTS_VOLUME, 0.3f); | ||
audioSource.volume = volume; | ||
} | ||
|
||
public void ChangeVolume() { | ||
volume += 0.1f; | ||
if(volume > 1f) { | ||
volume = 0f; | ||
} | ||
audioSource.volume = volume; | ||
|
||
PlayerPrefs.SetFloat(PLAYER_PREFS_MUSIC_EFFECTS_VOLUME, volume); | ||
PlayerPrefs.Save(); | ||
} | ||
|
||
public float GetVolume() { | ||
return volume; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using TMPro; | ||
|
||
public class OptionsUI : MonoBehaviour { | ||
public static OptionsUI Instance { get; private set; } | ||
|
||
[SerializeField] private Button soundEffectsButton; | ||
[SerializeField] private Button musicButton; | ||
[SerializeField] private Button closeButton; | ||
[SerializeField] private Button moveUpButton; | ||
[SerializeField] private Button moveDownButton; | ||
[SerializeField] private Button moveLeftButton; | ||
[SerializeField] private Button moveRightButton; | ||
[SerializeField] private Button interactButton; | ||
[SerializeField] private Button interactAltButton; | ||
[SerializeField] private Button pauseButton; | ||
[SerializeField] private TextMeshProUGUI soundEffectsText; | ||
[SerializeField] private TextMeshProUGUI musicText; | ||
[SerializeField] private TextMeshProUGUI moveUpText; | ||
[SerializeField] private TextMeshProUGUI moveDownText; | ||
[SerializeField] private TextMeshProUGUI moveLeftText; | ||
[SerializeField] private TextMeshProUGUI moveRightText; | ||
[SerializeField] private TextMeshProUGUI interactText; | ||
[SerializeField] private TextMeshProUGUI interactAltText; | ||
[SerializeField] private TextMeshProUGUI pauseText; | ||
[SerializeField] private Transform pressToRebindKeyTransform; | ||
|
||
private void Awake() { | ||
Instance = this; | ||
|
||
soundEffectsButton.onClick.AddListener(() => { | ||
SoundManager.Instance.ChangeVolume(); | ||
UpdateVisual(); | ||
}); | ||
musicButton.onClick.AddListener(() => { | ||
MusicManager.Instance.ChangeVolume(); | ||
UpdateVisual(); | ||
}); | ||
closeButton.onClick.AddListener(() => { | ||
Hide(); | ||
}); | ||
|
||
moveUpButton.onClick.AddListener(() => { RebindBinding(GameInput.Binding.Move_Up); }); | ||
moveDownButton.onClick.AddListener(() => { RebindBinding(GameInput.Binding.Move_Down); }); | ||
moveLeftButton.onClick.AddListener(() => { RebindBinding(GameInput.Binding.Move_Left); }); | ||
moveRightButton.onClick.AddListener(() => { RebindBinding(GameInput.Binding.Move_Right); }); | ||
interactButton.onClick.AddListener(() => { RebindBinding(GameInput.Binding.Interact); }); | ||
interactAltButton.onClick.AddListener(() => { RebindBinding(GameInput.Binding.InteractAlternate); }); | ||
pauseButton.onClick.AddListener(() => { RebindBinding(GameInput.Binding.Pause); }); | ||
} | ||
|
||
private void Start() { | ||
KitchenGameManager.Instance.OnGameUnpaused += KitchenGameManager_OnGameUnpaused; | ||
|
||
UpdateVisual(); | ||
Hide(); | ||
HidePressToRebindKey(); | ||
} | ||
|
||
private void KitchenGameManager_OnGameUnpaused(object sender, System.EventArgs e) { | ||
Hide(); | ||
} | ||
|
||
private void UpdateVisual() { | ||
soundEffectsText.text = "Sound Effects: " + Mathf.Round(SoundManager.Instance.GetVolume() * 10f); | ||
musicText.text = "Music Effects: " + Mathf.Round(MusicManager.Instance.GetVolume() * 10f); | ||
|
||
moveUpText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Move_Up); | ||
moveDownText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Move_Down); | ||
moveLeftText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Move_Left); | ||
moveRightText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Move_Right); | ||
interactText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Interact); | ||
interactAltText.text = GameInput.Instance.GetBindingText(GameInput.Binding.InteractAlternate); | ||
pauseText.text = GameInput.Instance.GetBindingText(GameInput.Binding.Pause); | ||
} | ||
|
||
public void Show() { | ||
gameObject.SetActive(true); | ||
} | ||
|
||
private void Hide() { | ||
gameObject.SetActive(false); | ||
} | ||
|
||
public void ShowPressToRebindKey() { | ||
pressToRebindKeyTransform.gameObject.SetActive(true); | ||
} | ||
|
||
private void HidePressToRebindKey() { | ||
pressToRebindKeyTransform.gameObject.SetActive(false); | ||
} | ||
|
||
private void RebindBinding(GameInput.Binding binding) { | ||
ShowPressToRebindKey(); | ||
GameInput.Instance.RebindBinding(binding, () => { | ||
HidePressToRebindKey(); | ||
UpdateVisual(); | ||
}); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.