// Initializes the game for each level. // Level 0 : initialize and start GameManager // Level 1 : Menu screen // Level indexes >2 are game levels by default when using this script void InitGame(int scene) { Debug.Log("Initializing level: " + scene); // Try to find GamePlayActions type object from current scene // (mandatory for actual game levels) gamePlayActions = GameObject.FindObjectOfType <GamePlayActions> (); // Search for TextLevel named UI object // If found, set Text content as "Level: <n>" GameObject textObject = GameObject.Find("TextLevel"); Debug.Log("textobject: " + textObject); if (textObject != null) { textLevel = textObject.GetComponent <Text> (); textLevel.text = "Level: " + (scene - 1); } // Search for TextContinue // If found, set Text content as continueMessage continueObject = GameObject.Find("TextContinue"); if (continueObject != null) { textContinue = continueObject.GetComponent <Text> (); textContinue.text = continueMessage; continueObject.SetActive(false); } buttonMenu = GameObject.Find("ButtonMenu"); if (buttonMenu != null) { buttonMenu.SetActive(false); } highScoreObject = GameObject.Find("HighScoreText"); if (highScoreObject != null) { highScoreMessage = "Highscore\n" + highScore; textHighScore = highScoreObject.GetComponent <Text> (); textHighScore.text = highScoreMessage; highScoreObject.SetActive(true); } }
void Start() { gamePlayActions = new GamePlayActions(); BindDefaultControls(); }