Hi, I’m doing a game - car racing based on the tutorial from http://www.docstoc.com/docs/24770154/Unity3D-Car-Racing-Game-Development-Tutorial
I’m stuck in a moment when I try to do high score, there is sth wrong in JS code, I’m a beginner, so please help me to solve it. Debugger shows me a msg that “unknown identifier entry” and “name/score is not a member of Object”. I think there is only small mistake but I cant find it out…
#pragma strict
var blinkingName;
// This stores the score and name of the players
class Entry {
var score = 0.0;
var name = "";
}
private var entries = ArrayList ();
var maxEntryCount = 10;
var maxNameLength = 10;
...
// Insert a new entry
function InsertEntry (score : float) : int {
**HERE STARTS PROBLEMS**
entry = Entry ();
entry.score = score;
// In
for (var i=0;i<entries.Count;i++) {
if (entry.score < entries_.score || entries*.score == 0.0) {*_
entries.Insert (i, entry);
break;
}
}
// Remove excess entries
if (entries.Count > maxEntryCount)
entries.RemoveRange (maxEntryCount, entries.Count - maxEntryCount);
// We changed the high score table, so we need to rebuild
// the text we rneder
SetupHighscoreTableText ();
return entries.IndexOf (entry);
}
// Changes the name of the entry at index
function ChangeName (index : int, name : String) {
var entry = entries[index];
entry.name = name;
SetupHighscoreTableText ();
}
// Loads all entries from the preferences
// Sorts them and removes excess high score entries
function LoadEntries ()
{
entries.Clear ();
// Load entries from preferences
for (var i=0;i<maxEntryCount;i++)
{
var entry = Entry ();
entry.name = PlayerPrefs.GetString ("HighScore Name " + i);
entry.score = PlayerPrefs.GetFloat ("HighScore Score " + i);
if (entry.score != 0)
entries.Add (entry);
}
// Add empty entries to fill up the remaining highscore entries
while (entries.Count < maxEntryCount) {
entry = Entry ();
entry.name = “Empty”;
entry.score = 0;
entries.Add (entry);
}
if (entries.Count > maxEntryCount)
entries.RemoveRange (maxEntryCount, entries.Count - maxEntryCount);
}
// Saves all high score entries to the preferences
function SaveEntries () {
for (var i=0;i<entries.Count;i++) {
PlayerPrefs.SetString ("HighScore Name " + i, entries*.name);*
PlayerPrefs.SetFloat ("HighScore Score " + i, entries*.score);*
}}