// Add a high score, only if it is actually a high score // Returns the new high score data instance with the score // and initials values set public RFHighScore AddNewScore(int score, string initials) { RFHighScore newScore = AddNewScore(score); if (newScore != null) { newScore.Initials = initials; } return(newScore); }
RFHighScoreUpdateCallback updateCallbackFunc; // If not null; call it when updates happen #region IRFHighScoreHandler Implementation // IRFHighScoreHandler methods marked as virtual so this class is easily extendable. If extending with custom // classes, don't forget to call these base methods when overriden! virtual public void SetHighScoreData(int scoreIndex, RFHighScore rfHighScore) { if (rfHighScore == null) { return; } workingHighScore = rfHighScore; workingValue = rfHighScore.Initials; UpdateColorHighScoreColor(); }
void endHighScoreEdit() { highScoreHandler.EditHighScoreComplete( ); // All done - Better save those scores. HighScoresManager.SaveHighScores(HighscoresFile); // Let other systems know editing is DONE! currentHighScoreEvent.EventType = RFHighScoreEventType.RFHIGH_SCORE_EDIT_DONE; onRFHighScoreEvent.Invoke(currentHighScoreEvent); // reset some values currentHighScoreEvent = null; mostRecentHighScore = null; highScoreHandler = null; }
// Add a high score, only if it is actually a high score // Returns the new high score data instance with the score // value set public RFHighScore AddNewScore(int score) { RFHighScore newScore = null; if (IsHighScore(score)) { newScore = new RFHighScore(); newScore.HighScore = score; HighScoresList.Add(newScore); sortHighToLow(); cullList(); } return(newScore); }
// Add a score to the list; if it is a high score go into "collect initials" mode public bool AddScore(int score) { RFHighScore scoreData = HighScoresManager.AddNewScore(score, NewScoreInitials); // If it was a high score, reset the display.. if (scoreData != null) { mostRecentHighScore = scoreData; currentHighScoreEvent = new RFHighScoreEventData(); currentHighScoreEvent.HighScoreData = scoreData; displayHighScores(); // Let other systems know a new high score was just submitted rfHighScoreEvent.Invoke(currentHighScoreEvent); } return(scoreData != null); }
// Iterate through the high scores list; create renderers, pass data // for renderers to do their thing void displayHighScores() { // The container and the renderer prefab both need to be hooked up! if (HighScoresContainer == null || HighScoreRendererPrefab == null) { return; } List <RFHighScore> scores = HighScoresManager.HighScoresList; // Destroy current high scores children RFUtils.DestroyTransformChildren(HighScoresContainer); for (int cnt = 0; cnt < scores.Count; cnt++) { GameObject renderer = Instantiate(HighScoreRendererPrefab) as GameObject; IRFHighScoreHandler scoreHandler = renderer.GetComponent <IRFHighScoreHandler>(); if (scoreHandler != null) { renderer.name = HighScoreRendererPrefab.name + "_" + (cnt + 1).ToString(); renderer.transform.SetParent(HighScoresContainer, false); RFHighScore highScore = scores[cnt]; scoreHandler.SetHighScoreData(cnt + 1, highScore); renderer.SetActive(true); // Check to see if the high score is a recent one added // If so, there is a little house keeping to happen if (mostRecentHighScore == highScore && mostRecentHighScore != null) { scoreHandler.EditHighScoreStart(SelectableCharacters, HandleScoreEditUpdate); if (currentHighScoreEvent != null) { currentHighScoreEvent.HighScoreRenderer = renderer; } highScoreHandler = scoreHandler; } } } }