public override bool UpdateGame() { var players = new SPlayer[CGame.NumPlayers]; if (_Round >= 0) { players = _Points.GetPlayer(_Round, CGame.NumPlayers); } else { for (int i = 0; i < CGame.NumRounds; i++) { SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayers); for (int p = 0; p < players.Length; p++) { players[p].Points += points[p].Points; } } for (int p = 0; p < players.Length; p++) { players[p].Points = (int)(players[p].Points / CGame.NumRounds); } } return(true); }
public override bool UpdateGame() { var players = new SPlayer[CGame.NumPlayers]; if (_Round >= 0) { players = _Points.GetPlayer(_Round, CGame.NumPlayers); } else { for (int i = 0; i < CGame.NumRounds; i++) { SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayers); for (int p = 0; p < players.Length; p++) { players[p].Points += points[p].Points; } } for (int p = 0; p < players.Length; p++) { players[p].Points = (int)(players[p].Points / CGame.NumRounds); } } for (int p = 0; p < players.Length; p++) { if (_StaticPointsBarDrawnPoints[p] < players[p].Points) { if (CConfig.Config.Game.ScoreAnimationTime >= 1) { _StaticPointsBarDrawnPoints[p] = (_Timer.ElapsedMilliseconds / 1000f) / CConfig.Config.Game.ScoreAnimationTime * 10000; if (_StaticPointsBarDrawnPoints[p] > players[p].Points) { _StaticPointsBarDrawnPoints[p] = players[p].Points; } var direction = (string)_ScreenSettings[_ScreenSettingAnimationDirection].GetValue(); if (direction.ToLower() == "vertical") { _Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].W = ((float)_StaticPointsBarDrawnPoints[p]) * (_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].W / CSettings.MaxScore); } else { _Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].H = ((float)_StaticPointsBarDrawnPoints[p]) * (_Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].H / CSettings.MaxScore); _Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].Y = _Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].H + _Statics[_StaticPointsBarBG[p, CGame.NumPlayers - 1]].Y - _Statics[_StaticPointsBar[p, CGame.NumPlayers - 1]].H; } } } } return(true); }
public override bool UpdateGame() { SPlayer[] player = new SPlayer[CGame.NumPlayer]; if (_Round != 0) { player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); } else { for (int i = 0; i < CGame.NumRounds; i++) { SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer); for (int p = 0; p < player.Length; p++) { player[p].Points += points[p].Points; } } for (int p = 0; p < player.Length; p++) { player[p].Points = (int)(player[p].Points / CGame.NumRounds); } } for (int p = 0; p < player.Length; p++) { if (StaticPointsBarDrawnPoints[p] < player[p].Points) { if (CConfig.ScoreAnimationTime >= 1) { StaticPointsBarDrawnPoints[p] = (timer.ElapsedMilliseconds / 1000f) / CConfig.ScoreAnimationTime * 10000; if (StaticPointsBarDrawnPoints[p] > player[p].Points) { StaticPointsBarDrawnPoints[p] = player[p].Points; } Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H = ((float)StaticPointsBarDrawnPoints[p]) * (Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H / 10000); Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.Y = Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H + Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.Y - Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H; } } } return(true); }
private void _UpdateScores() { if (!GameData.Rounds[GameData.FieldNr].Finished) { GameData.CurrentRoundNr++; } CPoints points = CBase.Game.GetPoints(); SPlayer[] results = CBase.Game.GetPlayers(); if (results == null || results.Length < 2) { return; } //Sum up all points for (int r = 0; r < points.NumRounds; r++) { SPlayer[] player = points.GetPlayer(r, 2); for (int i = 0; i < 2; i++) { results[i].Points += player[i].Points; results[i].PointsGoldenNotes += player[i].PointsGoldenNotes; results[i].PointsLineBonus += player[i].PointsLineBonus; } } //Calc average of points for (int i = 0; i < 2; i++) { results[i].Points /= points.NumRounds; results[i].PointsGoldenNotes /= points.NumRounds; results[i].PointsLineBonus /= points.NumRounds; } //Decide who has won GameData.Rounds[GameData.FieldNr].PointsTeam1 = (int)Math.Round(results[0].Points); GameData.Rounds[GameData.FieldNr].PointsTeam2 = (int)Math.Round(results[1].Points); GameData.Rounds[GameData.FieldNr].Finished = true; if (GameData.Rounds[GameData.FieldNr].PointsTeam1 < GameData.Rounds[GameData.FieldNr].PointsTeam2) { GameData.Rounds[GameData.FieldNr].Winner = 2; } else if (GameData.Rounds[GameData.FieldNr].PointsTeam1 > GameData.Rounds[GameData.FieldNr].PointsTeam2) { GameData.Rounds[GameData.FieldNr].Winner = 1; } else { GameData.Rounds[GameData.FieldNr].Finished = false; GameData.CurrentRoundNr--; } }
private void LoadScores() { CPoints points = CGame.GetPoints(); if (points == null) { return; } _Pos = 0; for (int round = 0; round < points.NumRounds; round++) { SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0]; CDataBase.LoadScore(ref _Scores[round], player); } }
private void LoadScores() { CPoints points = CGame.GetPoints(); if (points == null) { return; } _Pos = 0; for (int round = 0; round < points.NumRounds; round++) { SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0]; CDataBase.LoadScore(ref _Scores, player); if (round == _Round) { _IsDuet = false; CSong song = CSongs.GetSong(player.SongID); Texts[htTexts(TextSongName)].Text = song.Artist + " - " + song.Title; switch (CGame.GameMode) { case EGameMode.Normal: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; case EGameMode.Medley: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_MEDLEY"; break; case EGameMode.Duet: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_DUET"; _IsDuet = true; break; default: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; } } } }
private void UpdateRound() { _IsDuet = false; CPoints points = CGame.GetPoints(); SPlayer player = points.GetPlayer(_Round, CGame.NumPlayer)[0]; CSong song = CGame.GetSong(_Round + 1); if (song == null) { return; } Texts[htTexts(TextSongName)].Text = song.Artist + " - " + song.Title; if (points.NumRounds > 1) { Texts[htTexts(TextSongName)].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")"; } switch (CGame.GetGameMode(_Round)) { case EGameMode.TR_GAMEMODE_NORMAL: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; case EGameMode.TR_GAMEMODE_MEDLEY: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_MEDLEY"; break; case EGameMode.TR_GAMEMODE_DUET: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_DUET"; _IsDuet = true; break; case EGameMode.TR_GAMEMODE_SHORTSONG: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_SHORTSONG"; break; default: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; } }
private void AddScoresToDB() { CPoints points = CGame.GetPoints(); if (points == null) { return; } for (int round = 0; round < points.NumRounds; round++) { SPlayer[] player = points.GetPlayer(round, CGame.NumPlayer); for (int p = 0; p < player.Length; p++) { if (player[p].Points > CSettings.MinScoreForDB && player[p].SongFinished && !CProfiles.IsGuestProfile(player[p].ProfileID)) { _NewEntryIDs.Add(CDataBase.AddScore(player[p])); } } } }
private void _UpdateScores() { //Prepare results table if (GameData.ResultTable.Count == 0) { for (int i = 0; i < GameData.NumPlayer; i++) { var row = new CResultTableRow { PlayerID = GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0 }; GameData.ResultTable.Add(row); } GameData.Results = new int[GameData.NumRounds, GameData.NumPlayerAtOnce]; for (int i = 0; i < GameData.NumRounds; i++) { for (int j = 0; j < GameData.NumPlayerAtOnce; j++) { GameData.Results[i, j] = 0; } } } //Get points from game CPoints points = CBase.Game.GetPoints(); SPlayer[] players = CBase.Game.GetPlayers(); //Go over all rounds and sum up points for (int round = 0; round < points.NumRounds; round++) { SPlayer[] res = points.GetPlayer(round, GameData.NumPlayerAtOnce); if (res == null || res.Length < GameData.NumPlayerAtOnce) { return; } for (int p = 0; p < GameData.NumPlayerAtOnce; p++) { players[p].Points += res[p].Points; players[p].PointsGoldenNotes += res[p].PointsGoldenNotes; players[p].PointsLineBonus += res[p].PointsLineBonus; } } //Calculate average points for (int p = 0; p < GameData.NumPlayerAtOnce; p++) { players[p].Points /= points.NumRounds; players[p].PointsGoldenNotes /= points.NumRounds; players[p].PointsLineBonus /= points.NumRounds; //Save points in GameData GameData.Results[GameData.CurrentRoundNr - 2, p] = (int)Math.Round(players[p].Points); } List <SStats> stats = _GetPointsForPlayer(players); for (int i = 0; i < GameData.NumPlayerAtOnce; i++) { //Find matching row in results table int index = -1; for (int j = 0; j < GameData.ResultTable.Count; j++) { if (stats[i].ProfileID == GameData.ResultTable[j].PlayerID) { index = j; break; } } if (index == -1) { continue; } CResultTableRow row = GameData.ResultTable[index]; //Update results entry row.NumPlayed++; row.NumWon += stats[i].Won; row.NumSingPoints += stats[i].SingPoints; row.NumGamePoints += stats[i].GamePoints; GameData.ResultTable[index] = row; } GameData.ResultTable.Sort(); //Update position-number int pos = 1; int lastPoints = 0; int lastSingPoints = 0; foreach (CResultTableRow resultRow in GameData.ResultTable) { if (lastPoints > resultRow.NumGamePoints || lastSingPoints > resultRow.NumSingPoints) { pos++; } resultRow.Position = pos; lastPoints = resultRow.NumGamePoints; lastSingPoints = resultRow.NumSingPoints; } }
private void _UpdateScores() { if (GameData.ResultTable.Count == 0) { for (int i = 0; i < GameData.NumPlayer; i++) { CResultTableRow row = new CResultTableRow { PlayerID = GameData.ProfileIDs[i], NumPlayed = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0 }; GameData.ResultTable.Add(row); } GameData.Results = new int[GameData.NumRounds, GameData.NumPlayerAtOnce]; for (int i = 0; i < GameData.NumRounds; i++) { for (int j = 0; j < GameData.NumPlayerAtOnce; j++) { GameData.Results[i, j] = 0; } } } CPoints gamePoints = CBase.Game.GetPoints(); if (gamePoints == null || gamePoints.NumPlayer < GameData.NumPlayerAtOnce) { return; } SPlayer[] results = gamePoints.GetPlayer(0, GameData.NumPlayerAtOnce); if (results == null) { return; } if (results.Length < GameData.NumPlayerAtOnce) { return; } if (gamePoints.NumRounds == 0) { return; } for (int i = 1; i < gamePoints.NumRounds; i++) { SPlayer[] temp = gamePoints.GetPlayer(i, GameData.NumPlayerAtOnce); for (int p = 0; p < GameData.NumPlayerAtOnce; p++) { results[p].Points += temp[p].Points; } } for (int j = 0; j < GameData.NumPlayerAtOnce; j++) { results[j].Points = results[j].Points / gamePoints.NumRounds; GameData.Results[GameData.CurrentRoundNr - 2, j] = (int)Math.Round(results[j].Points); } List <SStats> points = _GetPointsForPlayer(results); for (int i = 0; i < GameData.NumPlayerAtOnce; i++) { int index = -1; for (int j = 0; j < GameData.ResultTable.Count; j++) { if (points[i].ProfileID == GameData.ResultTable[j].PlayerID) { index = j; break; } } if (index != -1) { CResultTableRow row = GameData.ResultTable[index]; row.NumPlayed++; row.NumWon += points[i].Won; row.NumSingPoints += points[i].SingPoints; row.NumGamePoints += points[i].GamePoints; GameData.ResultTable[index] = row; } } GameData.ResultTable.Sort(); //Update position-number int pos = 1; int lastPoints = 0; int lastSingPoints = 0; foreach (CResultTableRow resultRow in GameData.ResultTable) { if (lastPoints > resultRow.NumGamePoints || lastSingPoints > resultRow.NumSingPoints) { pos++; } resultRow.Position = pos; lastPoints = resultRow.NumGamePoints; lastSingPoints = resultRow.NumSingPoints; } }