Пример #1
0
    public void NoteHit(NoteQuality quality, bool optional)
    {
        Debug.Log("Note HIT");

        switch (quality)
        {
        case NoteQuality.Normal:
            currentScore += scorePerNote;
            normalHits   += 1;
            break;

        case NoteQuality.Good:
            currentScore += scorePerGoodNote;
            goodHits     += 1;
            break;

        case NoteQuality.Perfect:
            currentScore += scorePerPerfectNote;
            perfectHits  += 1;
            break;
        }

        totalHits += 1;

        musicTrack.PlayOneShot(hitSound);
    }
Пример #2
0
 private void NoteHit(NoteQuality quality, float diff)
 {
     if (quality != NoteQuality.Miss)
     {
         ResetBeat();
         TriggerFade(1);
         _beatInputService.NoteHit -= NoteHit;
     }
 }
Пример #3
0
 public override void Executed(NoteQuality noteQuality, int streak)
 {
     UpdateClosestVisibleEnemy();
     _initPosition        = unit.transform.position;
     unit.Agent.isStopped = false;
     unit.Agent.speed     = unit.MovementSpeed + unit.MovementSpeed * streakBonus;
     if (_closestEnemy)
     {
         Vector3 direction = (_closestEnemy.transform.position - unit.transform.position).normalized;
         unit.Agent.destination = _closestEnemy.transform.position - direction * unit.Range;
     }
 }
Пример #4
0
        public override void Executed(NoteQuality noteQuality, int streak)
        {
            unit.Agent.isStopped   = false;
            unit.Agent.speed       = unit.MovementSpeed + unit.MovementSpeed * streakBonus;
            unit.Agent.destination = unit.transform.position + Vector3.up * 20;
            NavMeshHit hit;

            // true if terminated before reaching max distance
            if (unit.Agent.SamplePathPosition(NavMesh.AllAreas, unit.Agent.remainingDistance, out hit))
            {
                unit.Agent.destination = hit.position;
            }
        }
Пример #5
0
        public override void Executed(NoteQuality noteQuality, int streak)
        {
            // do nothing if current target still has health
            // otherwise search deposits on screen (closest first) and pick a target
            // pick targets depending on unit equipment (tier, type)
            _closestDeposit = unit.GetClosestDeposit();

            _initPosition        = unit.transform.position;
            unit.Agent.isStopped = false;
            unit.Agent.speed     = unit.MovementSpeed + unit.MovementSpeed * streakBonus;
            if (_closestDeposit)
            {
                Vector3 direction = (_closestDeposit.transform.position - unit.transform.position).normalized;
                unit.Agent.destination = _closestDeposit.transform.position - direction * GATHER_DISTANCE;
            }
        }
Пример #6
0
 private void OnNoteHit(NoteQuality quality, float diff)
 {
     if (quality != NoteQuality.Miss)
     {
         iTween.PunchRotation(mood.gameObject, 30f * (_moodDirection ? 1 : -1) * Vector3.forward, BeatInputService.NOTE_TIME * .9f);
         _moodDirection = !_moodDirection;
         _successCount++;
         if (_successCount >= 4)
         {
             _successCount = 0;
             SetMoodSpriteIndex(_moodIndex + 1);
         }
     }
     else
     {
         HandleFail();
     }
 }
Пример #7
0
        private void HandleNoteHit()
        {
            double dspTime         = AudioSettings.dspTime;
            double closestHalfNote = RoundToMetronome(dspTime);
            double closestFullNote = RoundToMetronomeFull(dspTime);

            _lastNoteTimeAbs = closestHalfNote;
            float noteTimeDiff       = (float)(_lastNoteTimeAbs - dspTime);
            float noteTimeDiffToFull = (float)(closestFullNote - dspTime);
            bool  canCreateBeat      = !HasBeat || _currentBeatRunTime >= 8 * NOTE_TIME - FAIL_TOLERANCE;

            if (canCreateBeat && Mathf.Abs(noteTimeDiffToFull) <= FAIL_TOLERANCE)
            {
                _currentBeatRunTime      = noteTimeDiffToFull;
                _currentBeatStartTimeAbs = RoundToMetronome(dspTime);
            }
            NoteQuality hitNoteQuality = CalcNoteQuality(noteTimeDiff);

            if (hitNoteQuality != NoteQuality.Miss)
            {
                _currentNotes.Add(Mathf.RoundToInt((float)_currentBeatRunTime / HALF_NOTE_TIME) * .5f);
                _currentQualities.Add(hitNoteQuality);
            }

            HasBeat = true;
            float[]     notesAsArray  = _currentNotes.ToArray();
            List <Song> matchingSongs = _songService.CheckSongs(notesAsArray);

            if (matchingSongs.Count == 1 && matchingSongs[0].Matches(notesAsArray))
            {
                ExecuteSong(hitNoteQuality, noteTimeDiff, matchingSongs[0]);
                return;
            }
            if (matchingSongs.Count == 0)
            {
                hitNoteQuality = NoteQuality.Miss;
                Debug.Log("No songs detected with that beat! Current beat was " + string.Join("-", _currentNotes));
            }
            NoteHit?.Invoke(hitNoteQuality, noteTimeDiff);
            if (hitNoteQuality == NoteQuality.Miss)
            {
                HandleBeatLost();
            }
        }
Пример #8
0
        private void ExecuteSong(NoteQuality hitNoteQuality, float beatTimeDiff, Song matchingSong)
        {
            NoteHit?.Invoke(hitNoteQuality, beatTimeDiff);
            if (_beatInputHandler == Constants.Noop)
            {
                // don't execute song if game has been finished with the last note
                return;
            }
            _streakScore += _currentQualities.Aggregate(0, (total, curQuality) => total + (int)curQuality);
            _streakPower  = Mathf.Min(_streakScore / Constants.REQUIRED_STREAK_SCORE, Constants.MAX_STREAK_POWER);
            _currentSong  = matchingSong;
            int curStreakPower = _streakPower;

            _currentSong.ExecuteCommand(hitNoteQuality, curStreakPower);
            _coroutineProvider.StartCoroutine(Coroutines.ExecuteAfterSeconds(HALF_NOTE_TIME, () => {
                ExecutionStarted?.Invoke(matchingSong, curStreakPower);
                DisableTouchHandler();
            }));
            ExecutionStarting?.Invoke(_currentSong, curStreakPower);
            _currentCommandUpdate = _currentSong.ExecuteCommandUpdate;
            ResetBeatAfterSeconds(NOTE_TIME * 4);
        }
Пример #9
0
        private void NoteHit(NoteQuality quality, float diff)
        {
            updateClickLocation();
            Image hitImage;

            if (quality == NoteQuality.Bad)
            {
                hitImage = diff > 0 ? hitEarly : hitLate;
            }
            else
            {
                hitImage = _beatHitImages[quality];
            }
            _beatHitFadeHashtable["onupdate"] = CreateFadeDelegate(hitImage);
            GameObject hitImageGo = hitImage.gameObject;

            hitImageGo.transform.eulerAngles = Random.value * 90 * Vector3.back;
            Vector2 center = new Vector2(Screen.width / 2f, Screen.height / 2f);

            hitImageGo.transform.position = Vector2.Lerp(center, _latestTouchPosition, .5f);
            iTween.PunchScale(hitImageGo, _punchScaleHashtable);
            iTween.ValueTo(hitImageGo, _beatHitFadeHashtable);
        }
Пример #10
0
        private void PunchClosestIndicator(NoteQuality noteQuality, float diff)
        {
            if (noteQuality == NoteQuality.Miss)
            {
                return;
            }

            // if we don't have a beat, we reset and thus always punch the first index
            if (_hadBeat)
            {
                float closestDist = 1;
                for (int i = 0; i < _indicatorLines.Count; i++)
                {
                    float curDist = CalcDistToIndicator(_indicatorLines[i]);
                    if (closestDist > curDist)
                    {
                        closestDist = curDist;
                    }
                }
            }
//            iTween.PunchScale(_indicatorLines[closestIndex].gameObject, Vector3.one * 1.1f, BeatInputService.NOTE_TIME);
            iTween.PunchScale(metronomeDiffIndicator.gameObject, Vector3.one * 1.1f, BeatInputService.NOTE_TIME * .75f);
        }
Пример #11
0
 private void NoteHit(NoteQuality arg1, float diff)
 {
     _animator.SetTrigger(nextAnim);
     nextAnim = nextAnim == LeftPerfect ? RightPerfect : LeftPerfect;
 }
Пример #12
0
 private void SetDegreeQuality(ScaleDegree degree, NoteQuality quality)
 {
     _noteQualities[(int) degree] = quality;
 }
Пример #13
0
 public abstract void Executed(NoteQuality noteQuality, int streak);
Пример #14
0
 private void OnCommandExecuted(NoteQuality noteQuality, int streak)
 {
     _curStreakPower = streak;
     streakBonus     = CalcStreakBonus();
     Executed(noteQuality, streak);
 }
Пример #15
0
 public void ExecuteCommand(NoteQuality noteQuality, int streakLength)
 {
     Debug.Log("Executing song " + Name);
     CommandExecuted?.Invoke(noteQuality, streakLength);
 }
Пример #16
0
 private void NoteHit(NoteQuality quality, float diff)
 {
     ServiceLocator.Get <AudioService>().PlayOneShot(clips[quality]);
 }