//========================================================================================= /// <summary> /// Gets the index of a new high score the player has just got, if any. /// </summary> /// <param name="high_scores"> Current high scores records</param> /// <returns> 0 if the player has obtained the new 1st high score, 1 if the /// 2nd best score was got and so on. -1 is returned if no high score was got. </returns> //========================================================================================= private int GetNewHighScoreIndex( LevelHighScores.HighScoreRecord high_scores ) { // Get the level rules object: LevelRules rules = (LevelRules) Core.Level.Search.FindByType("LevelRules"); // If not there then abort: if ( rules == null ) return -1; // Otherwise return the first score the players score exceeds: if ( rules.PlayerScore > high_scores.Score1 ) return 0; if ( rules.PlayerScore > high_scores.Score2 ) return 1; if ( rules.PlayerScore > high_scores.Score3 ) return 2; // Player didn't get a new high score: return -1; }
//========================================================================================= /// <summary> /// Gets the length that the rendering code should move out along the x-axis from where the /// names are being drawn to the scores. /// </summary> /// <param name="record"> High scores record containing names for all the scores </param> /// <returns>Length along the x axis that the rendering code should move </returns> //========================================================================================= private float GetNameLabelLength( LevelHighScores.HighScoreRecord record ) { // If we have no font return 0: if ( m_font == null ) return 0; // Get the size of all three names in the high scores: add 4 spaces to each also float s1 = m_font.GetStringSize( record.Name1 + " " ).X; float s2 = m_font.GetStringSize( record.Name2 + " " ).X; float s3 = m_font.GetStringSize( record.Name3 + " " ).X; // Get the longest of the lot: float longest = s1; if ( s2 > longest ) longest = s2; if ( s3 > longest ) longest = s3; // Return the longest string: return longest; }