Exemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (((RhythmGame)Game).State == RhythmGame.GameStateType.Paused)
            {
                if (Input.OtherKeyPressed(OtherKeyType.Select))
                {
                    ChangeState(RhythmGame.GameStateType.Running);
                    return;
                }
            }

            if (((RhythmGame)Game).State != RhythmGame.GameStateType.Running)
            {
                return;
            }

            bool onLastNote = false;

            if (Notes.SongDone)
            {
                if (waitTimer > TimeSpan.Zero)
                {
                    waitTimer -= gameTime.ElapsedGameTime;
                    onLastNote = true;
                }
                else
                {
                    ChangeState(RhythmGame.GameStateType.SongSuccess);
                    return;
                }
            }

            if (Input.OtherKeyPressed(OtherKeyType.Pause))
            {
                ChangeState(RhythmGame.GameStateType.Paused);
                return;
            }

            SongData.NoteSet[] noteSet = Notes.NoteSet;
            int beginIndex             = Notes.CurrentBeginIndex;
            int endIndex = Notes.CurrentEndIndex;

            ulong pressed = Input.FullPressed;
            ulong held    = Input.FullHeld;

            if (onLastNote)
            {
                beginIndex--;
                endIndex--;
            }

            int  noteRange       = (endIndex - beginIndex);
            bool splitNotes      = noteRange > 1;
            bool shouldIncrement = false;


            bool nextIsValid = Notes.ValidRange(Notes.NextIndex);

            if (Input.Strummed && nextIsValid)
            {
                bool wasBurning = false;
                for (int noteIdx = beginIndex; noteIdx <= endIndex; noteIdx++)
                {
                    SongData.NoteSet note = noteSet[noteIdx];
                    if (note.burning != 0L)
                    {
                        wasBurning = true;
                    }
                    note.burning = 0L;
                }
                if (wasBurning)
                {
                    Notes.IncrementPastEnd();
                }
            }

            for (int noteIdx = beginIndex; noteIdx <= endIndex; noteIdx++)
            {
                SongData.NoteSet note = noteSet[noteIdx];
                if (Input.Strummed && (note.burning != 0L) && !Notes.IsInNotePadding(note))
                {
                    note.burning    = 0L;
                    shouldIncrement = true;
                    continue;
                }

                if (Notes.ValidRange() || (Notes.BurningRange() && (note.burning != 0L)))
                {
                    if (!Notes.BurningRange() && note.burning != 0L)
                    {
                        shouldIncrement = true;
                        continue;
                    }
                    if (Input.Strummed)
                    {
                        note.Strum();
                    }

                    note.AddPressedGuitar(_instrument, held);
                    goodHits = note.IsGood(_instrument, note.IsHOPO(_instrument)); //Notes.NoteIndex > 0 && noteSet[Notes.NoteIndex - 1].visible[0] == SongData.NoteSet.VIS_STATE.INVISIBLE);
                    bool burningBetter = (note.burning != 0L) && (goodHits > note.burning);
                    bool trueHit       = goodHits > 0 && note.burning == 0L;
                    if (trueHit || burningBetter)
                    {
                        HitNote(note);
                        // Another hack... don't deal damage for burning hopos.
                        bool burningHOPO = (note.length <= 0) && note.IsHOPO(_instrument);
                        if (!burningHOPO && note.NumMissed > 0)
                        {
                            DealDamage(note);
                        }

                        if (note.length > 0)
                        {
                            note.burning = goodHits;
                        }
                        else
                        {
                            shouldIncrement = true;
                        }
                        note.exploding = goodHits;
                    }
                    else if (note.burning != 0L)
                    {
                        if (Notes.BurningRange() && (goodHits & note.type) != 0L)
                        {
                            note.burning &= goodHits;
                            BurnNote(note, gameTime);
                            //note.exploding = true;
                        }
                        else
                        {
                            note.burning    = 0L;
                            shouldIncrement = true;
                        }
                    }
                    else if (Notes.LateRange())
                    {
                        DealDamage(note);
                        //missedNote = note; // 4.0change
                        for (int i = 0; i < note.visible.Length; i++)
                        {
                            if (note.visible[i] == SongData.NoteSet.VIS_STATE.VISIBLE)
                            {
                                note.visible[i] = SongData.NoteSet.VIS_STATE.GREYED_OUT;
                            }
                        }
                        shouldIncrement = true;
                    }
                    held = (held ^ goodHits);
                }
                else
                {
                    if (Input.Strummed && !note.IsHOPO(_instrument))
                    {
                        if (noteIdx == 0 || !noteSet[noteIdx - 1].IsHOPO(_instrument))
                        {
                            // 4.0change - Additionally, don't penalize when strumming immediately after a HOPO note
                            if (noteIdx == 0 || !(noteSet[noteIdx - 1].IsHOPO(_instrument) && Notes.LateRange(noteIdx - 1)))
                            {
                                DealDamage(note);
                            }
                        }
                        //missedNote = note; // 4.0change
                    }
                }
            }

            if (shouldIncrement)
            {
                Notes.IncrementPastEnd();
            }
        }