I am doing a game similar to Mario Party, but I have a problem and I don’t know how to solve it. The problem is how can I make a scoretable in which players with the same puntuatio have the same rate?
It´s a four local multiplayer game, of course.
For example:
Player1 score 60
Player 2 score 30
Player 3 score 20
Player 4 score 30
I want to have for player 1 in first 100points
player 2 and 4 in third position with 50 points
player 3 in fourth postion with 25 points
Here is my sample code
private List<HighscoreEntry> highScoreEntryList;//scoretable list
public void AddToList()
{
//add score
highScoreEntryList = new List<HighscoreEntry>() {
new HighscoreEntry{score = player1score, name = "Player1" },
new HighscoreEntry{score = player2score, name = "Player2" },
new HighscoreEntry{score = player3score, name = "Player3" },
new HighscoreEntry{score = player4score, name = "Player4" }
};
//order puntuations
for (int i = 0; i < highScoreEntryList.Count; i++) {
for (int j = i + 1; j < highScoreEntryList.Count; j++)
{
if (highScoreEntryList[j].score > highScoreEntryList*.score)*
{
HighscoreEntry tmp = highScoreEntryList*;*
highScoreEntryList = highScoreEntryList[j];
highScoreEntryList[j] = tmp;
}
}
}
}
private class HighscoreEntry //class for the list
{
public int score;
public string name;
}