Пример #1
0
        public static Band LoadBandFromFile(String fileLocation)
        {
            Band band = new Band();

            band._saveLocation = fileLocation;

            try
            {
                StreamReader streamReader = new StreamReader(fileLocation);
                String       line;

                // Read in band name
                if ((line = streamReader.ReadLine()) != null)
                {
                    band._bandName = line;
                }
                // Read in song data
                while ((line = streamReader.ReadLine()) != null)
                {
                    String[] data = line.Split(';');
                    switch (data[0])
                    {
                    case "S":
                        // Song data
                        ScoreAndStars scores = new ScoreAndStars();
                        scores.Score = double.Parse(data[2]);
                        if (data.Length > 3)
                        {
                            scores.Stars = uint.Parse(data[3]);
                        }
                        else
                        {
                            scores.Stars = 0;
                        }
                        band._songStats.Add(data[1], scores);
                        break;

                    case "C":
                        // Challenge data
                        break;

                    case "L":
                        // Logo name...
                        band._logoName = data[1];
                        break;
                    }
                }

                streamReader.Close();
            }
            catch (Exception)
            {
                // Do things here incase it can't read the file
            }

            return(band);
        }
Пример #2
0
 public void ScoreSong(String song, double score, uint stars)
 {
     if (!_songStats.ContainsKey(song))
     {
         _songStats.Add(song, new ScoreAndStars(score, stars));
     }
     else if (score > ((ScoreAndStars)_songStats[song]).Score)
     {
         _songStats[song] = new ScoreAndStars(score, stars);
     }
 }