示例#1
0
        public static void UpdatePoints(float Time)
        {
            bool DEBUG_HIT = false;

            CSong song = _GameMode.GetSong();

            if (song == null)
            {
                return;
            }

            float b = GetBeatFromTime(Time, song.BPM, song.Gap);

            if (b <= _Beat)
            {
                return;
            }

            _Beat        = b;
            _CurrentBeat = (int)Math.Floor(_Beat);

            _MidBeatD     = -0.5f + GetBeatFromTime(Time, song.BPM, song.Gap + CConfig.MicDelay / 1000f);
            _CurrentBeatD = (int)Math.Floor(_MidBeatD);

            for (int p = 0; p < _NumPlayer; p++)
            {
                CSound.AnalyzeBuffer(p);
            }

            if (_OldBeatD >= _CurrentBeatD)
            {
                return;
            }

            for (int p = 0; p < _NumPlayer; p++)
            {
                for (int beat = _OldBeatD + 1; beat <= _CurrentBeatD; beat++)
                {
                    if ((_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) ||
                        (_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat))
                    {
                        _Player[p].SongFinished = true;
                    }

                    CLine[] lines = song.Notes.GetLines(_Player[p].LineNr).Line;
                    int     Line  = -1;

                    for (int j = 0; j < lines.Length; j++)
                    {
                        if (beat >= lines[j].StartBeat && beat <= lines[j].EndBeat)
                        {
                            Line = j;
                            break;
                        }
                    }

                    if (Line >= 0)
                    {
                        if (Line != _Player[p].CurrentLine)
                        {
                            _Player[p].CurrentNote = -1;
                        }

                        _Player[p].CurrentLine = Line;

                        while (_Player[p].SingLine.Count <= Line)
                        {
                            _Player[p].SingLine.Add(new CLine());
                        }

                        CNote[] notes = lines[Line].Notes;
                        int     Note  = -1;
                        for (int j = 0; j < notes.Length; j++)
                        {
                            if (beat >= notes[j].StartBeat && beat <= notes[j].EndBeat)
                            {
                                Note = j;
                                break;
                            }
                        }

                        if (Note >= 0)
                        {
                            _Player[p].CurrentNote = Note;

                            if (Line == lines.Length - 1)
                            {
                                if (Note == lines[Line].NoteCount - 1)
                                {
                                    if (notes[Note].EndBeat == beat)
                                    {
                                        _Player[p].SongFinished = true;
                                    }
                                }
                            }

                            if (notes[Note].PointsForBeat > 0 && (CSound.RecordToneValid(p) || DEBUG_HIT))
                            {
                                int Tone       = notes[Note].Tone;
                                int TonePlayer = CSound.RecordGetTone(p);

                                while (TonePlayer - Tone > 6)
                                {
                                    TonePlayer -= 12;
                                }

                                while (TonePlayer - Tone < -6)
                                {
                                    TonePlayer += 12;
                                }

                                if (DEBUG_HIT)
                                {
                                    TonePlayer = Tone;
                                }

                                _Player[p].NoteDiff = Math.Abs(Tone - TonePlayer);
                                if (_Player[p].NoteDiff <= (2 - (int)_Player[p].Difficulty))
                                {
                                    // valid
                                    //CSound.RecordSetTone(p, Tone);
                                    double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[Note].PointsForBeat / (double)song.Notes.GetLines(_Player[p].LineNr).Points;
                                    if (notes[Note].NoteType == ENoteType.Golden)
                                    {
                                        _Player[p].PointsGoldenNotes += points;
                                    }

                                    _Player[p].Points += points;

                                    // update player notes (sung notes)
                                    if (_Player[p].SingLine[Line].NoteCount > 0)
                                    {
                                        CNote nt = _Player[p].SingLine[Line].LastNote;
                                        if (notes[Note].StartBeat == beat || nt.EndBeat + 1 != beat || nt.Tone != Tone)
                                        {
                                            _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType));
                                        }
                                        else
                                        {
                                            _Player[p].SingLine[Line].IncLastNoteLength();
                                        }
                                    }
                                    else
                                    {
                                        _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType));
                                    }

                                    _Player[p].SingLine[Line].LastNote.IsPerfect(notes[Note]);
                                    _Player[p].SingLine[Line].IsPerfect(lines[Line]);
                                }
                                else
                                {
                                    if (_Player[p].SingLine[Line].NoteCount > 0)
                                    {
                                        CNote nt = _Player[p].SingLine[Line].LastNote;
                                        if (nt.EndBeat + 1 != beat || nt.Hit)
                                        {
                                            _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle));
                                        }
                                        else
                                        {
                                            if (nt.Tone == TonePlayer && nt.EndBeat + 1 == beat)
                                            {
                                                _Player[p].SingLine[Line].IncLastNoteLength();
                                            }
                                            else
                                            {
                                                _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle));
                                    }
                                }
                            }

                            // Line Bonus
                            int NumLinesWithPoints = song.Notes.GetNumLinesWithPoints(_Player[p].LineNr);
                            if (Note == lines[Line].NoteCount - 1 && NumLinesWithPoints > 0)
                            {
                                if (notes[Note].EndBeat == beat && lines[Line].Points > 0f)
                                {
                                    double factor = (double)_Player[p].SingLine[Line].Points / (double)lines[Line].Points;
                                    if (factor < 0.4)
                                    {
                                        factor = 0.0;
                                    }
                                    else if (factor > 0.9)
                                    {
                                        factor = 1.0;
                                    }
                                    else
                                    {
                                        factor -= 0.4;
                                        factor *= 2;
                                        factor *= factor;
                                    }

                                    double points = CSettings.LinebonusScore * factor * 1f / NumLinesWithPoints;
                                    _Player[p].Points          += points;
                                    _Player[p].PointsLineBonus += points;
                                }
                            }
                        }
                    }
                }
            }
            _OldBeatD = _CurrentBeatD;
        }