Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
Highscore display fixed. Source code button added
Browse files Browse the repository at this point in the history
Fixes #37
  • Loading branch information
vilbeyli committed May 19, 2015
1 parent 64a7a84 commit e2168b9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
Binary file modified Assets/Scenes/game.unity
Binary file not shown.
50 changes: 37 additions & 13 deletions Assets/Scripts/ScoreManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class ScoreManager : MonoBehaviour
public static bool DBReadSuccessful;

// handles
public Text BeginnerScores;
public Text IntermediateScores;
public Text ExpertScores;
public Text[] BeginnerScores;
public Text[] IntermediateScores;
public Text[] ExpertScores;

// private variables
private List<List<Score>> _highScores;
Expand Down Expand Up @@ -89,23 +89,46 @@ public void LoadScoresToUI()
String beginnerScoresText, intermediateScoresText, expertScoresText;
beginnerScoresText = intermediateScoresText = expertScoresText = "";

String beginnerScoresValue, intermediateScoresValue, expertScoresValue;
beginnerScoresValue = intermediateScoresValue = expertScoresValue = "";

Debug.Log("Loading scores to UI: " + _highScores[0].Count + ", " + _highScores[1].Count + ", " + _highScores[2].Count);


for (int j = 0; j < (HighScoreDisplayCount <= _highScores[0].Count ? HighScoreDisplayCount : _highScores[0].Count); j++)
for (int j = 0;
j < (HighScoreDisplayCount <= _highScores[0].Count ? HighScoreDisplayCount : _highScores[0].Count);
j++)
{
beginnerScoresText += HighScoreFormat(j, _highScores[0][j]);

for (int j = 0; j < (HighScoreDisplayCount <= _highScores[1].Count ? HighScoreDisplayCount : _highScores[1].Count); j++)
beginnerScoresValue += _highScores[0][j].TimePassed.ToString("0.00") + "\n\n";
}

for (int j = 0;
j < (HighScoreDisplayCount <= _highScores[1].Count ? HighScoreDisplayCount : _highScores[1].Count);
j++)
{
intermediateScoresText += HighScoreFormat(j, _highScores[1][j]);
intermediateScoresValue += _highScores[1][j].TimePassed.ToString("0.00") + "\n\n";
}

for (int j = 0; j < (HighScoreDisplayCount <= _highScores[2].Count ? HighScoreDisplayCount : _highScores[2].Count); j++)
for (int j = 0;
j < (HighScoreDisplayCount <= _highScores[2].Count ? HighScoreDisplayCount : _highScores[2].Count);
j++)
{
expertScoresText += HighScoreFormat(j, _highScores[2][j]);
expertScoresValue += _highScores[2][j].TimePassed.ToString("0.00") + "\n\n";

}


// update UI elements' text fields
BeginnerScores.text = beginnerScoresText;
IntermediateScores.text = intermediateScoresText;
ExpertScores.text = expertScoresText;
BeginnerScores[0].text = beginnerScoresText;
IntermediateScores[0].text = intermediateScoresText;
ExpertScores[0].text = expertScoresText;

BeginnerScores[1].text = beginnerScoresValue;
IntermediateScores[1].text = intermediateScoresValue;
ExpertScores[1].text = expertScoresValue;
}

string HighScoreFormat(int i, Score score)
Expand All @@ -120,14 +143,14 @@ string HighScoreFormat(int i, Score score)
case 1:
case 2:
case 3:
case 4:
s += "\t\t\t\t";
break;
case 4:
case 5:
case 6:
case 7:
s += "\t\t\t";
break;
case 7:
case 8:
case 9:
s += "\t\t";
Expand All @@ -137,7 +160,8 @@ string HighScoreFormat(int i, Score score)
break;
}

s += score.TimePassed.ToString("0.00") + "\n\n";
// score.TimePassed.ToString("0.00") +
s += "\n\n";

return s;
}
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ public void ResetHUD(int flagCount)
UpdateFlagText(flagCount);
UpdateTimeText(0);
}

public void SourceCode()
{
Application.OpenURL("http://github.com/vilbeyli/Minesweeper");
}
}

[Serializable]
Expand Down

0 comments on commit e2168b9

Please sign in to comment.