Well, i need to do show some labels with bot’s points in javascript, so I have a class Bot.
#pragma strict
class Bot extends MonoBehaviour
{
var name = "";
var animal = "";
var pointsScene1 : float = 0;
var pointsScene2 : float = 0;
var pointsScene3 : float = 0;
var totalPoints : float = 0;
function get Name() : String { return name; }
function set Name(value : String) { name = value; }
function get Animal() : String { return animal; }
function set Animal(value : String) { animal = value; }
function get PointsScene1() : float { return pointsScene1; }
function set PointsScene1(value : float) { pointsScene1 = value; }
function get PointsScene2() : float { return pointsScene2; }
function set PointsScene2(value : float) { pointsScene2 = value; }
function get PointsScene3() : float { return pointsScene3; }
function set PointsScene3(value : float) { pointsScene3 = value; }
function get TotalPoints() : float { return totalPoints; }
function set TotalPoints(value : float) { totalPoints = value; }
}
This class is populate with random values, until here is all perfect.
But i need to “sort” this class to find out the the best bot with “TotalPoints” and complete the labels!
I assign they in Inspector using
var arr : Bot[];
Any ideas how can i do this?
I tryed something like this to find out
function Top8(arrTmp : Bot[]) {
var max = arrTmp[0].TotalPoints;
for (i = 1; i < arrTmp.Length; i++) {
if (arrTmp*.TotalPoints > max) {*
max = arrTmp*.TotalPoints;*
}
}
return max;
}
I called this function using
Top8(arr);
And I got the highest value TotalPoints, but I need to check from what bot is, and show it in GUI.Label to do a top 8 including 7 bots and player’s points
Im accepting any sugestions!