Advertisement
KorolevDmitry123

Untitled

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