//Método que añade diez primeros jugadores con el puntaje mas alto private void BestPlayers() { //Inializando los textos lblPlayers.Text = "\n Players\n"; lblScore.Text = "\nScore\n"; //Guardando los diez jugadores con su respectivo puntaje var PlayerList = ScoreDAO.GetNickNames(); var ScoreList = ScoreDAO.GetScores(); //Llenando los textos con los jugadores for (int i = 0; i < PlayerList.Count; i++) { //Utilizado para indentar de manera correcta los textos switch (i) { case 0: lblPlayers.Text += $"{i + 1} " + PlayerList[i] + "\n"; break; case 9: lblPlayers.Text += $"{i + 1} " + PlayerList[i] + "\n"; break; default: lblPlayers.Text += $"{i + 1} " + PlayerList[i] + "\n"; break; } lblScore.Text += ScoreList[i] + "\n"; } }
/// <summary> /// 执行登录-函数名与ActionCode相同,这里面的参数也就是反射机制那里调用时的参数 /// </summary> /// <param name="data">客户端loginRequest传来的数据</param> /// <param name="client">Client的引用</param> /// <param name="server">Server的引用</param> public string Login(string data, Client client, Server server) { //拆分传来的data string[] strArr = data.Split('#'); string username = strArr[0]; string password = strArr[1]; //调用UserDAO的验证用户方法 User user = UserDAO.VerifyUser(client.MysqlConn, username, password); //回给客户端响应 if (user == null) { //登陆失败 //将ReturnCode.Fail转化为字符串返回 return(((int)ReturnCode.Fail).ToString()); } else { //登录成功-查询战绩 Score score = ScoreDAO.GetScoreByUserId(client.MysqlConn, user.Id); //为Client中的User对象和Score对象初始化 client.user = user; client.score = score; //将ReturnCode.Success转化为字符串,以及用户id,用户名,总场数,胜利数都转化为字符串返回.用#分割 string info = ((int)ReturnCode.Success).ToString() + "#" + user.Id + "#" + user.Username + "#" + score.TotalCount + "#" + score.WinCount; return(info); } }
public HttpResponseMessage ApiGetAllPlaceScore(int id) { ScoreDAO scoreDAO = new ScoreDAO(); IEnumerable <Score> scoreList = scoreDAO.SelectAllScore(id, out string message); var scoreToJson = JsonConvert.SerializeObject(scoreList); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, scoreToJson); return(response); }
public string ApiDeleteScoreById(int id) { ScoreDAO scoreDAO = new ScoreDAO(); if (scoreDAO.DeleteScoreById(id, out string message)) { return("Avaliação excluida com sucesso! "); } else { return("Erro ao deletar Avaliação " + message); } }
/* * Método: void LoadLabels() * * Función: carga las puntuaciones. * * Descripción: crea dos columnas de labels en orden decreciente (puntuación más alta primero), la primera * columna de nombres y la segunda de puntuaciones correspondientes. Se envía una excepción la lista está vacía. */ private void LoadLabels() { try { int I = 0; List <Score> list = ScoreDAO.GetTop10(); if (list.Count == 0) { throw new NoScoreSavedException("There are no scores at the moment"); } for (int i = 0; i < list.Count; i++) { labels[i] = new Label(); tableLayoutPanel1.Controls.Add(labels[i]); tableLayoutPanel1.SetRow(labels[i], i + 2); tableLayoutPanel1.SetColumn(labels[i], 1); labels[i].Text = list[i].username; labels[i].TextAlign = ContentAlignment.MiddleCenter; labels[i].Font = new Font("Zorque", 12); labels[i].ForeColor = Color.White; labels[i].Dock = DockStyle.Fill; I++; } for (int i = 0; i < list.Count; i++) { labels[I] = new Label(); tableLayoutPanel1.Controls.Add(labels[I]); tableLayoutPanel1.SetRow(labels[I], i + 2); tableLayoutPanel1.SetColumn(labels[I], 2); labels[I].Text = list[i].score.ToString(); labels[I].TextAlign = ContentAlignment.MiddleCenter; labels[I].Font = new Font("Zorque", 12); labels[I].ForeColor = Color.White; labels[I].Dock = DockStyle.Fill; I++; } }catch (NoScoreSavedException ex) { tableLayoutPanel1.Controls.Add(lblException); tableLayoutPanel1.SetColumn(lblException, 1); tableLayoutPanel1.SetRow(lblException, 2); tableLayoutPanel1.SetColumnSpan(lblException, 2); lblException.Text = ex.Message; lblException.Font = new Font("Zorque", 10); lblException.TextAlign = ContentAlignment.MiddleCenter; lblException.ForeColor = Color.White; lblException.Dock = DockStyle.Fill; } }
public HttpResponseMessage ApiDeleteScoreById(int id) { ScoreDAO scoreDAO = new ScoreDAO(); if (scoreDAO.DeleteScoreById(id, out string message)) { return(new HttpResponseMessage(HttpStatusCode.NoContent)); } else { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError, message); return(response); } }
public string ApiGetAllPlaceScore(int id) { ScoreDAO scoreDAO = new ScoreDAO(); List <Score> scoreList = scoreDAO.SelectAllScore(id, out string message); if (scoreList == null) { return(message); } var scoreJson = JsonConvert.SerializeObject(scoreList); return(scoreJson); }
private void LoadScores() { try { Scoresp = ScoreDAO.getLista(); listScores = ScoreDAO.getTop(Scoresp); } catch (Exception e) { MessageBox.Show(e.Message); } players = new Label[10, 2]; int sampleTop = label1.Bottom + 25, sampleLeft = 10; for (int i = 0; i < listScores.Count; i++) { for (int j = 0; j < 2; j++) { players[i, j] = new Label(); if (j == 0) { players[i, j].Text = listScores[i].Name; players[i, j].Left = sampleLeft; } else { players[i, j].Text = listScores[i].Score.ToString(); players[i, j].Left = Width / 2 + sampleLeft; } players[i, j].Top = sampleTop + (sampleTop / 2) * i; players[i, j].Height += 4; players[i, j].Width += 20; players[i, j].Font = new Font("Microsoft YaHei", 14F); players[i, j].TextAlign = ContentAlignment.MiddleCenter; Controls.Add(players[i, j]); } } }
/* * Método: private void GameIsOver() * * Función: finalizar juego * * Descripción: Verifica si el juego ha terminado, ya sea con una victoria * o con una derrota. Si el juego ha terminado, guarda la puntuación final * del jugador y detiene el reloj de actualizaciones del juego. */ private void GameIsOver() { if (GameData.gameOver) { GameData.gameStart = false; //el jugador ha ganado if (GameData.victory) { /*Aplicar multiplier basado en el tiempo que tomo para completar * el juego y las vidas restantes del jugador.*/ score += (score * 10 / time) * hp; txtScore.Text = "SCORE: " + score; VictoryScreen.BackgroundImage = Resources.VictoryImg; VictoryScreen.BackgroundImageLayout = ImageLayout.Stretch; VictoryScreen.Height = (int)(Height * 0.65); VictoryScreen.Width = (int)(Width * 0.80); VictoryScreen.Top = (int)(Height * 0.20); VictoryScreen.Left = (int)(Width * 0.08); VictoryScreen.Show(); } //el jugador ha perdido else { GameOverScreen.BackgroundImage = Resources.GameOverImg; GameOverScreen.BackgroundImageLayout = ImageLayout.Stretch; GameOverScreen.Height = (int)(Height * 0.5); GameOverScreen.Width = (int)(Width * 0.8); GameOverScreen.Top = (int)(Height * 0.25); GameOverScreen.Left = (int)(Width * 0.08); GameOverScreen.Show(); } //detener relojes secondsTimer.Stop(); gameTimer.Stop(); //guardar puntuación Score s = new Score(score, playahata.username); ScoreDAO.AddScore(s); } }
/// <summary> /// 用于更新玩家的战绩-游戏结束时调用 /// </summary> /// <param name="isWin">赢了吗</param> public void UpdateUserScore(bool isWin) { if (isWin) { //胜利 score.TotalCount++; score.WinCount++; ScoreDAO.UpdateUserScoreRecordByUserid(mysqlConn, user.Id, score.TotalCount, score.WinCount); } else { //失败 score.TotalCount++; ScoreDAO.UpdateUserScoreRecordByUserid(mysqlConn, user.Id, score.TotalCount, score.WinCount); } //告知客户端更新现在的显示【房间列表界面左侧的战绩信息】 string data = score.TotalCount + "#" + score.WinCount; _currentServer.SendResponseToClient(this, ActionCode.UpdatePlayerInfo, data); }
public string ApiAddNewScore(int id, [FromBody] Score score) { ScoreDAO scoreDAO = new ScoreDAO(); Score _scoreWithTotal = new Score(); _scoreWithTotal.UserId = score.UserId; _scoreWithTotal.DistanceScore = score.DistanceScore; _scoreWithTotal.MaskScore = score.MaskScore; _scoreWithTotal.CleanScore = score.CleanScore; _scoreWithTotal.TotalScore = Math.Round((score.MaskScore + score.CleanScore + score.DistanceScore) / 3, 2); if (scoreDAO.InsertNewScore(id, _scoreWithTotal, out string message)) { return("Avaliação adicionada com sucesso! "); } else { return("Erro ao cadastrar o Avaliação " + message); } }
//Revisa los bloques restantes y finaliza el juego. private void CheckGame() { //Verificar que no hayan más bloques if (GameData.GameScore == 180) { //detener timer timer1.Stop(); //Agregar puntaje ScoreDAO.AddScore(GameData.GameScore * GameData.Lives, player.nickname); MessageBox.Show("Felicidades ha completado el juego.", "Arkanoid", MessageBoxButtons.OK); //Cambiar de menu ControlMenu menu = new ControlMenu(); //Reiniciar valores de juego para permitir juego nuevo GameData.Lives = 3; GameData.GameScore = 0; GameData.GameStarted = false; //Cambiar de userControl ((frmGame)this.Parent).ShowControl(menu); } }
public HttpResponseMessage ApiAddNewScore(int id, [FromBody] Score score) { ScoreDAO scoreDAO = new ScoreDAO(); Score _scoreWithTotal = new Score(); _scoreWithTotal.UserId = score.UserId; _scoreWithTotal.DistanceScore = score.DistanceScore; _scoreWithTotal.MaskScore = score.MaskScore; _scoreWithTotal.CleanScore = score.CleanScore; _scoreWithTotal.TotalScore = Math.Round((score.MaskScore + score.CleanScore + score.DistanceScore) / 3, 2); if (scoreDAO.InsertNewScore(id, _scoreWithTotal, out string message)) { return(new HttpResponseMessage(HttpStatusCode.Created)); } else { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError, message); return(response); } }
public ScoreAplicacao() { repositorio = new ScoreDAO(); }
public bool SaveScore(User user, PlayerStat score) { ScoreDAO service = new ScoreDAO(); return(service.SaveScore(user, score)); }
public List <PlayerStat> GetUserScores(User user) { ScoreDAO service = new ScoreDAO(); return(service.GetUserScores(user)); }
public List <PlayerStat> GetGlobalScores() { ScoreDAO service = new ScoreDAO(); return(service.GetAllScores()); }
//Poblar el data grid view con los datos de la consulta private void ControlTop10_Load(object sender, EventArgs e) { sound.PlayLooping(); dgvScoresTop10.DataSource = null; dgvScoresTop10.DataSource = ScoreDAO.GetTop10(); }
//se va a guardar el puntaje del jugador private void SaveScore() { ScoreDAO.AddScore(anUser.Id_u, DataGame.score); }
private void Menu_Load(object sender, EventArgs e) { Scores = ScoreDAO.getLista(); _usersxScore = ScoreDAO.getTop(Scores); }