Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MusicPlayer : MonoBehaviour
- {
- public GUISkin MySkin3;
- public AudioClip[] clips;
- public AudioSource audioSource;
- public bool playrandom;
- public bool consistentaly;
- public bool pause;
- public bool nexttrack;
- public bool previoustrack;
- private float timer;
- private float timer1;
- public Texture2D playing;
- public Texture2D pauseplaying;
- public Texture2D nt;
- public Texture2D pt;
- public int ScoreBoxWicth;
- public int ScoreBoxWicth1;
- public int ScoreBoxHeight;
- public int SpriteBoxWicth;
- public int SpriteBoxHeight;
- public PauseM z;
- public Pause c;
- public bool output;
- public bool output1;
- public bool ta;
- private string nameofsingle;
- private bool b;
- public ChangeCamera m;
- public ChangeCamera2 n;
- public ChangeCamera3 o;
- public ChangeCamera5 p;
- public ChangeCamera6 r;
- public ChangeCamera4 s;
- public ChangeCamera7 t;
- public ChangeCamera8 y;
- public ChangeCamera9 v;
- void Start()
- {
- timer = 0.0f;
- timer1 = 0.0f;
- audioSource.loop = false;
- }
- protected AudioClip PlayClip()// эти строчки я списал
- {
- return clips[Random.Range(0, clips.Length)];
- }
- void Update()
- {
- if (consistentaly == true)
- {
- }
- if (playrandom == true)// тут он трек выбирает рандомно
- {
- audioSource.clip = PlayClip();// и эту
- if (pause == false)
- {
- audioSource.Play();
- }
- consistentaly = false;
- }
- if (Input.GetKeyDown(KeyCode.F1))// тут паузу включаю
- {
- if (pause == true)
- {
- pause = false;
- audioSource.Play();
- }
- else if (pause == false)
- {
- pause = true;
- audioSource.Pause();
- }
- }
- if (pause == false)
- {
- if (Input.GetKeyDown(KeyCode.F2))// здесь я хочу предыдущий трек включить
- {
- previoustrack = true;
- }
- if (Input.GetKeyDown(KeyCode.F3))// здесь следующий
- {
- nexttrack = true;
- }
- }
- if (Input.GetKeyDown(KeyCode.F4))// тут я отправляю его трек выбирать
- {
- playrandom = true;
- }
- if (playrandom == true)// тут ему передаю что хватит выбирать (хочу сделать чтоб после он дальше их последовательно включал)
- {
- if (timer <= 0.0f || timer >= 0.0f)
- {
- timer += Time.deltaTime;
- }
- if (timer >= 0.2f)
- {
- timer = 0.0f;
- playrandom = false;
- consistentaly = true;
- pause = false;
- }
- }
- if (previoustrack == true)
- {
- }
- if (nexttrack == true)
- {
- }
- if (b == true)
- {
- if (timer1 <= 0.0f || timer1 >= 0.0f)
- {
- timer1 += Time.deltaTime;
- }
- if (timer1 >= 0.2f)
- {
- timer1 = 0.0f;
- nexttrack = false;
- previoustrack = false;
- b = false;
- }
- }
- if (Input.GetKeyUp(KeyCode.Tab))
- {
- if (ta == true)
- {
- ta = false;
- }
- else if (ta == false)
- {
- ta = true;
- }
- }
- if (ta == true)
- {
- if (z.timing == 1 && c.timing == 1)
- {
- output = true;
- }
- else if (z.timing == 0 && c.timing == 0)
- {
- output = false;
- }
- 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)
- {
- output = false;
- output1 = true;
- }
- 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)
- {
- output1 = false;
- }
- }
- else if (ta == false)
- {
- output = false;
- output1 = false;
- }
- }
- public void PlayClips()// тут я при включении предохраняюсь от того чтоб он их выбирал и включаю последовательное воспроизведение
- {
- playrandom = false;
- consistentaly = true;
- }
- void OnGUI()
- {
- GUI.skin = MySkin3;
- if (output == true)
- {
- GUI.Box(new Rect(0, 55, ScoreBoxWicth, ScoreBoxHeight), "" + nameofsingle);
- if (pause == false)
- {
- if (b == false)
- {
- GUI.DrawTexture(new Rect(0, 53, SpriteBoxWicth, SpriteBoxHeight), playing);
- }
- }
- if (pause == true)
- {
- GUI.DrawTexture(new Rect(0, 53, SpriteBoxWicth, SpriteBoxHeight), pauseplaying);
- }
- if (previoustrack == true)
- {
- b = true;
- GUI.DrawTexture(new Rect(0, 53, SpriteBoxWicth, SpriteBoxHeight), pt);
- }
- else if (nexttrack == true)
- {
- b = true;
- GUI.DrawTexture(new Rect(0, 53, SpriteBoxWicth, SpriteBoxHeight), nt);
- }
- }
- if (output1 == true)
- {
- GUI.Box(new Rect(0, 33, ScoreBoxWicth1, ScoreBoxHeight), "" + nameofsingle);
- if (pause == false)
- {
- if (b == false)
- {
- GUI.DrawTexture(new Rect(0, 31, SpriteBoxWicth, SpriteBoxHeight), playing);
- }
- }
- if (pause == true)
- {
- GUI.DrawTexture(new Rect(0, 31, SpriteBoxWicth, SpriteBoxHeight), pauseplaying);
- }
- if (previoustrack == true)
- {
- b = true;
- GUI.DrawTexture(new Rect(0, 31, SpriteBoxWicth, SpriteBoxHeight), pt);
- }
- else if (nexttrack == true)
- {
- b = true;
- GUI.DrawTexture(new Rect(0, 31, SpriteBoxWicth, SpriteBoxHeight), nt);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement