/*=========================== Methods ===================================================*/ /*=========================== Awake() ===================================================*/ void Awake(){ // initialise variables lbPanelWidth = Screen.width * 0.28f; // width is 28% screen size lbPanelHeight = Screen.height * 0.72f; // height is 72% screen height // get reference to UI Elements usernameInput = GameObject.Find ("UsernameInputField").GetComponent<InputField>(); playButton = GameObject.Find ("PlayButton").GetComponent<Button> (); leaderboardButton = GameObject.Find ("LeaderboardButton").GetComponent<Button>(); quitButton = GameObject.Find ("QuitButton").GetComponent<Button>(); // add play game button onclick method playButton.onClick.AddListener(() => PlayGame()); // add leaderboard button onclick method leaderboardButton.onClick.AddListener(() => Leaderboard()); // add quit button onclick method quitButton.onClick.AddListener(() => QuitGame()); // get reference to saveManager saveManager = GetComponent<SaveGameDataManager>(); // get reference to leaderboard leaderBoard = GetComponent<LeaderBoard>(); } // Awake()
/*=========================== Methods ===================================================*/ /*=========================== Awake() ===================================================*/ void Awake(){ // get a reference to the soundManager soundManager = GameObject.FindGameObjectWithTag("SoundManager"); // flag scene as main soundManager.GetComponent<SoundManager>().isMainScene = true; // tell the sound manager to transition tracks to start playing main game music soundManager.GetComponent<SoundManager>().TransitionTracks(); // get reference to gameManagers audio source audioSource = GetComponent<AudioSource>(); // get references to UI scoreText = GameObject.Find ("ScoreText").GetComponent<Text>(); towerOneButton = GameObject.Find ("TowerOneButton").GetComponent<Button>(); towerTwoButton = GameObject.Find ("TowerTwoButton").GetComponent<Button>(); towerThreeButton = GameObject.Find ("TowerThreeButton").GetComponent<Button>(); towerFourButton = GameObject.Find ("TowerFourButton").GetComponent<Button>(); towerFiveButton = GameObject.Find ("TowerFiveButton").GetComponent<Button>(); settingsButton = GameObject.Find ("SettingsButton").GetComponent<Button>(); // get reference to castle health bar image castleHealthBar = GameObject.Find("CastleHealthBar").GetComponent<Image>(); // Initialise Variables GameLevel = 1; GameScore = 0; totalCastleHealth = 200; castleHealth = totalCastleHealth; // Setup the games UI SetUpUI(); // instantiate the pathLayout pathLayout = (GameObject)Instantiate ((GameObject)Resources.Load ("Prefabs/PathLayout1")); // get a reference to saveManager saveManager = GetComponent<SaveGameDataManager>(); } // Awake()