Skip to content

Commit

Permalink
Added + or - Score Methods to ScoreController
Browse files Browse the repository at this point in the history
I think health is good to go at this point. I don’t think that when you
die we want to change scenes just yet, there is no reason to, but at
least or right now it adds some closure to the game and a way to
restart it.
  • Loading branch information
dyllandry committed Jul 4, 2016
1 parent ae4ed6e commit 2c6bf87
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions djGame/Assets/scripts/ScoreController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,39 @@
public class ScoreController : MonoBehaviour
{

public int scoreRate;
private float score;
public int scoreRate = 0;
private float score = 0;
private bool pause = false;

void Start ()
{
void Update ()
{
IncrementScore ();
UpdateScore ();
}

public void IncreaseScore (int amount)
{
score += amount;
}

void Update ()
{
IncrementScore ();
public void DescreaseScore (int amount)
{
score -= amount;
if (score < 0) {
score = 0;
}
}

void IncrementScore ()
{
if (scoreRate != null && !pause) {
if (!pause) {
score += scoreRate * Time.deltaTime;
UpdateScore ();
}
}

void UpdateScore ()
{
gameObject.GetComponent<GUIText> ().text = "Score: " + Mathf.Round (score).ToString();
gameObject.GetComponent<GUIText> ().text = "Score: " + Mathf.Round (score).ToString ();
}

public void PauseScore ()
Expand Down

0 comments on commit 2c6bf87

Please sign in to comment.