public void PlayButtonClick() { // increase number of interactions BoxScript.totalInteractions++; // Play sound AudioManager.instance.Play("Sparkle1"); //=========FEATURE: Unproductive Juice================================= // CAMERA SHAKE when pressing button //===================================================================== if (GameManagerScript.juiceUnproductive) { CameraShaker.instance.ShakeOnce(3f, 4f, .1f, .6f); } //=========FEATURE: Productive Obstruction============================= // Display prompt if productive //===================================================================== if (GameManagerScript.obstructionProductive) { // get score long score = BoxScript.GetScore(BoxScript.currentWord, null); // get rarity float rarity = BoxScript.GetWordRank(BoxScript.currentWord); if (rarity < 0) { rarity = 0; } // update text promptText.text = "Are you sure you want to submit " + BoxScript.currentWord + "?"; rarityText.text = "Rarity: " + (rarity * 100).ToString("0.00") + "%"; pointsText.text = "Points: " + score; submitPromptPanel.SetActive(true); // Turn on the timer for logging GameManagerScript.submitPromptOn = true; // Disable touch of the rest of the screen TouchInputHandler.inputEnabled = false; // Log the action LogPlayButtonClick(BoxScript.currentWord, rarity, score); } else { BoxScript.PlayWord(); } }
public void UpdatePlayButton() { if (BoxScript.currentWord.Length >= 3 && BoxScript.GetWordRank(BoxScript.currentWord) > -1) { playButton.GetComponent <Button>().interactable = true; } else { playButton.GetComponent <Button>().interactable = false; } }
public void LogCancelButtonClick() { if (GameManagerScript.logging) { CancelPlayWordLogEntry entry = new CancelPlayWordLogEntry(); CancelPlayWordLogEntry.CancelPlayWordPayload payload = new CancelPlayWordLogEntry.CancelPlayWordPayload( BoxScript.currentWord, BoxScript.GetWordRank(BoxScript.currentWord), BoxScript.GetScore(BoxScript.currentWord, null) ); entry.SetValues("BNW_CancelButton", "BNW_Action", payload); string json = JsonUtility.ToJson(entry); DatabaseReference reference = FirebaseDatabase.DefaultInstance.GetReference(GameManagerScript.LOGGING_VERSION); DatabaseReference child = reference.Push(); child.SetRawJsonValueAsync(json); BoxScript.totalInteractions++; } }
public void GameOver() { gameHasBegun = false; gameOverPanel.SetActive(true); Text gameOverMessage = gameOverMessageObject.GetComponent <Text>(); Text gameOverScoreText = gameOverScoreTextObject.GetComponent <Text>(); Text highScoreText = highScoreTextObject.GetComponent <Text>(); Text highestScoringWordText = highestScoringWordObject.GetComponent <Text>(); Text rarestWordText = rarestWordObject.GetComponent <Text>(); highScoreText.text = "Your High Score: " + myHighScore; // Check if new local high score was reached if (myHighScoreUpdated) { // update game over text gameOverMessage.text = "Congratulations! You've set a new personal high score!"; // TODO: animate particles } // Check if new global high score was reached /* * if (globalHighScoreUpdated) * { * // update game over text * gameOverMessage.text = "Congratulations! You've set a new global high score!"; * highScoreText.text = "New High Score: " + BoxScript.score; * * // TODO: animate particles * } */ gameOverScoreText.text = "Score: " + BoxScript.score; // update highest scoring word text highestScoringWordText.text = "Highest Scoring Word:\n" + myHighestScoringWord + "\n" + myHighestScoringWordScore + " points"; string rarityText = (BoxScript.GetWordRank(myRarestWord) * 100).ToString("0.00"); if (myRarestWord.Trim() == "") { rarityText = "0"; } // update rarest word text rarestWordText.text = "Rarest Word:\n" + myRarestWord + "\n" + rarityText + "%"; // disable touch events TouchInputHandler.touchEnabled = false; TouchInputHandler.inputEnabled = false; // disable button press playButton.GetComponent <Button>().interactable = false; // Log the final state of the game Logger.LogEndOfGame(); }