I’m making a highscore system for my game with the list method and I need to compare points and times to set the rank position.
I’ve already done this:
A script creates a “playerlist”.
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
[Serializable]
public class players
{
public List<PlayerData> pdata;
}
A script to set strings and ints
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
[Serializable]
public class PlayerData
{
public int rank;
public string name;
public string time;
public int score;
}
To set the rank I need to compare score and time between players, if at some point there will be tie by score, the time will set the rank of the player …
for example,
Player 1 - (Name: Bob - Score: 100 - Time 0:30)
Player 2 - (Name: Bill - Score: 100 - Time 0:28)
Player 2 made 100 points in less time, so he will be ahead in rank.
How do I make this comparison to set the rank of each player?
Thanks