Skip to content

Commit

Permalink
rebuild done.
Browse files Browse the repository at this point in the history
  • Loading branch information
andong777 committed Sep 2, 2014
1 parent bff8021 commit 27fc477
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions Assets/Scripts/SaveLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SaveLoad {
int cursor; // cursor to read records

private SaveLoad() {
cursor = start;
ResetCursor();
}

public static SaveLoad Instance
Expand All @@ -33,7 +33,7 @@ public static SaveLoad Instance

public void ResetCursor()
{
cursor = start;
cursor = start - recordsPerPage;
}

public void Save(Data data)
Expand Down Expand Up @@ -79,31 +79,32 @@ public Data[] Prev()
{
int i = 0;
var page = new Data[recordsPerPage];
if (cursor - recordsPerPage >= start)
cursor -= recordsPerPage;
Debug.Log("---Prev---"+cursor);
cursor = cursor - recordsPerPage >= start ? cursor - recordsPerPage : start;
while (i < recordsPerPage && PlayerPrefs.HasKey(cursor + "Name"))
{
string name = PlayerPrefs.GetString(cursor + "Name");
int score = PlayerPrefs.GetInt(cursor + "Score");
page[i++] = new Data(cursor, name, score);

cursor ++;
}
int idx = cursor + i;
string name = PlayerPrefs.GetString(idx + "Name");
int score = PlayerPrefs.GetInt(idx + "Score");
page[i++] = new Data(idx, name, score);
}
return page;
}

public Data[] Next()
{
int i=0;
var page = new Data[recordsPerPage];
if (PlayerPrefs.HasKey((cursor + recordsPerPage) + "Name"))
cursor += recordsPerPage;
Debug.Log("---Next---"+cursor);
while (i < recordsPerPage && PlayerPrefs.HasKey(cursor + "Name"))
{
string name = PlayerPrefs.GetString(cursor + "Name");
int score = PlayerPrefs.GetInt(cursor + "Score");
page[i++] = new Data(cursor, name, score);

cursor ++;
int idx = cursor + i;
string name = PlayerPrefs.GetString(idx + "Name");
int score = PlayerPrefs.GetInt(idx + "Score");
page[i++] = new Data(idx, name, score);
}
return page;
}
Expand Down

0 comments on commit 27fc477

Please sign in to comment.