Example #1
0
        public void Update(float second)
        {
            //Update self's state
            float time = PhiUnitConvert.secondToTime(second, bpm);

            UpdateValues(time);
            JudgeLineRenderer.startColor        = JudgeLineRenderer.endColor = currentColor;
            JudgeLineTransform.localEulerAngles = new Vector3(0, 0, currentRotation);
            JudgeLineTransform.localPosition    = currentPosition;

            //Update all contained notes
            float currentFloorPosition = PhiUnitConvert.timeToFloorPosition(time, this);

            foreach (var note in notesAbove)
            {
                //Attempt to play judge effect as long as the note is still playing (JudgeEffect'll handle playing the correct loop time)
                if (note.Enabled & time >= note.time)
                {
                    note.Judge(time);
                }
                //Disable judged notes or notes too far ahead
                if (time > note.time + note.holdTime || (note.floorPosition - currentFloorPosition) > 5)
                {
                    note.Enabled = false;
                    continue;
                }
                note.Enabled = true;
                note.Update(currentFloorPosition, time);
            }

            //Same as above
            foreach (var note in notesBelow)
            {
                if (note.Enabled & time >= note.time)
                {
                    note.Judge(time);
                }
                if (time > note.time + note.holdTime || (note.floorPosition - currentFloorPosition) > 5)
                {
                    note.Enabled = false;
                    continue;
                }
                note.Enabled = true;
                note.Update(currentFloorPosition, time);
            }
        }
Example #2
0
        private int GetCombo()
        {
            float second = AudioManager.Instance.Timing;
            CompareNoteByTimeAndHoldTime comparer = new CompareNoteByTimeAndHoldTime();
            int combo = 0;

            foreach (var judgeline in PhiChartFileReader.Instance.CurrentChart.JudgeLineList)
            {
                float   time      = PhiUnitConvert.secondToTime(second, judgeline.bpm);
                PhiNote dummyNote = new PhiNote(time);

                int found = judgeline.notesAbove.BinarySearch(dummyNote, comparer);
                //If current timing doesn't matches exactly with one note BinarySearch returns the bitwise complement of index of the next note
                combo += (found >= 0) ? found + 1 : -found - 1;

                found  = judgeline.notesBelow.BinarySearch(dummyNote, comparer);
                combo += (found >= 0) ? found + 1 : -found - 1;
                // Debug.Log(dummyNote.time + " " + found + " " + combo + " " + judgeline.numOfNotes);
            }
            return(combo);
        }