Hello.
Thanks for reading this question
My game is simple remake of agar.io
What i want to do?
I have problem with scoreboard as title says.
I dont have any idea how to store 2 values in one veriable for example(name , score)
I tried using dictionary but i got stucked when i need to sort position of objects.
I want scoreboard look like this.
1.name + value
2.name + value
4.name + value
5.name + value
i think you are in need of a custom class
you can set up your own class like this:
//put this first line at the very top of your script to use a list
using System.Collections.Generic;
public class entry{
public string name;
public int score;
public entry (string n,int s){
name = n;score = s;
}}
public List<entry> scoreboard;
void Start () {
scoreboard = new List<entry> ();
scoreboard.Add (new entry (3,"bob"));
scoreboard.Add (new entry (75,"fred"));
scoreboard.Add (new entry (28,"henry"));
scoreboard.Add (new entry (17,"vladimir"));
//get high score
int a = scoreboard.Count;
int high = 0;int n = 0;
while(a>0){a--;if(scoreboard[a].score>high){
high=scoreboard[a].score;n=a;}}
print (scoreboard[n].name+" has high score");
}