//For when the user is done with a branch, also called when timer runs out void Submit() { Sprite background = GameObject.Find("Branch").GetComponent <SpriteRenderer>().sprite; Transition.setBackground(background); //Iterate to get the next scene sceneIterator++; //Score is persistant between levels for now, but might want to change this levelScore = calcLevelScore(); totalScore += levelScore; TimerScript.SetCurrentTime(findTime(sceneIterator)); selectedBug = null; //StartCoroutine(Utilities.HighlightUnfoundBugs(3)); //If we're on the last level, display the game over screen. Otherwise go to next level if (sceneIterator == 5) { playerScore = ScoreScript.scoreValue; //Hide the game interface GameObject mainInterface = GameObject.Find("LevelUI"); mainInterface.SetActive(false); //Make the gameover screen visible gameOver.SetActive(true); //Update the score value and display it to the game over screen Text scoreText = GameObject.Find("YourScore").GetComponent <Text>(); scoreText.text += playerScore.ToString(); Text totalScoreText = GameObject.Find("TotalScore").GetComponent <Text>(); totalScoreText.text += totalScore.ToString() + " possible points"; Text feedbackText = GameObject.Find("Feedback").GetComponent <Text>(); getFeedback(playerScore, feedbackText); //Finds the play again button from the scene and adds an event listener playAgainButton = GetComponentInChildren <Button>(); playAgainAction += PlayAgain; playAgainButton.onClick.AddListener(playAgainAction); } else { //Index for the transition scene TimerScript.PauseTime(); SceneManager.LoadScene(1); } }
//For when the user is done with a branch, also called when timer runs out void Submit() { Sprite background = GameObject.Find("Branch").GetComponent <SpriteRenderer>().sprite; Transition.setBackground(background); //Iterate to get the next scene sceneIterator++; //Score is persistant between levels for now, but might want to change this levelScore = calcLevelScore(); totalScore += levelScore; TimerScript.SetCurrentTime(findTime(sceneIterator)); selectedBug = null; TimerScript.PauseTime(); SceneManager.LoadScene(1); }
//Public method for a bug to call once it has been clicked public void BugClicked(GameObject bug) { bugsClicked++; //Zooms camera in on bug Camera.main.orthographic = true; Camera.main.transform.position = Camera.main.ScreenToWorldPoint( new Vector3(Input.mousePosition.x, Input.mousePosition.y - Mathf.Floor(Screen.height / 24), Input.mousePosition.z)); //20 zoomingIn = true; levelSubmitButton.gameObject.SetActive(false); bugSelectionUI.SetActive(true); bugButtons.SetActive(true); bugSelectionText.SetActive(true); Utilities.PauseBugs(); TimerScript.PauseTime(); //MagnifyGlass.DisableZoom(); currentBugScript = bug.GetComponent <Bug>(); selectedBug = currentBugScript.classification; }
//Public method for a bug to call once it has been clicked public void BugClicked(GameObject bug) { bugsClicked++; //Zooms camera in on bug Camera.main.orthographic = true; Camera.main.transform.position = Camera.main.ScreenToWorldPoint( new Vector3(Input.mousePosition.x, Input.mousePosition.y - Mathf.Floor(Screen.height / 20), Input.mousePosition.z)); zoomingIn = true; levelSubmitButton.gameObject.SetActive(false); bugSelectionUI.SetActive(true); bugButtons.SetActive(true); bugSelectionText.SetActive(true); //Hide the ruler when bug has been clicked //ruler.SetActive(false); //GameObject ruler = GameObject.Find("Ruler"); /* * Image rulerImage = ruler.GetComponent<Image>(); * var tempColor = rulerImage.color; * tempColor.a = 0f; * rulerImage.color = tempColor; */ //InputField measurementInput = lengthUI.GetComponentInChildren<InputField>(); //measurementInput.onEndEdit.AddListener(delegate {EvaluateMeasurement(measurementInput); }); //bugUISubmitButton = GameObject.Find("BugUISubmit").GetComponent<Button>();//bugSelectionUI.GetComponentInChildren<Button>(); //lengthSubmit.GetComponent<Button>().onClick.AddListener(delegate {BugUISubmit(); }); Utilities.PauseBugs(); TimerScript.PauseTime(); //MagnifyGlass.DisableZoom(); currentBugScript = bug.GetComponent <Bug>(); selectedBug = currentBugScript.classification; }