Skip to content

Instantly share code, notes, and snippets.

@gclsoft
Created December 2, 2014 01:20
Show Gist options
  • Save gclsoft/1501c6eac25b4ec085da to your computer and use it in GitHub Desktop.
Save gclsoft/1501c6eac25b4ec085da to your computer and use it in GitHub Desktop.
game.js
#pragma strict
var _gameOver:GameObject; //Gameobject visible when player has died
var _levelComplete:GameObject; //Gameobject visible when level complete
var _scoreTextMesh:TextMesh; //Displays score from previous level
var _retryButton:Button; //Insert retry button to go back to previously loaded level
private var _previousLevel:String;
//var cb:Chartboost;
function Start () {
// cb.loadInterstital();
Chartboost.loadInterstital();
_gameOver.SetActive(false);
_levelComplete.SetActive(false);
_scoreTextMesh.text = SaveStats.instance._score.ToString("000000000"); //Change score text
_previousLevel = SaveStats.instance._previousLevel;
if(SaveStats.instance._score > PlayerPrefs.GetInt(Application.loadedLevelName+"highscore", 0)){
PlayerPrefs.SetInt(_previousLevel+"highscore", SaveStats.instance._score);
}
if(SaveStats.instance._levelComplete){ //If player completed level
_levelComplete.SetActive(true);
}else if(!SaveStats.instance._levelComplete){
_gameOver.SetActive(true); //If player died in last level
}
if(_retryButton){
_retryButton._sceneToLoad = _previousLevel; //Replay last level
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment