Exemplo n.º 1
0
    void SwitchMusic(int nextFocus)
    {
        MusicUIItem currentItem = musicUIItemList[focusIndex];
        MusicUIItem nextItem    = musicUIItemList[nextFocus];

        float updatedGroupPosition = -nextFocus * (itemWidth + itemSpacing);

        musicUIGroup.transform.DOPause();
        musicUIGroup.transform.DOLocalMoveX(updatedGroupPosition, swipeTransitionDuration, true).SetEase(Ease.OutQuad).OnComplete(() =>
        {
            Music nextMusic = nextItem.music;
            if (playMusicCoroutine != null)
            {
                StopCoroutine(playMusicCoroutine);
            }
            playMusicCoroutine      = StartCoroutine(LoadAsyncAndPlay(nextMusic));
            bannerBackground.sprite = nextItem.albumImage.sprite;
            bannerBackground.DOFade(backgroundAlpha, swipeTransitionDuration).SetEase(Ease.OutQuad);
        });

        currentItem.transform.DOScale(itemMinScale, swipeTransitionDuration).SetEase(Ease.OutQuad);
        nextItem.transform.DOScale(itemMaxScale, swipeTransitionDuration).SetEase(Ease.OutQuad);

        currentItem.textGroup.DOFade(0, swipeTransitionDuration).SetEase(Ease.OutQuad);
        nextItem.textGroup.DOFade(1, swipeTransitionDuration).SetEase(Ease.OutQuad);

        audio.DOFade(0, swipeTransitionDuration).SetEase(Ease.OutQuad);
        bannerBackground.DOFade(0, swipeTransitionDuration).SetEase(Ease.OutQuad);

        focusIndex = nextFocus;
    }
Exemplo n.º 2
0
    MusicUIItem CreateMusicUIItem(Music music)
    {
        GameObject itemGameObject = Instantiate(musicUIItemPrefab, musicUIGroup.transform);

        itemGameObject.name = music.title;
        itemGameObject.SetActive(true);

        MusicUIItem item = new MusicUIItem
        {
            gameObject   = itemGameObject,
            music        = music,
            beatmapIndex = 0,
        };

        item.transform       = item.gameObject.transform;
        item.albumImage      = item.transform.Find("AlbumBackground/AlbumImage").GetComponent <UnityEngine.UI.Image>();
        item.textGroup       = item.transform.Find("TextGroup").GetComponent <CanvasGroup>();
        item.titleLabel      = item.transform.Find("TextGroup/TitleBackground/TitleLabel").GetComponent <Text>();
        item.artistLabel     = item.transform.Find("TextGroup/ArtistBackground/ArtistLabel").GetComponent <Text>();
        item.difficultyLabel = item.transform.Find("TextGroup/DifficultyBackground/DifficultyLabel").GetComponent <Text>();

        item.transform.localScale  = Vector3.one * itemMinScale;
        item.albumImage.sprite     = Utils.LoadBanner(music.bannerFilename);
        item.titleLabel.text       = music.title;
        item.artistLabel.text      = music.artist;
        item.difficultyLabel.text  = music.beatmapList[0].difficultyName;
        item.difficultyLabel.color = music.beatmapList[0].difficultyDisplayColor.ToColor();

        return(item);
    }
Exemplo n.º 3
0
    void InitMusicGroup()
    {
        musicUIItemList = new List <MusicUIItem>();

        for (int i = 0; i < musicList.Count; i++)
        {
            Music       music = musicList[i];
            MusicUIItem item  = CreateMusicUIItem(music);
            musicUIItemList.Add(item);

            item.transform.localPosition = new Vector3
            {
                x = i * (itemWidth + itemSpacing),
            };
        }

        // Set group position
        musicUIGroup.transform.localPosition = new Vector3
        {
            x = -focusIndex * (itemWidth + itemSpacing),
        };

        // Set default focut item
        SetDefaultFocusItem(musicUIItemList[focusIndex]);
    }
Exemplo n.º 4
0
    void SetDefaultFocusItem(MusicUIItem item)
    {
        item.beatmapIndex          = RuntimeData.selectedBeatmapIndex;
        item.difficultyLabel.text  = item.music.beatmapList[item.beatmapIndex].difficultyName;
        item.difficultyLabel.color = item.music.beatmapList[item.beatmapIndex].difficultyDisplayColor.ToColor();

        item.transform.localScale = Vector3.one * itemMaxScale;

        item.textGroup.alpha = 1;

        bannerBackground.sprite = item.albumImage.sprite;

        playMusicCoroutine = StartCoroutine(LoadAsyncAndPlay(item.music));
    }
Exemplo n.º 5
0
    public void ChangeDifficulty(int directionCode = 1)
    {
        if (callingStartGame)
        {
            return;
        }

        MusicUIItem item = musicUIItemList[focusIndex];

        int beatmapCount = item.music.beatmapList.Count;

        if (beatmapCount <= 1)
        {
            return;
        }

        item.beatmapIndex += directionCode;
        if (item.beatmapIndex < 0)
        {
            item.beatmapIndex = beatmapCount - 1;
        }
        if (item.beatmapIndex >= beatmapCount)
        {
            item.beatmapIndex = 0;
        }

        Beatmap nextBeatmap = item.music.beatmapList[item.beatmapIndex];

        changingDifficulty = true;
        item.difficultyLabel.DOFade(0, 0.3f).SetEase(Ease.OutQuad).OnComplete(() =>
        {
            Color color = nextBeatmap.difficultyDisplayColor.ToColor();
            color.a     = 0;
            item.difficultyLabel.color = color;
            item.difficultyLabel.text  = nextBeatmap.difficultyName;
            item.difficultyLabel.DOFade(1, 0.3f).SetEase(Ease.OutQuad).OnComplete(() =>
            {
                changingDifficulty = false;
            });
        });
    }