Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Birb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gadig
Birb
Commits
00619417
Commit
00619417
authored
Feb 23, 2017
by
Ashley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Timer is done
parent
1fc5c3e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
Assets/Scenes/CharacterTest.unity
Assets/Scenes/CharacterTest.unity
+0
-0
Assets/Scripts/Birb/Dash.cs
Assets/Scripts/Birb/Dash.cs
+1
-1
Assets/Scripts/Birb/GameManager.cs
Assets/Scripts/Birb/GameManager.cs
+20
-3
No files found.
Assets/Scenes/CharacterTest.unity
View file @
00619417
No preview for this file type
Assets/Scripts/Birb/Dash.cs
View file @
00619417
...
...
@@ -26,7 +26,7 @@ public class Dash : AbstractBehavior {
}
void
Start
()
{
dashMeter
=
GameObject
.
FindGameObjectWithTag
(
"DashMeter"
).
transform
;
//
dashMeter = GameObject.FindGameObjectWithTag("DashMeter").transform;
}
// Should be called every frame
...
...
Assets/Scripts/Birb/GameManager.cs
View file @
00619417
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine.UI
;
using
UnityEngine
;
public
class
GameManager
:
SingletonBehaviour
<
GameManager
>
...
...
@@ -8,10 +9,12 @@ public class GameManager : SingletonBehaviour<GameManager>
private
bool
_isPaused
;
private
float
_levelTimer
;
public
Text
timerText
;
void
Awake
()
{
DontDestroyOnLoad
(
this
);
isPaused
=
true
;
}
public
bool
isPaused
...
...
@@ -22,19 +25,19 @@ public class GameManager : SingletonBehaviour<GameManager>
}
set
{
_isPaused
=
value
;
if
(
isPaused
)
{
//set timescale back to normal
isPaused
=
false
;
Time
.
timeScale
=
1
;
Debug
.
Log
(
"Game is unpaused"
);
}
else
{
//set timescale to zero
isPaused
=
true
;
Time
.
timeScale
=
0
;
Debug
.
Log
(
"Game is paused"
);
}
_isPaused
=
value
;
}
}
...
...
@@ -56,4 +59,18 @@ public class GameManager : SingletonBehaviour<GameManager>
Debug
.
Log
(
"Changing level state"
);
levelTimer
=
Time
.
time
;
}
//formats the time for the text object
private
string
formatTime
(
float
time
)
{
int
minutes
=
Mathf
.
FloorToInt
(
time
/
60F
);
int
seconds
=
Mathf
.
FloorToInt
(
time
-
minutes
*
60
);
return
string
.
Format
(
"{0:0}:{1:00}"
,
minutes
,
seconds
);
}
//updates the text object
void
Update
()
{
string
currentTime
=
formatTime
(
Time
.
time
-
levelTimer
);
timerText
.
text
=
"Time: "
+
currentTime
;
}
}
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