public void SendData(GameFlow.GameOverCause cause, int highScore) { if (settings.AreCheatsEnabled()) { //Debug.Log("Not sending analytics because cheats are enabled."); return; //Don't send analytics if cheats were enabled } //Debug.Log("Sending analytics!"); int finalScore = score.GetScore(); int peakEnergy = energy.GetPeakEnergy(); int turnsPlayed = turns.GetTurns(); int peakVestiges = vestiges.GetPeakVestiges(); int currentVestiges = vestiges.GetCurrentVestiges(); int finalClearedSquares = clearedSquares.GetClearedSquares(); float timePlaying = Time.time; bool isZenMode = settings.IsZenModeEnabled(); //string currentTimeStamp = System.DateTime.Now.ToString(); //string allTheData = "timestamp;" + currentTimeStamp + ",score;" + finalScore + ",peakEnergy;" + peakEnergy + ",timePlaying;" + timePlaying + ",turnsPlayed;" + turnsPlayed + ",peakVestiges;" + peakVestiges + ",endingVestiges;" + currentVestiges + ",totalClearedSquares;" + finalClearedSquares; //Debug.Log("allTheData is" + allTheData); UnityEngine.Analytics.Analytics.CustomEvent("gameOver", new Dictionary <string, object> { { "score", finalScore }, { "gameOverCause", cause }, { "peakEnergy", peakEnergy }, { "timePlaying", timePlaying }, { "turnsPlayed", turnsPlayed }, { "peakVestiges", peakVestiges }, { "endingVestiges", currentVestiges }, { "totalClearedSquares", finalClearedSquares }, { "highScore", highScore }, { "isZenMode", isZenMode } //{ "allTheData", allTheData} //I removed this because it wasn't working anyway }); }
// Callback function for gameFlow's GameLost event. private void GameFlow_GameLost(GameFlow.GameOverCause cause) { if (blocksQueue.Count > 0) { blocksQueue.Peek().AllowDragging(false); } enabled = false; }
// Callback function for GameFlow.GameLost. void Appear(GameFlow.GameOverCause cause) { AudioController.Instance.StopSFX("About_To_Lose_1"); AudioController.Instance.PlaySFX("Game_Over_1"); foreach (GameObject obj in toBeEnabled) { obj.SetActive(true); } string reason; switch (cause) { case GameFlow.GameOverCause.NoRemainingSpaces: reason = "ReasonNoSpaceLeft"; break; case GameFlow.GameOverCause.QueueOverflow: reason = "ReasonHesitation"; break; case GameFlow.GameOverCause.NoMoreEnergy: reason = "ReasonNoEnergy"; break; case GameFlow.GameOverCause.Reset: reason = "ReasonManualReset"; break; default: reason = "ReasonHesitation"; break; } string prefsEntry; if (Settings.Instance.IsZenModeEnabled()) { prefsEntry = "HighScoreZen"; } else { prefsEntry = "HighScore"; } int highScore = PlayerPrefs.GetInt(prefsEntry); //Get the stored high score - 0 if doesn't exist int finalScore = score.GetScore(); if (finalScore > highScore) { highScore = finalScore; PlayerPrefs.SetInt(prefsEntry, highScore); //Save it } analytics.SendData(cause, highScore); textGameOverReason.text = translator.Translate(reason) + "\n" + translator.Translate("HighScore1") + highScore; //textGameOverReason.text = reason + "\nHigh score: " + highScore; }