Example #1
0
    // Use this for initialization
    void Start()
    {
        int zapdos       = 0;
        int numberOfRows = scoreRow.Length;
        Dictionary <SizeAndTimer, NameAndScore> records = ScoreUpdatesHolda.rankingHolder.records;

        for (int gridSizeIndex = 0; gridSizeIndex < gridSizeValues.Length; gridSizeIndex++)
        {
            for (int timerIndex = 0; timerIndex < timerValues.Length; timerIndex++)
            {
                int       gridSize     = gridSizeValues [gridSizeIndex];
                float     timer        = timerValues [timerIndex];
                Transform correctChild = scoreRow [timerIndex].GetChild(gridSizeIndex);
                try
                {
                    NameAndScore nas = records [new SizeAndTimer(gridSize, timer)];
                    correctChild.Find("Name").GetComponent <Text> ().text  = nas.name;
                    correctChild.Find("Score").GetComponent <Text> ().text = nas.score.ToString();
                }
                catch (KeyNotFoundException ex)
                {
                    zapdos++;
                }
            }
            Debug.Log(zapdos);
        }
    }
Example #2
0
        public void compareScoreAndNameTest_SortByLastName_TRUE()
        {
            NameAndScore line1       = new NameAndScore("KING", "MADISON", 88);
            NameAndScore line2       = new NameAndScore("BUNDY", "TERESSA", 88);
            Boolean      returnValue = Program.compareScoreAndName(line1, line2);

            Assert.IsTrue(returnValue);
        }
Example #3
0
        public void compareScoreAndNameTest_SortByScore_FALSE()
        {
            NameAndScore line1       = new NameAndScore("SMITH", "ALLAN", 88);
            NameAndScore line2       = new NameAndScore("KING", "MADISON", 70);
            Boolean      returnValue = Program.compareScoreAndName(line1, line2);

            Assert.IsFalse(returnValue);
        }
Example #4
0
        public void compareScoreAndNameTest_SortByFirstName_FALSE()
        {
            NameAndScore line1       = new NameAndScore("KING", "TERESSA", 88);
            NameAndScore line2       = new NameAndScore("BUNDY", "TERESSA", 88);
            Boolean      returnValue = Program.compareScoreAndName(line1, line2);

            Assert.IsFalse(returnValue);
        }
 private NameAndScore[] textToHighscore(string toConvert)
 {
     string[]       fLines = Regex.Split(toConvert, "\n");
     NameAndScore[] temp   = new NameAndScore[fLines.Length];
     //starts at 1 to ignore the Highscore line
     for (int i = 1; i < fLines.Length; i++)
     {
         string[] line = Regex.Split(fLines[i], "\t");
         temp[i].playerName = line[0];
         temp[i].time       = float.Parse(line[1]);
     }
     return(temp);
 }
    private string highscoreToText(NameAndScore[] toConvert)
    {
        string temp = "Highscore:\n";

        if (toConvert == null)
        {
            toConvert = new NameAndScore[0];
            toConvert[0].playerName = "Placeholder";
            toConvert[0].time       = 0.0f;
        }
        for (int i = 0; i < toConvert.Length; i++)
        {
            temp += toConvert[i].playerName + "\t" + toConvert[i].time.ToString() + "\n";
        }
        return(temp);
    }
Example #7
0
        public void ReadFileAndSaveIntoListTest_SUCCESS()
        {
            string filename = (@".\..\..\names.txt");
            List <NameAndScore> successReturn = Program.ReadFileAndSaveIntoList(filename);

            successReturn.ForEach(i => Console.WriteLine(i.ToString()));
            List <NameAndScore> expectedList = new List <NameAndScore>();
            NameAndScore        line1        = new NameAndScore("BUNDY", "TERESSA", 88);
            NameAndScore        line2        = new NameAndScore("SMITH", "ALLAN", 70);
            NameAndScore        line3        = new NameAndScore("KING", "MADISON", 88);
            NameAndScore        line4        = new NameAndScore("SMITH", "FRANCIS", 85);

            expectedList.Add(line1);
            expectedList.Add(line2);
            expectedList.Add(line3);
            expectedList.Add(line4);
            CollectionAssert.AreEqual(expectedList, successReturn);
        }
    public void addHighScore(string name, float time)
    {
        int tempIndex;

        if (scores == null)
        {
            tempIndex = 0;
        }
        else
        {
            tempIndex = scores.Length + 1;
        }
        NameAndScore[] temp = new NameAndScore[tempIndex];
        if (temp.Length == 1)
        {
            temp[0] = new NameAndScore(name, time);
        }
        else
        {
            bool shift = false;
            for (int i = 0; i < temp.Length; i++)
            {
                if (!shift)
                {
                    if (scores[i].time > time)
                    {
                        temp[i] = new NameAndScore(name, time);
                        shift   = true;
                    }
                    else
                    {
                        temp[i] = scores[i];
                    }
                }
                else
                {
                    temp[i] = scores[i - 1];
                }
            }
        }
    }
Example #9
0
        public void SortByScoreAndNameTest_NOT_NULL()
        {
            List <NameAndScore> inputList = new List <NameAndScore>();
            NameAndScore        line1     = new NameAndScore("BUNDY", "TERESSA", 88);
            NameAndScore        line2     = new NameAndScore("SMITH", "ALLAN", 70);
            NameAndScore        line3     = new NameAndScore("KING", "MADISON", 88);
            NameAndScore        line4     = new NameAndScore("SMITH", "FRANCIS", 85);

            inputList.Add(line1);
            inputList.Add(line2);
            inputList.Add(line3);
            inputList.Add(line4);
            List <NameAndScore> returnedList = Program.SortByScoreAndName(inputList);
            List <NameAndScore> expectedList = new List <NameAndScore>();

            expectedList.Add(line1);
            expectedList.Add(line3);
            expectedList.Add(line4);
            expectedList.Add(line2);
            CollectionAssert.AreEqual(returnedList, expectedList);
        }
Example #10
0
 public void AddScore(int score, int size, float timer, string name)
 {    //tries to add the player data,will throw an exception if the score is too low
     records[new SizeAndTimer(size, timer)] = new NameAndScore(name, score);
     Save();
 }