Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (AutoNext)
        {
            m_Button.GetComponent <Image>().sprite = selected;
            //0.02s left for this song
            if (MusicPlayer.GetSongLength() - MusicPlayer.GetAudioPosSec() < 0.02f)
            {
                int index = MusicWheelBase.GetCurSongIndex() + 1;
                if (index >= MusicWheelBase.GetWheelItemCount())
                {
                    index = 0;
                }
                MusicWheelItem item = GameObject.Find("WheelItem" + string.Format("{0}", index)).GetComponent <MusicWheelItem>();

                MusicWheelBase.SetWheelPosIndex(index);
                item.ButtonClicked();
                GameObject.Find("SongProgressBar").GetComponent <SongProgressbar>().SetProgress(0f);
                GameObject.Find("PlayButton").GetComponent <PlayButton>().ButtonOnClickEvent();
            }
        }
        else
        {
            m_Button.GetComponent <Image>().sprite = normal;
        }
    }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     gameObject.GetComponent <Text>().text = "CurrentSongs:" + MusicWheelBase.GetWheelItemCount() + " CurrentPacks:";
     foreach (string s in MusicLoader.GetFolderFilter())
     {
         gameObject.GetComponent <Text>().text = gameObject.GetComponent <Text>().text + s + " ";
     }
 }
Exemplo n.º 3
0
    public static void SetWheelPosIndex(int index)
    {
        float t = index * 1.0f / (MusicWheelBase.GetWheelItemCount() - 1);

        MusicWheelBase.UpdateWheelPos(t);
        Scrollbar m_Scrollbar = GameObject.Find("Scrollbar").GetComponent <Scrollbar>();

        m_Scrollbar.value = t;
    }
Exemplo n.º 4
0
    public static int GetCurSongIndex()
    {
        int index = 0;

        for (int i = 0; i < MusicWheelBase.GetWheelItemCount(); i++)
        {
            if (MusicLoader.SongList[i].title == MusicPlayer.GetCurAudio())
            {
                index = i;
                break;
            }
        }
        return(index);
    }
Exemplo n.º 5
0
    public void ButtonOnClickEvent()
    {
        int index = MusicWheelBase.GetCurSongIndex() + 1;

        if (index >= MusicWheelBase.GetWheelItemCount())
        {
            index = 0;
        }
        MusicWheelItem item = GameObject.Find("WheelItem" + string.Format("{0}", index)).GetComponent <MusicWheelItem>();

        MusicWheelBase.SetWheelPosIndex(index);
        item.ButtonClicked();
        GameObject.Find("SongProgressBar").GetComponent <SongProgressbar>().SetProgress(0f);
        GameObject.Find("PlayButton").GetComponent <PlayButton>().ButtonOnClickEvent();
    }
Exemplo n.º 6
0
    public void ButtonOnClickEvent()
    {
        if (MusicPlayer.GetIsPlaying())
        {
            Debug.Log("Paused");
            MusicPlayer.PauseAudio();
        }
        List <int> itemlist = new List <int>();

        for (int i = 0; i < MusicWheelBase.GetWheelItemCount(); i++)
        {
            MusicWheelItem item_t = GameObject.Find("WheelItem" + string.Format("{0}", i)).GetComponent <MusicWheelItem>();
            if (!item_t.played)
            {
                itemlist.Add(i);
            }
        }
        if (itemlist.Count == 0)
        {
            return;
        }
        //Random.InitState(1);
        int index = Random.Range(0, itemlist.Count);

        GameObject.Find("RedoRandomButton").GetComponent <RedoRandom>().AddRandom(itemlist[index]);
        MusicWheelItem item = GameObject.Find("WheelItem" + string.Format("{0}", itemlist[index])).GetComponent <MusicWheelItem>();

        float t = itemlist[index] * 1.0f / (MusicWheelBase.GetWheelItemCount() - 1);

        MusicWheelBase.UpdateWheelPos(t);
        Scrollbar m_Scrollbar = GameObject.Find("Scrollbar").GetComponent <Scrollbar>();

        m_Scrollbar.value = t;
        item.ButtonClicked();

        float pos = Random.Range(0f, 0.8f);

        if (GameObject.Find("LimTVSizeButton").GetComponent <LimitTVSize>().LimitTvSize)
        {
            float songlen = MusicPlayer.GetSongLength();
            float sec     = Random.Range(0f, 80f);
            sec = Mathf.Min(songlen - 15f, sec);
            pos = sec / songlen;
        }

        GameObject.Find("SongProgressBar").GetComponent <SongProgressbar>().SetProgress(pos);
    }
    void Update()
    {
        if (blocked)
        {
            return;
        }
        if (m_Scrollbar.value < 0)
        {
            m_Scrollbar.value = 0;
        }
        if (m_Scrollbar.value > 1)
        {
            m_Scrollbar.value = 1;
        }

        if (HasFocus && Input.GetAxis("Mouse ScrollWheel") > 0 && m_Scrollbar.value > 0)
        {
            m_Scrollbar.value -= 0.02f * 150f / (MusicWheelBase.GetWheelItemCount() + 1);
        }
        if (HasFocus && Input.GetAxis("Mouse ScrollWheel") < 0 && m_Scrollbar.value < 1)
        {
            m_Scrollbar.value += 0.02f * 150f / (MusicWheelBase.GetWheelItemCount() + 1);
        }

        if (HasFocus && Input.touchCount == 1)
        {
            if (Input.touches[0].phase == TouchPhase.Began)
            {
                // 记录手指触屏的位置
                m_screenpos = Input.touches[0].position;
            }
            // 手指移动
            else if (Input.touches[0].phase == TouchPhase.Moved)
            {
                m_Scrollbar.value += Input.touches[0].deltaPosition.y / 50 * Time.deltaTime * 150f / (MusicWheelBase.GetWheelItemCount() + 1);
            }
        }
    }
Exemplo n.º 8
0
    public void ButtonOnClickEvent()
    {
        if (st.Count <= 1)
        {
            return;
        }
        //redo now
        int            index  = (int)st.Peek();
        MusicWheelItem item_t = GameObject.Find("WheelItem" + string.Format("{0}", index)).GetComponent <MusicWheelItem>();

        item_t.side_image_obj.SetActive(false);
        item_t.played = false;
        st.Pop();

        index = (int)st.Peek();
        MusicWheelItem item = GameObject.Find("WheelItem" + string.Format("{0}", index)).GetComponent <MusicWheelItem>();

        float t = index * 1.0f / (MusicWheelBase.GetWheelItemCount() - 1);

        MusicWheelBase.UpdateWheelPos(t);
        Scrollbar m_Scrollbar = GameObject.Find("Scrollbar").GetComponent <Scrollbar>();

        m_Scrollbar.value = t;
        item.ButtonClicked();

        /*
         * float pos = Random.Range(0f, 0.8f);
         * if (GameObject.Find("LimTVSizeButton").GetComponent<LimitTVSize>().LimitTvSize)
         * {
         *  float songlen = MusicPlayer.GetSongLength();
         *  float sec = Random.Range(0f, 80f);
         *  pos = sec / songlen;
         * }*/

        GameObject.Find("SongProgressBar").GetComponent <SongProgressbar>().SetProgress(0f);
    }
Exemplo n.º 9
0
 // Update is called once per frame
 void Update()
 {
     gameObject.transform.localPosition = new Vector3(-160, -index * 50 + MusicWheelBase.GetWheelPos() * (MusicWheelBase.GetWheelItemCount() - 1) * 50, -1);
 }
Exemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        if (FullAuto)
        {
            m_Button.GetComponent <Image>().sprite = selected;


            if (MusicPlayer.GetIsPlaying())
            {
                timer += Time.deltaTime;
                if (timer > max_time || MusicPlayer.GetSongLength() - MusicPlayer.GetAudioPosSec() < 0.02f)
                {
                    List <int> itemlist = new List <int>();
                    for (int i = 0; i < MusicWheelBase.GetWheelItemCount(); i++)
                    {
                        MusicWheelItem item_t = GameObject.Find("WheelItem" + string.Format("{0}", i)).GetComponent <MusicWheelItem>();
                        if (!item_t.played)
                        {
                            itemlist.Add(i);
                        }
                    }
                    if (itemlist.Count == 0)
                    {
                        //放完了
                        timer  = 0f;
                        fading = false;
                        MusicPlayer.SetVolume(GameObject.Find("SongVolumeBar").GetComponent <Scrollbar>().value);
                        FullAuto = !FullAuto;
                        GameObject.Find("PlayButton").GetComponent <PlayButton>().ButtonOnClickEvent();
                    }
                    else
                    {
                        timer  = 0f;
                        fading = false;
                        GameObject.Find("RandomNextButton").GetComponent <RandomNext>().ButtonOnClickEvent();
                        //MusicPlayer.SetVolume(volume);
                        MusicPlayer.SetVolume(GameObject.Find("SongVolumeBar").GetComponent <Scrollbar>().value);

                        //GameObject.Find("SongVolumeBar").GetComponent<Scrollbar>().value = volume;
                        GameObject.Find("PlayButton").GetComponent <PlayButton>().ButtonOnClickEvent();
                    }
                }
                if (!fading)
                {
                    //volume = MusicPlayer.GetVolume();
                }
                if (timer > max_time - fade_time)
                {
                    fading = true;

                    //MusicPlayer.SetVolume(volume * (max_time - timer) / (max_time-fade_time));
                    MusicPlayer.SetVolume(GameObject.Find("SongVolumeBar").GetComponent <Scrollbar>().value *(max_time - timer) / (max_time - fade_time));
                    // GameObject.Find("SongVolumeBar").GetComponent<Scrollbar>().value = volume * (max_time - timer) / (max_time - fade_time);
                }

                /*
                 * else
                 * {
                 *  volume = MusicPlayer.GetVolume();
                 * }*/
            }
            else
            {
                timer = 0f;
            }
        }
        else
        {
            m_Button.GetComponent <Image>().sprite = normal;
        }
    }