Advertisement
KorolevDmitry123

Untitled

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