Beispiel #1
0
        private void ChangeRound(int Num)
        {
            CPoints points = CGame.GetPoints();

            if (points.NumRounds < 2)
            {
                return;
            }

            _Round += Num;

            if (Num > 0)
            {
                if (_Round >= points.NumRounds)
                {
                    _Round = 0;
                }

                LoadScores();
            }

            if (Num < 0)
            {
                if (_Round < 0)
                {
                    _Round = points.NumRounds - 1;
                }

                LoadScores();
            }
        }
Beispiel #2
0
        private void _ChangeRound(int num)
        {
            CPoints points = CGame.GetPoints();

            _Round += num;
            _Round  = _Round.Clamp(0, points.NumRounds - 1);
            _UpdateRound();
        }
Beispiel #3
0
        public override void OnShow()
        {
            base.OnShow();
            _Round  = 1;
            _Points = CGame.GetPoints();

            SetVisuability();
            UpdateRatings();
        }
Beispiel #4
0
        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--;
            }
        }
Beispiel #5
0
        private void _UpdateRound()
        {
            _IsDuet = false;
            CPoints points = CGame.GetPoints();

            CSong song;

            if (_FromScreenSong)
            {
                song = CSongs.GetSong(CScreenSong.getSelectedSongID());
            }
            else
            {
                song = CGame.GetSong(_Round);
            }

            if (song == null)
            {
                return;
            }

            _Texts[_TextSongName].Text = song.Artist + " - " + song.Title;
            if (points != null && !_FromScreenSong && points.NumRounds > 1)
            {
                _Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
            }

            switch ((_FromScreenSong ? (EGameMode)_Round : CGame.GetGameMode(_Round)))
            {
            case EGameMode.TR_GAMEMODE_NORMAL:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
                break;

            case EGameMode.TR_GAMEMODE_MEDLEY:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_MEDLEY";
                break;

            case EGameMode.TR_GAMEMODE_DUET:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_DUET";
                _IsDuet = true;
                break;

            case EGameMode.TR_GAMEMODE_SHORTSONG:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_SHORTSONG";
                break;

            default:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
                break;
            }

            _Pos = 0;
        }
Beispiel #6
0
        public override void OnShow()
        {
            base.OnShow();
            //-1 --> Show average
            _Round  = CGame.NumRounds > 1 ? -1 : 0;
            _Points = CGame.GetPoints();

            _SavePlayedSongs();

            _SetVisibility();
            _UpdateRatings();
            _SlideShowBG.Visible = _UpdateBackground();
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
        public override void OnShow()
        {
            base.OnShow();
            //-1 --> Show average
            _Round  = CGame.NumRounds > 1 ? -1 : 0;
            _Points = CGame.GetPoints();

            _SavePlayedSongs();

            _SetVisibility();
            _UpdateRatings();
            _SlideShowBG.Visible = _UpdateBackground();

            for (int p = 0; p < CGame.NumPlayers; p++)
            {
                _Statics[_StaticAvatar[p, CGame.NumPlayers - 1]].Aspect = EAspect.Crop;
            }
        }
Beispiel #9
0
        private void ChangeRound(int Num)
        {
            CPoints _Points = CGame.GetPoints();

            if (_Round + Num < _Points.NumRounds && _Round + Num > -1)
            {
                _Round += Num;
            }
            else if (_Round + Num >= _Points.NumRounds)
            {
                _Round = _Points.NumRounds - 1;
            }
            else if (_Round + Num < 0)
            {
                _Round = 0;
            }
            UpdateRound();
        }
Beispiel #10
0
        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;
                    }
                }
            }
        }
Beispiel #11
0
        public override void OnShow()
        {
            base.OnShow();
            _Round = 0;
            _Pos   = 0;
            CPoints _Points = CGame.GetPoints();

            _Scores = new List <SScores> [_Points.NumRounds];
            for (int i = 0; i < _Scores.Length; i++)
            {
                _Scores[i] = new List <SScores>();
            }
            _NewEntryIDs.Clear();
            AddScoresToDB();
            LoadScores();
            UpdateRound();

            UpdateGame();
        }
Beispiel #12
0
        private void _UpdateRound()
        {
            _IsDuet = false;
            CPoints points = CGame.GetPoints();
            CSong   song   = CGame.GetSong(_Round);

            if (song == null)
            {
                return;
            }

            _Texts[_TextSongName].Text = song.Artist + " - " + song.Title;
            if (points.NumRounds > 1)
            {
                _Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
            }

            switch (CGame.GetGameMode(_Round))
            {
            case EGameMode.TR_GAMEMODE_NORMAL:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
                break;

            case EGameMode.TR_GAMEMODE_MEDLEY:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_MEDLEY";
                break;

            case EGameMode.TR_GAMEMODE_DUET:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_DUET";
                _IsDuet = true;
                break;

            case EGameMode.TR_GAMEMODE_SHORTSONG:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_SHORTSONG";
                break;

            default:
                _Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
                break;
            }

            _Pos = 0;
        }
Beispiel #13
0
        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;
            }
        }
Beispiel #14
0
        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]));
                    }
                }
            }
        }
Beispiel #15
0
        private void _ChangeRound(int num)
        {
            if (_FromScreenSong)
            {
                if (_Round == (int)EGameMode.TR_GAMEMODE_SHORTSONG)
                {
                    _Round = (int)EGameMode.TR_GAMEMODE_NORMAL;
                }
                else
                {
                    ++_Round;
                }
            }
            else
            {
                CPoints points = CGame.GetPoints();
                _Round += num;
                _Round  = _Round.Clamp(0, points.NumRounds - 1);
            }

            _UpdateRound();
        }
Beispiel #16
0
        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;
            }
        }
Beispiel #17
0
 public void Start(SPlayer[] players)
 {
     _Points = new CPoints(_SongQueue.Count, players);
 }
Beispiel #18
0
        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;
            }
        }