Advertisement
KorolevDmitry123

Untitled

Apr 16th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.98 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. public class MusicPlayer : MonoBehaviour
  4. {
  5. public GUISkin MySkin3;
  6. public AudioClip[] clips;
  7. public AudioSource audioSource;
  8. public bool playrandom;
  9. public bool consistentaly;
  10. public bool pause;
  11. public bool nexttrack;
  12. public bool previoustrack;
  13. private float timer;
  14. private float timer1;
  15. public Texture2D playing;
  16. public Texture2D pauseplaying;
  17. public Texture2D nt;
  18. public Texture2D pt;
  19. public int ScoreBoxWicth;
  20. public int ScoreBoxWicth1;
  21. public int ScoreBoxHeight;
  22. public int SpriteBoxWicth;
  23. public int SpriteBoxHeight;
  24. public PauseM z;
  25. public Pause c;
  26. public bool output;
  27. public bool output1;
  28. public bool ta;
  29. private string nameofsingle;
  30. private bool b;
  31. public ChangeCamera m;
  32. public ChangeCamera2 n;
  33. public ChangeCamera3 o;
  34. public ChangeCamera5 p;
  35. public ChangeCamera6 r;
  36. public ChangeCamera4 s;
  37. public ChangeCamera7 t;
  38. public ChangeCamera8 y;
  39. public ChangeCamera9 v;
  40. void Start()
  41. {
  42. timer = 0.0f;
  43. timer1 = 0.0f;
  44. audioSource.loop = false;
  45. }
  46. protected AudioClip PlayClip()// эти строчки я списал
  47. {
  48. return clips[Random.Range(0, clips.Length)];
  49.  
  50. }
  51. void Update()
  52. {
  53. if (consistentaly == true)
  54. {
  55.  
  56. }
  57. if (playrandom == true)// тут он трек выбирает рандомно
  58. {
  59. audioSource.clip = PlayClip();// и эту
  60. if (pause == false)
  61. {
  62. audioSource.Play();
  63. }
  64. consistentaly = false;
  65. }
  66. if (Input.GetKeyDown(KeyCode.F1))// тут паузу включаю
  67. {
  68. if (pause == true)
  69. {
  70. pause = false;
  71. audioSource.Play();
  72. }
  73. else if (pause == false)
  74. {
  75. pause = true;
  76. audioSource.Pause();
  77. }
  78. }
  79. if (pause == false)
  80. {
  81. if (Input.GetKeyDown(KeyCode.F2))// здесь я хочу предыдущий трек включить
  82. {
  83. previoustrack = true;
  84. }
  85. if (Input.GetKeyDown(KeyCode.F3))// здесь следующий
  86. {
  87. nexttrack = true;
  88. }
  89. }
  90. if (Input.GetKeyDown(KeyCode.F4))// тут я отправляю его трек выбирать
  91. {
  92. playrandom = true;
  93. }
  94. if (playrandom == true)// тут ему передаю что хватит выбирать (хочу сделать чтоб после он дальше их последовательно включал)
  95. {
  96. if (timer <= 0.0f || timer >= 0.0f)
  97. {
  98. timer += Time.deltaTime;
  99. }
  100. if (timer >= 0.2f)
  101. {
  102. timer = 0.0f;
  103. playrandom = false;
  104. consistentaly = true;
  105. pause = false;
  106. }
  107. }
  108. if (previoustrack == true)
  109. {
  110.  
  111. }
  112. if (nexttrack == true)
  113. {
  114.  
  115. }
  116. if (b == true)
  117. {
  118. if (timer1 <= 0.0f || timer1 >= 0.0f)
  119. {
  120. timer1 += Time.deltaTime;
  121. }
  122. if (timer1 >= 0.2f)
  123. {
  124. timer1 = 0.0f;
  125. nexttrack = false;
  126. previoustrack = false;
  127. b = false;
  128. }
  129. }
  130. if (Input.GetKeyUp(KeyCode.Tab))
  131. {
  132. if (ta == true)
  133. {
  134. ta = false;
  135. }
  136. else if (ta == false)
  137. {
  138. ta = true;
  139. }
  140. }
  141. if (ta == true)
  142. {
  143. if (z.timing == 1 && c.timing == 1)
  144. {
  145. output = true;
  146. }
  147. else if (z.timing == 0 && c.timing == 0)
  148. {
  149. output = false;
  150. }
  151. if (m.whichcam == true || n.whichcam2 == true || o.whichcam3 == true || p.whichcam3 == true || r.whichcam == true || s.whichcam == true || t.whichcam7 == true || y.whichcam8 == true || v.whichcam9 == true)
  152. {
  153. output = false;
  154. output1 = true;
  155. }
  156. else if (m.whichcam == false || n.whichcam2 == false || o.whichcam3 == false || p.whichcam3 == false || r.whichcam == false || s.whichcam == false || t.whichcam7 == false || y.whichcam8 == false || v.whichcam9 == false)
  157. {
  158. output1 = false;
  159. }
  160. }
  161. else if (ta == false)
  162. {
  163. output = false;
  164. output1 = false;
  165. }
  166. }
  167. public void PlayClips()// тут я при включении предохраняюсь от того чтоб он их выбирал и включаю последовательное воспроизведение
  168. {
  169. playrandom = false;
  170. consistentaly = true;
  171. }
  172. void OnGUI()
  173. {
  174. GUI.skin = MySkin3;
  175. if (output == true)
  176. {
  177. GUI.Box(new Rect(0, 55, ScoreBoxWicth, ScoreBoxHeight), "" + nameofsingle);
  178. if (pause == false)
  179. {
  180. if (b == false)
  181. {
  182. GUI.DrawTexture(new Rect(0, 53, SpriteBoxWicth, SpriteBoxHeight), playing);
  183. }
  184. }
  185. if (pause == true)
  186. {
  187. GUI.DrawTexture(new Rect(0, 53, SpriteBoxWicth, SpriteBoxHeight), pauseplaying);
  188. }
  189. if (previoustrack == true)
  190. {
  191. b = true;
  192. GUI.DrawTexture(new Rect(0, 53, SpriteBoxWicth, SpriteBoxHeight), pt);
  193. }
  194. else if (nexttrack == true)
  195. {
  196. b = true;
  197. GUI.DrawTexture(new Rect(0, 53, SpriteBoxWicth, SpriteBoxHeight), nt);
  198. }
  199. }
  200. if (output1 == true)
  201. {
  202. GUI.Box(new Rect(0, 33, ScoreBoxWicth1, ScoreBoxHeight), "" + nameofsingle);
  203. if (pause == false)
  204. {
  205. if (b == false)
  206. {
  207. GUI.DrawTexture(new Rect(0, 31, SpriteBoxWicth, SpriteBoxHeight), playing);
  208. }
  209. }
  210. if (pause == true)
  211. {
  212. GUI.DrawTexture(new Rect(0, 31, SpriteBoxWicth, SpriteBoxHeight), pauseplaying);
  213. }
  214. if (previoustrack == true)
  215. {
  216. b = true;
  217. GUI.DrawTexture(new Rect(0, 31, SpriteBoxWicth, SpriteBoxHeight), pt);
  218. }
  219. else if (nexttrack == true)
  220. {
  221. b = true;
  222. GUI.DrawTexture(new Rect(0, 31, SpriteBoxWicth, SpriteBoxHeight), nt);
  223. }
  224. }
  225. }
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement