예제 #1
0
    List <ScoreModel.HighScoreInformation> highScoresList;    //list of high score from score model

    ///<description>Set Final score on game finish and update high score list (in View)</description>
    void EvaluateScore()
    {
        ScoreModel.HighScoreInformation currentScoreInfo = new ScoreModel.HighScoreInformation("Enter Name To Save Score...", score);

        highScoresList = scoreModel.GetHighScoreList();
        int rank = 1;

        scoreRank = highScoresList.Count + 1;
        scoreView.OnHighScoreBeat(false);
        for (; rank <= highScoresList.Count; rank++)
        {
            if (highScoresList[rank - 1].score < score)
            {
                scoreRank = rank;
                break;
            }
        }
        if (scoreRank <= highScoresList.Count)
        {
            rank = highScoresList.Count;
            for (; rank > scoreRank; rank--)
            {
                highScoresList[rank - 1] = highScoresList[rank - 2];
            }
            highScoresList[scoreRank - 1] = currentScoreInfo;
            scoreView.OnHighScoreBeat(true);
        }
        scoreView.SetHighScoreUIForList(highScoresList);
    }