コード例 #1
0
        IEnumerable <SongItem> ParseSongItems(IEnumerable <Song> allSongs, string playingMethod)
        {
            var userSongs =
                db
                .GetAll()
                .ToDictionary(x => x.SongHash, x => x);

            return
                (allSongs
                 .Where(s => s.PlayingMethods.Exists(m => m.CharacteristicName == playingMethod))
                 .Select(
                     s => {
                var playingMethods =
                    s.PlayingMethods
                    .Select(m => new PlayingMethod(m.CharacteristicName, m.Difficulties))
                    .ToList();
                var difficulties = playingMethods.First(m => m.name == playingMethod).difficulties;

                byte starCount = 0;
                List <string> categories;
                if (userSongs.ContainsKey(s.Hash))
                {
                    var userSong = userSongs[s.Hash];
                    starCount = userSong.StarCount;
                    categories = userSong.Categories;
                }
                else
                {
                    categories = new List <string>();
                }

                var item = new SongItem(
                    s.Hash,
                    LoadImage(s.CoverImagePath),
                    s.Name,
                    s.AuthorName,
                    s.LevelAuthor,
                    starCount,
                    categories,
                    s.AudioFilePath,
                    playingMethods,
                    difficulties
                    );

                return item;
            }));
        }
コード例 #2
0
        internal void Load(SongItem song, bool highlight = false)
        {
            foreach (Transform child in Difficulties.transform)
            {
                Destroy(child.gameObject);
            }
            foreach (Transform child in Stars.transform)
            {
                Destroy(child.gameObject);
            }

            Icon.texture    = song.icon;
            SongName.text   = song.songName;
            ArtistName.text = song.artistName;
            AuthorName.text = song.authorName;

            var difficultyX = 0.0f;

            foreach (var d in song.difficulties.Reverse())
            {
                var obj = Instantiate(DifficultyPrefab, Difficulties.transform);
                obj.transform.localPosition = new Vector3(difficultyX, 0.0f);
                obj.GetComponent <SongItemDifficulty>().SetText(d);
                difficultyX -= obj.GetComponent <RectTransform>().rect.width;
            }

            var starX = 0.0f;

            for (var i = 0; i < MAX_STARS; i++)
            {
                GameObject obj = Instantiate(StarPrefab, Stars.transform);
                obj.GetComponent <Image>().sprite = i < song.stars ? FullStar : EmptyStar;
                obj.transform.localPosition       = new Vector3(starX, 0.0f);
                starX -= obj.GetComponent <RectTransform>().rect.width;
            }

            Background.color = highlight ? SongHighlightColor : SongBackgroundColor;
        }
コード例 #3
0
 void SelectSong(SongItem song)
 {
     selectSongSubject.OnNext(new SelectSongIntent(song));
 }
コード例 #4
0
 public SelectSongIntent(SongItem song)
 {
     this.Song = song;
 }