Created
December 2, 2014 01:20
-
-
Save gclsoft/1501c6eac25b4ec085da to your computer and use it in GitHub Desktop.
game.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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