Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
igem-quantifly
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLN
igem-quantifly
Commits
4ef0e6de
Unverified
Commit
4ef0e6de
authored
Oct 27, 2016
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scores scene: HighScore display
parent
0220008d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
4 deletions
+35
-4
Score.cs
Assets/Scripts/API/Score.cs
+0
-0
Server.cs
Assets/Scripts/API/Server.cs
+1
-1
HighScores.cs
Assets/Scripts/HighScores.cs
+34
-3
No files found.
Assets/Scripts/API/Score.cs
View file @
4ef0e6de
Assets/Scripts/API/Server.cs
View file @
4ef0e6de
...
...
@@ -23,7 +23,7 @@ namespace Assets.Scripts.API
GetScores
();
}
public
void
GetScores
()
public
void
GetScores
()
{
StartCoroutine
(
GetScoresAsync
());
Debug
.
Log
(
"Done."
);
...
...
Assets/Scripts/HighScores.cs
View file @
4ef0e6de
using
UnityEngine
;
using
System.Collections
;
using
Assets.Scripts.API
;
using
UnityEngine
;
using
UnityEngine.SceneManagement
;
using
UnityEngine.UI
;
using
System
;
using
System.Collections
;
public
class
HighScores
:
MonoBehaviour
{
public
Text
ScoreText
;
public
Server
Server
;
public
Score
[]
highscores
;
private
bool
updatedScores
=
false
;
//TODO: Not very elegant, can we instead load scores sync in Start?
// Use this for initialization
void
Start
()
{
ScoreText
.
text
=
""
;
Server
=
gameObject
.
GetComponent
(
typeof
(
Server
))
as
Server
;
}
// Update is called once per frame
void
Update
()
{
if
(!
updatedScores
)
{
if
(
Server
.
Scores
.
status
.
Equals
(
"ok"
))
{
Score
[]
highScores
=
Server
.
Scores
.
scores
;
Array
.
Sort
(
highScores
,
delegate
(
Score
x
,
Score
y
)
{
return
y
.
score
.
CompareTo
(
x
.
score
);});
Debug
.
Log
(
String
.
Format
(
"We got {0} scores."
,
highScores
.
Length
));
if
(
Server
.
Scores
.
scores
.
Length
>
0
)
{
for
(
int
i
=
0
;
i
<
highScores
.
Length
;
i
++)
{
Score
score
=
highScores
[
i
];
string
name
=
score
.
playerName
;
if
(
score
.
team
!=
null
&&
score
.
team
.
Length
>
0
)
{
name
+=
" ("
+
score
.
team
+
")"
;
}
ScoreText
.
text
+=
WWW
.
UnEscapeURL
(
name
)
+
": "
+
score
.
score
+
" points\n"
;
}
}
else
{
ScoreText
.
text
=
"No high-score yet... Play a game and show you are the best!"
;
}
updatedScores
=
true
;
}
}
}
public
void
OnButtonBackClicked
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment