/// <summary> /// Metodo para carregar os rankings e mostrar no painel /// </summary> public void LoadRankings() { //Carrega os rankings atuais do arquivo rankings.sr em uma lista List <SerializableScore> scoresList = RankingUtils.GetRankings(); //Limpa todos os objetos de score no painel de ranking ClearChilds(); //Conta quantos elementos tem na lista int scoreListCount = scoresList.Count; //Caso seja maior que 5 mudar o valor para 5 scoreListCount = scoreListCount > 5 ? 5 : scoreListCount; //Verifica se a lista tem mais que 0 elementos if (scoreListCount > 0) { //Percorre a lista for (int i = 0; i < scoreListCount; i++) { //Seta o painel de score com as informações do score atual scorePanel.transform.GetChild(0).GetComponent <Text>().text = scoresList[i].Name; scorePanel.transform.GetChild(1).GetComponent <Text>().text = scoresList[i].Score.ToString(); scorePanel.transform.GetChild(2).GetComponent <Text>().text = (i + 1).ToString(); //Instancia o painel de score no painel de ranking GameObject newScore = Instantiate(scorePanel); //Muda o nome do painel de score newScore.name = scoresList[i].Name + " ScorePanel"; //Seta o novo painel de score como filho do painel de ranking newScore.transform.SetParent(transform, false); } } }
// GET: Ranking public ActionResult Index() { string RedisServer = WebConfigurationManager.AppSettings["redisServer"]; ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(RedisServer); IDatabase db = redis.GetDatabase(); RankingModel model = new RankingModel(); RankingUtils ranking = new RankingUtils(); model.Ranking = ranking.get_topAccess_list(); return(View(model)); }
/// <summary> /// Metodo para adicionar o score da sessão atual para o arquivo rankings.sr /// </summary> private void AddScoreToRanking() { RankingUtils.AddRanking(score); }
public void Ok() { RankingUtils.ResetRanking(); Back(); }