Esempio n. 1
0
    public void PopulateBeatmapSelect(int bmdIndex)
    {
        BeatmapData bmd = OszUnpacker.bmds[bmdIndex];

        foreach (BeatmapUIObj beatmap in beatmaps)
        {
            ObjectPooling.inst.ReturnToPool(beatmap.gameObject, "Beatmap UI");
        }
        beatmaps.Clear();

        bool moreThanSeven = bmd.mapInfos.Count > 7;

        if (moreThanSeven)
        {
            beatmapHolder.sizeDelta        = new Vector2(sizePerNewObj * bmd.mapInfos.Count, beatmapHolder.sizeDelta.y);
            beatmapHolder.anchoredPosition = new Vector2(105, beatmapHolder.anchoredPosition.y);
        }
        else
        {
            beatmapHolder.sizeDelta        = new Vector2(245, beatmapHolder.sizeDelta.y);
            beatmapHolder.anchoredPosition = new Vector2(0, beatmapHolder.anchoredPosition.y);
        }

        for (int i = 0; i < bmd.mapInfos.Count; i++)
        {
            BeatmapUIObj beatmapObj = ObjectPooling.inst.SpawnFromPool("Beatmap UI", beatmapHolder.transform.position, beatmapHolder.transform.rotation).GetComponent <BeatmapUIObj>();
            beatmapObj.AssignBmData(bmdIndex, scroll);
            beatmapObj.AssignBmInfo(i);
            beatmapObj.mainImg.SizeToFillParent();
            beatmapObj.transform.SetSiblingIndex(i);
            beatmaps.Add(beatmapObj);
        }
    }
Esempio n. 2
0
    public void PopulateSongSelect()
    {
        foreach (BeatmapUIObj songObj in songObjs)
        {
            Destroy(songObj.gameObject);
        }
        songObjs.Clear();

        bool moreThanSeven = OszUnpacker.bmds.Count > 7;

        if (moreThanSeven)
        {
            songHolder.sizeDelta        = new Vector2(sizePerNewObj * OszUnpacker.bmds.Count, songHolder.sizeDelta.y);
            songHolder.anchoredPosition = new Vector2(105, songHolder.anchoredPosition.y);
            content.sizeDelta           = new Vector2(songHolder.sizeDelta.x + sizePerNewObj * 6, content.sizeDelta.y);   //6 because can view max 7 at once. 3 at start, 3 at end. Required so that the First and Last Obj can be at the middle
        }
        else
        {
            songHolder.sizeDelta        = new Vector2(245, songHolder.sizeDelta.y);
            songHolder.anchoredPosition = new Vector2(0, songHolder.anchoredPosition.y);
            content.sizeDelta           = new Vector2(songHolder.sizeDelta.x, content.sizeDelta.y);
        }

        for (int i = 0; i < OszUnpacker.bmds.Count; i++)
        {
            OszUnpacker.bmds = OszUnpacker.LoadBeatmapData();
            BeatmapUIObj songObj = Instantiate(songObjPrefab, songHolder);
            songObj.transform.position = new Vector3(songObj.transform.position.x, songObj.transform.position.y, songObj.transform.position.z - 0.01f);
            songObj.AssignBmData(i, scroll);
            songObj.mainImg.SizeToFillParent();
            songObjs.Add(songObj);
        }
    }
Esempio n. 3
0
    public void OnHoverSelect(BeatmapUIObj uiObj, bool playButtonSound = true, bool forceInvoke = false)
    {
        switch (uiObj.uiObjType)
        {
        case UIObjType.Song:

            if (currentSelectedSong == uiObj && !forceInvoke)
            {
                return;
            }

            if (currentSelectedSong)
            {
                currentSelectedSong.anim.SetBool("Is Hovering", false);
            }
            currentSelectedSong = uiObj;

            songTitle.text = OszUnpacker.bmds[currentSelectedSong.bmdIndex].songName;
            artist.text    = OszUnpacker.bmds[currentSelectedSong.bmdIndex].artistName;
            mapCount.text  = string.Format("{0} Beatmaps", OszUnpacker.bmds[currentSelectedSong.bmdIndex].mapInfos.Count);

            splashImg.color   = Color.white;
            splashImg.texture = OszUnpacker.bmds[currentSelectedSong.bmdIndex].mainSplash;
            splashImg.SizeToFillParent();

            gm.songPlayer.clip = currentSelectedSong.audio;
            gm.songPlayer.Play();

            if (playButtonSound)
            {
                PlayButtonSound(1);
            }

            anim.SetTrigger("New Select");
            break;

        case UIObjType.Beatmap:

            if (currentSelectedBeatmap == uiObj && !forceInvoke)
            {
                return;
            }

            if (currentSelectedBeatmap)
            {
                currentSelectedBeatmap.anim.SetBool("Is Hovering", false);
            }
            currentSelectedBeatmap = uiObj;

            BeatmapInfo bmi = OszUnpacker.bmds[currentSelectedSong.bmdIndex].mapInfos[currentSelectedBeatmap.bmiIndex];

            mapTitle.text         = bmi.mapName;
            creatorName.text      = string.Format("Mapped by: {0}", bmi.creator);
            difficulty.fillAmount = bmi.difficulty / 10;

            mapTitlePrompt.text = bmi.mapName;

            RepopulateHighscores(bmi);

            if (playButtonSound)
            {
                PlayButtonSound(1);
            }

            anim.SetTrigger("New Select");
            break;
        }
    }