Skip to content

Commit

Permalink
1Up awarded for every 5 coins collected
Browse files Browse the repository at this point in the history
  • Loading branch information
jonuy committed Jun 18, 2014
1 parent 2f49e77 commit d319736
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Assets/Scripts/CoinController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,8 @@ public void Pickup() {
// Display and add the points
GameObject pointsText = (GameObject)Instantiate(pointsIndicator);
pointsText.GetComponent<PointsIndicator>().AddPoints(pointValue, transform.position);

// Notify game controller
gameController.AddCoinCollected();
}
}
15 changes: 13 additions & 2 deletions Assets/Scripts/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public FFGameState GameState {
// Total points accumulated
private int score;

// Total # of coins collected
// Coins collected leading to next 1Up
private int coinsCollected;

// Number of coins needed to add life
private int coinsFor1Up = 10;
private int coinsFor1Up = 5;

// Left side and right side spawn controllers
private SpawnController leftSpawn;
Expand Down Expand Up @@ -352,8 +352,19 @@ public int GetHighScore() {
return highScore;
}

/**
* Handler for a coin getting collected.
*/
public void AddCoinCollected() {
coinsCollected++;

// Award new life and reset coin count
if (coinsCollected == coinsFor1Up) {
coinsCollected = 0;
currentLives++;

UpdateGUI();
}
}

/**
Expand Down

0 comments on commit d319736

Please sign in to comment.