Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. using Audio;
  2. using UnityEngine;
  3. using UnityEngine.Rendering.PostProcessing;
  4.  
  5. public class GameState : MonoBehaviour
  6. {
  7. public SaveManager SaveManager;
  8. public GameObject ppVolume;
  9. public PostProcessProfile pp;
  10. private MotionBlur ppBlur;
  11. public bool graphics = true;
  12. public bool muted;
  13. public bool blur = true;
  14. public bool shake = true;
  15. public bool slowmo = true;
  16. private float sensitivity = 1f;
  17. private float volume;
  18. private float music;
  19. public float fov = 1f;
  20. public float cameraShake = 1f;
  21. public static GameState Instance
  22. {
  23. get;
  24. private set;
  25. }
  26.  
  27. private void Start()
  28. {
  29. Instance = this;
  30. ppBlur = pp.GetSetting<MotionBlur>();
  31. graphics = SaveManager.Instance.state.graphics;
  32. shake = SaveManager.Instance.state.cameraShake;
  33. blur = SaveManager.Instance.state.motionBlur;
  34. slowmo = SaveManager.Instance.state.slowmo;
  35. muted = SaveManager.Instance.state.muted;
  36. sensitivity = SaveManager.Instance.state.sensitivity;
  37. music = SaveManager.Instance.state.music;
  38. volume = SaveManager.Instance.state.volume;
  39. fov = SaveManager.Instance.state.fov;
  40. UpdateSettings();
  41. }
  42.  
  43. public void SetGraphics(bool b)
  44. {
  45. graphics = b;
  46. ppVolume.SetActive(b);
  47. SaveManager.Instance.state.graphics = b;
  48. SaveManager.Instance.Save();
  49. }
  50.  
  51. public void SetBlur(bool b)
  52. {
  53. blur = b;
  54. if (b)
  55. {
  56. ppBlur.shutterAngle.value = 160f;
  57. }
  58. else
  59. {
  60. ppBlur.shutterAngle.value = 0f;
  61. }
  62. SaveManager.Instance.state.motionBlur = b;
  63. SaveManager.Instance.Save();
  64. }
  65.  
  66. public void SetShake(bool b)
  67. {
  68. shake = b;
  69. if (b)
  70. {
  71. cameraShake = 1f;
  72. }
  73. else
  74. {
  75. cameraShake = 0f;
  76. }
  77. SaveManager.Instance.state.cameraShake = b;
  78. SaveManager.Instance.Save();
  79. }
  80.  
  81. public void SetSlowmo(bool b)
  82. {
  83. slowmo = b;
  84. SaveManager.Instance.state.slowmo = b;
  85. SaveManager.Instance.Save();
  86. }
  87.  
  88. public void SetSensitivity(float s)
  89. {
  90. float num = sensitivity = Mathf.Clamp(s, 0f, 5f);
  91. if ((bool)PlayerMovement.Instance)
  92. {
  93. PlayerMovement.Instance.UpdateSensitivity();
  94. }
  95. SaveManager.Instance.state.sensitivity = num;
  96. SaveManager.Instance.Save();
  97. }
  98.  
  99. public void SetMusic(float s)
  100. {
  101. float musicVolume = music = Mathf.Clamp(s, 0f, 1f);
  102. if ((bool)Music.Instance)
  103. {
  104. Music.Instance.SetMusicVolume(musicVolume);
  105. }
  106. SaveManager.Instance.state.music = musicVolume;
  107. SaveManager.Instance.Save();
  108. MonoBehaviour.print("music saved as: " + music);
  109. }
  110.  
  111. public void SetVolume(float s)
  112. {
  113. float num2 = AudioListener.volume = (volume = Mathf.Clamp(s, 0f, 1f));
  114. SaveManager.Instance.state.volume = num2;
  115. SaveManager.Instance.Save();
  116. }
  117.  
  118. public void SetFov(float f)
  119. {
  120. float num = fov = Mathf.Clamp(f, 50f, 150f);
  121. if ((bool)MoveCamera.Instance)
  122. {
  123. MoveCamera.Instance.UpdateFov();
  124. }
  125. SaveManager.Instance.state.fov = num;
  126. SaveManager.Instance.Save();
  127. }
  128.  
  129. public void SetMuted(bool b)
  130. {
  131. AudioManager.Instance.MuteSounds(b);
  132. muted = b;
  133. SaveManager.Instance.state.muted = b;
  134. SaveManager.Instance.Save();
  135. }
  136.  
  137. private void UpdateSettings()
  138. {
  139. SetGraphics(graphics);
  140. SetBlur(blur);
  141. SetSensitivity(sensitivity);
  142. SetMusic(music);
  143. SetVolume(volume);
  144. SetFov(fov);
  145. SetShake(shake);
  146. SetSlowmo(slowmo);
  147. SetMuted(muted);
  148. }
  149.  
  150. public bool GetGraphics()
  151. {
  152. return graphics;
  153. }
  154.  
  155. public float GetSensitivity()
  156. {
  157. return sensitivity;
  158. }
  159.  
  160. public float GetVolume()
  161. {
  162. return volume;
  163. }
  164.  
  165. public float GetMusic()
  166. {
  167. return music;
  168. }
  169.  
  170. public float GetFov()
  171. {
  172. return fov;
  173. }
  174.  
  175. public bool GetMuted()
  176. {
  177. return muted;
  178. }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement