Ejemplo n.º 1
0
        private void updateDataGrid()
        {
            dgvScore.Rows.Clear();
            int order = cmbOrderBy.SelectedIndex;

            List<ScoreDTO> list = new ScoreDAO().getScore(new PlayerDTO(Start.getLoadPlayer()));
            List<ScoreDTO> ordered_list = new List<ScoreDTO>();
            switch(order){
                case 0:
                    ordered_list = list.OrderBy(o => o.score).ToList();
                    break;
                case 1:
                    ordered_list = list.OrderBy(o => (int)o.difficulty).ToList();
                    break;
                case 2:
                    ordered_list = list.OrderBy(o => (int)o.game_mode).ToList();
                    break;
                default:
                    ordered_list = list.OrderBy(o => (int)o.score).ToList();
                    break;
            }

            foreach (var score in ordered_list)
            {
                string[] row = { score.score.ToString(), score.difficulty.ToString(), score.game_mode.ToString() };
                dgvScore.Rows.Add(row);
            }
        }
Ejemplo n.º 2
0
 private void populateScoreDataGrid()
 {
     List<ScoreDTO> list = new ScoreDAO().getScore(new PlayerDTO(Start.getLoadPlayer()));
     foreach (var score in list)
     {
         string[] row = { score.score.ToString(), score.difficulty.ToString(), score.game_mode.ToString() };
         dgvScore.Rows.Add(row);
     }
 }
Ejemplo n.º 3
0
 public void saveGameScore()
 {
     if (this.game_mode == GameMode.SINGLE_PLAYER)
     {
         if (this.playerA.score > 0)
         {
             ScoreDAO scoreDAO = new ScoreDAO();
             scoreDAO.create(new ScoreDTO(this.playerA.id, this.playerA.score, this.difficulty, this.game_mode));
         }
     }
     else if (this.game_mode == GameMode.MULTI_PLAYER_STANDALONE)
     {
         ScoreDAO scoreDAO = new ScoreDAO();
         if (this.playerA.score > 0)
         {
             scoreDAO.create(new ScoreDTO(this.playerA.id, this.playerA.score, this.difficulty, this.game_mode));
         }
         if (this.playerB.score > 0)
         {
             scoreDAO.create(new ScoreDTO(this.playerB.id, this.playerB.score, this.difficulty, this.game_mode));
         }
     }
 }
Ejemplo n.º 4
0
 public void saveScore()
 {
     if (Game.current_game.game_mode == GameMode.SINGLE_PLAYER)
     {
         ScoreDAO scoreDAO = new ScoreDAO();
         scoreDAO.create(new ScoreDTO(this.id, this.score, Game.current_game.difficulty, Game.current_game.game_mode));
     }
 }