Example #1
0
 void Start()
 {
     _instrument = transform.parent.GetComponentInChildren<Instrument>();
     char[] splitters = { '\n' };
     string[] allStringTimings = trackFile.text.Split(splitters);
     _noteTimings = new Queue();
     foreach(string s in allStringTimings) {
         if(!string.IsNullOrEmpty(s)) {
             _noteTimings.Enqueue((float) Convert.ToInt32(s));
         }
     }
     _startTime = Time.time;
     Debug.Log(_noteTimings.Peek());
 }
Example #2
0
        public void OnInstrumentHit(Instrument instrument, float hitTime)
        {
            float offset = hitTime - _lastNoteTime;

            if(offset < _timeOffset) {
                _soundManager.PlayHitSound();
                OnGoodHit(_lastNote, offset);
            }
            else {
                _soundManager.PlayMissSound();
                _lastHitTime = hitTime;
                if(_lastNote != null) {
                    Debug.Log("miss");
                    _lastNote.OnNoteMissed();
                    _lastNote = null;
                }
                _lastNoteTime = -1.0f;
            }
        }