Example #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;
        }
    }
Example #2
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();
    }
Example #3
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);
    }
Example #4
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);
    }
    private static void CreateWheelItems(List <MusicData> mdata)
    {
        GameObject songlist = GameObject.FindGameObjectWithTag("SongList");
        int        index    = 0;

        foreach (MusicData md in mdata)
        {
            GameObject musicwheelitem = new GameObject("WheelItem" + string.Format("{0}", index));

            MusicWheelItem temp = musicwheelitem.AddComponent <MusicWheelItem>();


            musicwheelitem.transform.parent = songlist.transform;

            temp.button_obj = new GameObject();
            temp.button_obj.transform.parent        = musicwheelitem.transform;
            temp.button_obj.transform.localPosition = new Vector3(19f, 0, 0f);
            temp.button = temp.button_obj.AddComponent <Button>();

            //background image for item;
            temp.image = temp.button_obj.AddComponent <Image>();
            temp.image.GetComponent <RectTransform>().sizeDelta = new Vector2(38f, 6f);
            temp.image.color = new Color(255 / 255f, 255 / 255f, 255 / 255f, 125 / 255f);

            //temp.button.GetComponent<RectTransform>().sizeDelta = new Vector2(40f, 6f);
            temp.button.targetGraphic = temp.image;
            temp.button.onClick.RemoveAllListeners();
            temp.button.onClick.AddListener(temp.ButtonClicked);

            ColorBlock cb = new ColorBlock();

            cb                  = temp.button.colors;
            cb.normalColor      = new Color(255 / 255f, 255 / 255f, 255 / 255f, 120 / 255f);
            cb.highlightedColor = new Color(0 / 255f, 255 / 255f, 255 / 255f, 20 / 255f);
            cb.pressedColor     = new Color(0 / 255f, 255 / 255f, 255 / 255f, 20 / 255f);
            cb.selectedColor    = new Color(0 / 255f, 255 / 255f, 255 / 255f, 10 / 255f);
            cb.fadeDuration     = 0.5f;
            temp.button.colors  = cb;

            temp.text_title = new GameObject();
            temp.text_title.transform.parent = musicwheelitem.transform;
            temp.text_title_tm = temp.text_title.AddComponent <TextMesh>();

            temp.text_artist = new GameObject();
            temp.text_artist.transform.parent = musicwheelitem.transform;
            temp.text_artist_tm = temp.text_artist.AddComponent <TextMesh>();

            temp.text_animation = new GameObject();
            temp.text_animation.transform.parent = musicwheelitem.transform;
            temp.text_animation_tm = temp.text_animation.AddComponent <TextMesh>();

            temp.text_translated = new GameObject();
            temp.text_translated.transform.parent = musicwheelitem.transform;
            temp.text_translated_tm = temp.text_translated.AddComponent <TextMesh>();

            temp.transform.localScale    = new Vector3(8f, 8f, 8f);
            temp.transform.localPosition = new Vector3(-160, -20 + index * 50, -1);
            temp.text_title_tm.text      = LanguageManager.UTF8String(md.title);
            temp.text_artist_tm.text     = LanguageManager.UTF8String(md.artist);
            temp.text_animation_tm.text  = LanguageManager.UTF8String(md.animation);
            temp.text_translated_tm.text = LanguageManager.UTF8String(md.translated);

            temp.text_title.transform.localPosition = new Vector3(0, 2.8f, 0);
            temp.text_title_tm.fontSize             = 24;

            temp.text_artist.transform.localPosition = new Vector3(0, -1f, 0);
            temp.text_artist_tm.fontSize             = 12;

            temp.text_animation.transform.localPosition = new Vector3(38, -0.8f, 0);
            temp.text_animation_tm.fontSize             = 16;
            temp.text_animation_tm.anchor = TextAnchor.UpperRight;

            temp.text_translated.transform.localPosition = new Vector3(38f, 2.6f, 0f);
            temp.text_translated_tm.fontSize             = 16;
            temp.text_translated_tm.anchor = TextAnchor.UpperRight;

            musicwheelitem.layer = LayerMask.NameToLayer("UI");
            foreach (Transform tran in musicwheelitem.GetComponentsInChildren <Transform>())
            {                                                        //遍历当前物体及其所有子物体
                tran.gameObject.layer = LayerMask.NameToLayer("UI"); //更改物体的Layer层
            }
            //temp.button_obj.transform.gameObject.layer = LayerMask.NameToLayer("Background");

            temp.index = index;
            index++;
        }

        MusicWheelBase.UpdateWheelItemCount(index);
    }
Example #6
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;
        }
    }